diff options
-rw-r--r-- | net/base/net_log_event_type_list.h | 14 | ||||
-rw-r--r-- | webkit/appcache/appcache_request_handler.cc | 19 | ||||
-rw-r--r-- | webkit/appcache/appcache_request_handler.h | 2 | ||||
-rw-r--r-- | webkit/appcache/appcache_url_request_job.cc | 14 | ||||
-rw-r--r-- | webkit/appcache/appcache_url_request_job.h | 3 | ||||
-rw-r--r-- | webkit/appcache/appcache_url_request_job_unittest.cc | 11 |
6 files changed, 47 insertions, 16 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index d9225f8..08f0be0 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -596,6 +596,20 @@ EVENT_TYPE(AUTH_PROXY) EVENT_TYPE(AUTH_SERVER) // ------------------------------------------------------------------------ +// HTML5 Application Cache +// ------------------------------------------------------------------------ + +// This event is emitted whenever a request is satistifed directly from +// the appache. +EVENT_TYPE(APPCACHE_DELIVERING_CACHED_RESPONSE) + +// This event is emitted whenever the appcache uses a fallback response. +EVENT_TYPE(APPCACHE_DELIVERING_FALLBACK_RESPONSE) + +// This event is emitted whenever the appcache generates an error response. +EVENT_TYPE(APPCACHE_DELIVERING_ERROR_RESPONSE) + +// ------------------------------------------------------------------------ // Global events // ------------------------------------------------------------------------ // These are events which are not grouped by source id, as they have no diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index 28a9149..432534b 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -97,8 +97,8 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect( // 6.9.6, step 4: If this results in a redirect to another origin, // get the resource of the fallback entry. job_ = new AppCacheURLRequestJob(request, storage()); - DeliverAppCachedResponse(found_fallback_entry_, found_cache_id_, - found_manifest_url_); + DeliverAppCachedResponse( + found_fallback_entry_, found_cache_id_, found_manifest_url_, true); } else if (!found_network_namespace_) { // 6.9.6, step 6: Fail the resource load. job_ = new AppCacheURLRequestJob(request, storage()); @@ -138,8 +138,8 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse( // 6.9.6, step 4: If this results in a 4xx or 5xx status code // or there were network errors, get the resource of the fallback entry. job_ = new AppCacheURLRequestJob(request, storage()); - DeliverAppCachedResponse(found_fallback_entry_, found_cache_id_, - found_manifest_url_); + DeliverAppCachedResponse( + found_fallback_entry_, found_cache_id_, found_manifest_url_, true); return job_; } @@ -156,10 +156,11 @@ void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) { } void AppCacheRequestHandler::DeliverAppCachedResponse( - const AppCacheEntry& entry, int64 cache_id, const GURL& manifest_url) { + const AppCacheEntry& entry, int64 cache_id, const GURL& manifest_url, + bool is_fallback) { DCHECK(job_ && job_->is_waiting()); DCHECK(entry.has_response_id()); - job_->DeliverAppCachedResponse(manifest_url, cache_id, entry); + job_->DeliverAppCachedResponse(manifest_url, cache_id, entry, is_fallback); } void AppCacheRequestHandler::DeliverErrorResponse() { @@ -220,8 +221,8 @@ void AppCacheRequestHandler::OnMainResponseFound( found_network_namespace_ = false; // not applicable to main requests if (found_entry_.has_response_id()) { - DeliverAppCachedResponse(found_entry_, found_cache_id_, - found_manifest_url_); + DeliverAppCachedResponse( + found_entry_, found_cache_id_, found_manifest_url_, false); } else { DeliverNetworkResponse(); } @@ -271,7 +272,7 @@ void AppCacheRequestHandler::ContinueMaybeLoadSubResource() { found_cache_id_ = cache->cache_id(); found_manifest_url_ = cache->owning_group()->manifest_url(); DeliverAppCachedResponse( - found_entry_, found_cache_id_, found_manifest_url_); + found_entry_, found_cache_id_, found_manifest_url_, false); return; } diff --git a/webkit/appcache/appcache_request_handler.h b/webkit/appcache/appcache_request_handler.h index 77613f8..0910dee 100644 --- a/webkit/appcache/appcache_request_handler.h +++ b/webkit/appcache/appcache_request_handler.h @@ -53,7 +53,7 @@ class AppCacheRequestHandler : public URLRequest::UserData, // Helpers to instruct a waiting job with what response to // deliver for the request we're handling. void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, - const GURL& manifest_url); + const GURL& manifest_url, bool is_fallback); void DeliverNetworkResponse(); void DeliverErrorResponse(); diff --git a/webkit/appcache/appcache_url_request_job.cc b/webkit/appcache/appcache_url_request_job.cc index 05a5016..76a6663 100644 --- a/webkit/appcache/appcache_url_request_job.cc +++ b/webkit/appcache/appcache_url_request_job.cc @@ -9,8 +9,10 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "net/base/net_errors.h" +#include "net/base/net_log.h" #include "net/http/http_request_headers.h" #include "net/http/http_util.h" +#include "net/url_request/url_request.h" #include "net/url_request/url_request_status.h" namespace appcache { @@ -21,6 +23,7 @@ AppCacheURLRequestJob::AppCacheURLRequestJob( has_been_started_(false), has_been_killed_(false), delivery_type_(AWAITING_DELIVERY_ORDERS), cache_id_(kNoCacheId), + is_fallback_(false), ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( this, &AppCacheURLRequestJob::OnReadComplete)) { DCHECK(storage_); @@ -32,13 +35,15 @@ AppCacheURLRequestJob::~AppCacheURLRequestJob() { } void AppCacheURLRequestJob::DeliverAppCachedResponse( - const GURL& manifest_url, int64 cache_id, const AppCacheEntry& entry) { + const GURL& manifest_url, int64 cache_id, const AppCacheEntry& entry, + bool is_fallback) { DCHECK(!has_delivery_orders()); DCHECK(entry.has_response_id()); delivery_type_ = APPCACHED_DELIVERY; manifest_url_ = manifest_url; cache_id_ = cache_id; entry_ = entry; + is_fallback_ = is_fallback; MaybeBeginDelivery(); } @@ -81,11 +86,18 @@ void AppCacheURLRequestJob::BeginDelivery() { break; case ERROR_DELIVERY: + request()->net_log().AddEvent( + net::NetLog::TYPE_APPCACHE_DELIVERING_ERROR_RESPONSE, NULL); NotifyStartError( URLRequestStatus(URLRequestStatus::FAILED, net::ERR_FAILED)); break; case APPCACHED_DELIVERY: + request()->net_log().AddEvent( + is_fallback_ ? + net::NetLog::TYPE_APPCACHE_DELIVERING_FALLBACK_RESPONSE : + net::NetLog::TYPE_APPCACHE_DELIVERING_CACHED_RESPONSE, + NULL); storage_->LoadResponseInfo(manifest_url_, entry_.response_id(), this); break; diff --git a/webkit/appcache/appcache_url_request_job.h b/webkit/appcache/appcache_url_request_job.h index 68d8622..5e7dce2 100644 --- a/webkit/appcache/appcache_url_request_job.h +++ b/webkit/appcache/appcache_url_request_job.h @@ -28,7 +28,7 @@ class AppCacheURLRequestJob : public URLRequestJob, // methods should be called, and only once per job. A job will sit idle and // wait indefinitely until one of the deliver methods is called. void DeliverAppCachedResponse(const GURL& manifest_url, int64 cache_id, - const AppCacheEntry& entry); + const AppCacheEntry& entry, bool is_fallback); void DeliverNetworkResponse(); void DeliverErrorResponse(); @@ -131,6 +131,7 @@ class AppCacheURLRequestJob : public URLRequestJob, GURL manifest_url_; int64 cache_id_; AppCacheEntry entry_; + bool is_fallback_; scoped_refptr<AppCacheResponseInfo> info_; net::HttpByteRange range_requested_; scoped_ptr<net::HttpResponseInfo> range_response_info_; diff --git a/webkit/appcache/appcache_url_request_job_unittest.cc b/webkit/appcache/appcache_url_request_job_unittest.cc index 5799cad..44413ad 100644 --- a/webkit/appcache/appcache_url_request_job_unittest.cc +++ b/webkit/appcache/appcache_url_request_job_unittest.cc @@ -434,7 +434,7 @@ class AppCacheURLRequestJobTest : public testing::Test { const GURL kManifestUrl("http://blah/"); const int64 kCacheId(1); const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1); - job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kEntry); + job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kEntry, false); EXPECT_FALSE(job->is_waiting()); EXPECT_TRUE(job->is_delivering_appcache_response()); EXPECT_FALSE(job->has_been_started()); @@ -543,7 +543,8 @@ class AppCacheURLRequestJobTest : public testing::Test { if (start_after_delivery_orders) { job->DeliverAppCachedResponse( GURL(), 111, - AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_)); + AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), + false); EXPECT_TRUE(job->is_delivering_appcache_response()); } @@ -557,7 +558,8 @@ class AppCacheURLRequestJobTest : public testing::Test { if (!start_after_delivery_orders) { job->DeliverAppCachedResponse( GURL(), 111, - AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_)); + AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), + false); EXPECT_TRUE(job->is_delivering_appcache_response()); } @@ -652,7 +654,8 @@ class AppCacheURLRequestJobTest : public testing::Test { new AppCacheURLRequestJob(request_.get(), storage)); job->DeliverAppCachedResponse( GURL(), 111, - AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_)); + AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), + false); EXPECT_TRUE(job->is_delivering_appcache_response()); // Start the request. |