From 105051f09b0e850eba29efc12f067154f52c35b3 Mon Sep 17 00:00:00 2001 From: "horo@chromium.org" Date: Sun, 22 Jun 2014 15:39:50 +0000 Subject: [PATCH] Add isReload attribute to FetchEvent [chromium] (2/3) http://www.w3.org/TR/service-workers/#is-reload-attribute Multi-sided patch: 1/3: blink-side, https://codereview.chromium.org/332903003/ 2/3: chromium-side, THIS PATCH 3/3: blink-side, change IDL, Not Yet. BUG=386507 Review URL: https://codereview.chromium.org/341043002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279008 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/service_worker/service_worker_browsertest.cc | 3 ++- .../browser/service_worker/service_worker_fetch_dispatcher.cc | 7 +++++++ content/common/service_worker/service_worker_messages.h | 1 + content/common/service_worker/service_worker_types.cc | 10 +++++----- content/common/service_worker/service_worker_types.h | 9 +++++---- .../renderer/service_worker/service_worker_script_context.cc | 1 + 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index 4846b075de8f..8dc32a8e8474 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc @@ -380,7 +380,8 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { ServiceWorkerFetchRequest request( embedded_test_server()->GetURL("/service_worker/empty.html"), "GET", - std::map()); + std::map(), + false); version_->SetStatus(ServiceWorkerVersion::ACTIVE); version_->DispatchFetchEvent( request, CreateResponseReceiver(BrowserThread::UI, done, diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.cc b/content/browser/service_worker/service_worker_fetch_dispatcher.cc index 81be9aff2a7e..7562d43eea61 100644 --- a/content/browser/service_worker/service_worker_fetch_dispatcher.cc +++ b/content/browser/service_worker/service_worker_fetch_dispatcher.cc @@ -6,6 +6,8 @@ #include "base/bind.h" #include "content/browser/service_worker/service_worker_version.h" +#include "content/public/browser/resource_request_info.h" +#include "content/public/common/page_transition_types.h" #include "net/url_request/url_request.h" namespace content { @@ -22,6 +24,11 @@ ServiceWorkerFetchDispatcher::ServiceWorkerFetchDispatcher( const net::HttpRequestHeaders& headers = request->extra_request_headers(); for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) request_.headers[it.name()] = it.value(); + const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); + if (info) { + request_.is_reload = PageTransitionCoreTypeIs(info->GetPageTransition(), + PAGE_TRANSITION_RELOAD); + } } ServiceWorkerFetchDispatcher::~ServiceWorkerFetchDispatcher() {} diff --git a/content/common/service_worker/service_worker_messages.h b/content/common/service_worker/service_worker_messages.h index 0b0cb4ea821c..fa655052a77b 100644 --- a/content/common/service_worker/service_worker_messages.h +++ b/content/common/service_worker/service_worker_messages.h @@ -31,6 +31,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerFetchRequest) IPC_STRUCT_TRAITS_MEMBER(url) IPC_STRUCT_TRAITS_MEMBER(method) IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(is_reload) IPC_STRUCT_TRAITS_END() IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerFetchEventResult, diff --git a/content/common/service_worker/service_worker_types.cc b/content/common/service_worker/service_worker_types.cc index ce5cd7aee07f..25da8d9c5e85 100644 --- a/content/common/service_worker/service_worker_types.cc +++ b/content/common/service_worker/service_worker_types.cc @@ -6,15 +6,15 @@ namespace content { -ServiceWorkerFetchRequest::ServiceWorkerFetchRequest() {} +ServiceWorkerFetchRequest::ServiceWorkerFetchRequest() : is_reload(false) { +} ServiceWorkerFetchRequest::ServiceWorkerFetchRequest( const GURL& url, const std::string& method, - const std::map& headers) - : url(url), - method(method), - headers(headers) { + const std::map& headers, + bool is_reload) + : url(url), method(method), headers(headers), is_reload(is_reload) { } ServiceWorkerFetchRequest::~ServiceWorkerFetchRequest() {} diff --git a/content/common/service_worker/service_worker_types.h b/content/common/service_worker/service_worker_types.h index 8f49f9a5635f..8ee5545d50c2 100644 --- a/content/common/service_worker/service_worker_types.h +++ b/content/common/service_worker/service_worker_types.h @@ -36,15 +36,16 @@ const static int64 kInvalidServiceWorkerResponseId = -1; // we'll probably want to have response struct/class too. struct CONTENT_EXPORT ServiceWorkerFetchRequest { ServiceWorkerFetchRequest(); - ServiceWorkerFetchRequest( - const GURL& url, - const std::string& method, - const std::map& headers); + ServiceWorkerFetchRequest(const GURL& url, + const std::string& method, + const std::map& headers, + bool is_reload); ~ServiceWorkerFetchRequest(); GURL url; std::string method; std::map headers; + bool is_reload; }; // Indicates how the service worker handled a fetch event. diff --git a/content/renderer/service_worker/service_worker_script_context.cc b/content/renderer/service_worker/service_worker_script_context.cc index ad0534134ba0..59264e5df96a 100644 --- a/content/renderer/service_worker/service_worker_script_context.cc +++ b/content/renderer/service_worker/service_worker_script_context.cc @@ -135,6 +135,7 @@ void ServiceWorkerScriptContext::OnFetchEvent( webRequest.setHeader(blink::WebString::fromUTF8(it->first), blink::WebString::fromUTF8(it->second)); } + webRequest.setIsReload(request.is_reload); proxy_->dispatchFetchEvent(request_id, webRequest); } -- 2.11.4.GIT