Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: fix a database error Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/service_worker/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CountFeature, OnCountFeature) 117 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CountFeature, OnCountFeature)
118 IPC_MESSAGE_UNHANDLED(handled = false) 118 IPC_MESSAGE_UNHANDLED(handled = false)
119 IPC_END_MESSAGE_MAP() 119 IPC_END_MESSAGE_MAP()
120 DCHECK(handled) << "Unhandled message:" << msg.type(); 120 DCHECK(handled) << "Unhandled message:" << msg.type();
121 } 121 }
122 122
123 void ServiceWorkerDispatcher::RegisterServiceWorker( 123 void ServiceWorkerDispatcher::RegisterServiceWorker(
124 int provider_id, 124 int provider_id,
125 const GURL& pattern, 125 const GURL& pattern,
126 const GURL& script_url, 126 const GURL& script_url,
127 blink::WebServiceWorkerUpdateViaCache update_via_cache,
127 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) { 128 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) {
128 DCHECK(callbacks); 129 DCHECK(callbacks);
129 130
130 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars || 131 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars ||
131 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { 132 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) {
132 std::string error_message(kServiceWorkerRegisterErrorPrefix); 133 std::string error_message(kServiceWorkerRegisterErrorPrefix);
133 error_message += "The provided scriptURL or scope is too long."; 134 error_message += "The provided scriptURL or scope is too long.";
134 callbacks->OnError( 135 callbacks->OnError(
135 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, 136 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity,
136 blink::WebString::FromASCII(error_message))); 137 blink::WebString::FromASCII(error_message)));
137 return; 138 return;
138 } 139 }
139 140
140 int request_id = pending_registration_callbacks_.Add(std::move(callbacks)); 141 int request_id = pending_registration_callbacks_.Add(std::move(callbacks));
141 ServiceWorkerRegistrationOptions options(pattern); 142 ServiceWorkerRegistrationOptions options(pattern, update_via_cache);
142 143
143 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", 144 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker",
144 "ServiceWorkerDispatcher::RegisterServiceWorker", 145 "ServiceWorkerDispatcher::RegisterServiceWorker",
145 request_id, 146 request_id,
146 "Scope", pattern.spec(), 147 "Scope", pattern.spec(),
147 "Script URL", script_url.spec()); 148 "Script URL", script_url.spec());
148 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( 149 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker(
149 CurrentWorkerId(), request_id, provider_id, script_url, options)); 150 CurrentWorkerId(), request_id, provider_id, script_url, options));
150 } 151 }
151 152
(...skipping 30 matching lines...) Expand all
182 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); 183 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix);
183 error_message += "The provided documentURL is too long."; 184 error_message += "The provided documentURL is too long.";
184 callbacks->OnError( 185 callbacks->OnError(
185 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, 186 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity,
186 blink::WebString::FromASCII(error_message))); 187 blink::WebString::FromASCII(error_message)));
187 return; 188 return;
188 } 189 }
189 190
190 int request_id = 191 int request_id =
191 pending_get_registration_callbacks_.Add(std::move(callbacks)); 192 pending_get_registration_callbacks_.Add(std::move(callbacks));
193
192 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", 194 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
193 "ServiceWorkerDispatcher::GetRegistration", 195 "ServiceWorkerDispatcher::GetRegistration",
194 request_id, 196 request_id,
195 "Document URL", document_url.spec()); 197 "Document URL", document_url.spec());
196 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( 198 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration(
197 CurrentWorkerId(), request_id, provider_id, document_url)); 199 CurrentWorkerId(), request_id, provider_id, document_url));
198 } 200 }
199 201
200 void ServiceWorkerDispatcher::GetRegistrations( 202 void ServiceWorkerDispatcher::GetRegistrations(
201 int provider_id, 203 int provider_id,
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return ServiceWorkerRegistrationHandleReference::Adopt( 940 return ServiceWorkerRegistrationHandleReference::Adopt(
939 info, thread_safe_sender_.get()); 941 info, thread_safe_sender_.get());
940 } 942 }
941 943
942 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( 944 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt(
943 const ServiceWorkerObjectInfo& info) { 945 const ServiceWorkerObjectInfo& info) {
944 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 946 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
945 } 947 }
946 948
947 } // namespace content 949 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698