OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CountFeature, OnCountFeature) | 116 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CountFeature, OnCountFeature) |
117 IPC_MESSAGE_UNHANDLED(handled = false) | 117 IPC_MESSAGE_UNHANDLED(handled = false) |
118 IPC_END_MESSAGE_MAP() | 118 IPC_END_MESSAGE_MAP() |
119 DCHECK(handled) << "Unhandled message:" << msg.type(); | 119 DCHECK(handled) << "Unhandled message:" << msg.type(); |
120 } | 120 } |
121 | 121 |
122 void ServiceWorkerDispatcher::RegisterServiceWorker( | 122 void ServiceWorkerDispatcher::RegisterServiceWorker( |
123 int provider_id, | 123 int provider_id, |
124 const GURL& pattern, | 124 const GURL& pattern, |
125 const GURL& script_url, | 125 const GURL& script_url, |
| 126 blink::WebServiceWorkerUpdateViaCache update_via_cache, |
126 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) { | 127 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) { |
127 DCHECK(callbacks); | 128 DCHECK(callbacks); |
128 | 129 |
129 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars || | 130 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars || |
130 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { | 131 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { |
131 std::string error_message(kServiceWorkerRegisterErrorPrefix); | 132 std::string error_message(kServiceWorkerRegisterErrorPrefix); |
132 error_message += "The provided scriptURL or scope is too long."; | 133 error_message += "The provided scriptURL or scope is too long."; |
133 callbacks->OnError( | 134 callbacks->OnError( |
134 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, | 135 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, |
135 blink::WebString::FromASCII(error_message))); | 136 blink::WebString::FromASCII(error_message))); |
136 return; | 137 return; |
137 } | 138 } |
138 | 139 |
139 int request_id = pending_registration_callbacks_.Add(std::move(callbacks)); | 140 int request_id = pending_registration_callbacks_.Add(std::move(callbacks)); |
140 ServiceWorkerRegistrationOptions options(pattern); | 141 ServiceWorkerRegistrationOptions options(pattern, update_via_cache); |
141 | 142 |
142 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", | 143 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", |
143 "ServiceWorkerDispatcher::RegisterServiceWorker", | 144 "ServiceWorkerDispatcher::RegisterServiceWorker", |
144 request_id, | 145 request_id, |
145 "Scope", pattern.spec(), | 146 "Scope", pattern.spec(), |
146 "Script URL", script_url.spec()); | 147 "Script URL", script_url.spec()); |
147 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( | 148 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
148 CurrentWorkerId(), request_id, provider_id, script_url, options)); | 149 CurrentWorkerId(), request_id, provider_id, script_url, options)); |
149 } | 150 } |
150 | 151 |
(...skipping 30 matching lines...) Expand all Loading... |
181 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); | 182 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); |
182 error_message += "The provided documentURL is too long."; | 183 error_message += "The provided documentURL is too long."; |
183 callbacks->OnError( | 184 callbacks->OnError( |
184 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, | 185 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, |
185 blink::WebString::FromASCII(error_message))); | 186 blink::WebString::FromASCII(error_message))); |
186 return; | 187 return; |
187 } | 188 } |
188 | 189 |
189 int request_id = | 190 int request_id = |
190 pending_get_registration_callbacks_.Add(std::move(callbacks)); | 191 pending_get_registration_callbacks_.Add(std::move(callbacks)); |
| 192 |
191 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", | 193 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", |
192 "ServiceWorkerDispatcher::GetRegistration", | 194 "ServiceWorkerDispatcher::GetRegistration", |
193 request_id, | 195 request_id, |
194 "Document URL", document_url.spec()); | 196 "Document URL", document_url.spec()); |
195 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( | 197 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( |
196 CurrentWorkerId(), request_id, provider_id, document_url)); | 198 CurrentWorkerId(), request_id, provider_id, document_url)); |
197 } | 199 } |
198 | 200 |
199 void ServiceWorkerDispatcher::GetRegistrations( | 201 void ServiceWorkerDispatcher::GetRegistrations( |
200 int provider_id, | 202 int provider_id, |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 return ServiceWorkerRegistrationHandleReference::Adopt( | 931 return ServiceWorkerRegistrationHandleReference::Adopt( |
930 info, thread_safe_sender_.get()); | 932 info, thread_safe_sender_.get()); |
931 } | 933 } |
932 | 934 |
933 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 935 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
934 const ServiceWorkerObjectInfo& info) { | 936 const ServiceWorkerObjectInfo& info) { |
935 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 937 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
936 } | 938 } |
937 | 939 |
938 } // namespace content | 940 } // namespace content |
OLD | NEW |