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)); |
| 141 ServiceWorkerRegistrationOptions options(pattern, update_via_cache); |
| 142 |
140 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", | 143 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", |
141 "ServiceWorkerDispatcher::RegisterServiceWorker", | 144 "ServiceWorkerDispatcher::RegisterServiceWorker", |
142 request_id, | 145 request_id, |
143 "Scope", pattern.spec(), | 146 "Scope", pattern.spec(), |
144 "Script URL", script_url.spec()); | 147 "Script URL", script_url.spec()); |
145 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( | 148 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
146 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); | 149 CurrentWorkerId(), request_id, provider_id, script_url, options)); |
147 } | 150 } |
148 | 151 |
149 void ServiceWorkerDispatcher::UpdateServiceWorker( | 152 void ServiceWorkerDispatcher::UpdateServiceWorker( |
150 int provider_id, | 153 int provider_id, |
151 int64_t registration_id, | 154 int64_t registration_id, |
152 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { | 155 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { |
153 DCHECK(callbacks); | 156 DCHECK(callbacks); |
154 int request_id = pending_update_callbacks_.Add(std::move(callbacks)); | 157 int request_id = pending_update_callbacks_.Add(std::move(callbacks)); |
155 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( | 158 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( |
156 CurrentWorkerId(), request_id, provider_id, registration_id)); | 159 CurrentWorkerId(), request_id, provider_id, registration_id)); |
(...skipping 22 matching lines...) Expand all Loading... |
179 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); | 182 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); |
180 error_message += "The provided documentURL is too long."; | 183 error_message += "The provided documentURL is too long."; |
181 callbacks->OnError( | 184 callbacks->OnError( |
182 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, | 185 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, |
183 blink::WebString::FromASCII(error_message))); | 186 blink::WebString::FromASCII(error_message))); |
184 return; | 187 return; |
185 } | 188 } |
186 | 189 |
187 int request_id = | 190 int request_id = |
188 pending_get_registration_callbacks_.Add(std::move(callbacks)); | 191 pending_get_registration_callbacks_.Add(std::move(callbacks)); |
| 192 |
189 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", | 193 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", |
190 "ServiceWorkerDispatcher::GetRegistration", | 194 "ServiceWorkerDispatcher::GetRegistration", |
191 request_id, | 195 request_id, |
192 "Document URL", document_url.spec()); | 196 "Document URL", document_url.spec()); |
193 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( | 197 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( |
194 CurrentWorkerId(), request_id, provider_id, document_url)); | 198 CurrentWorkerId(), request_id, provider_id, document_url)); |
195 } | 199 } |
196 | 200 |
197 void ServiceWorkerDispatcher::GetRegistrations( | 201 void ServiceWorkerDispatcher::GetRegistrations( |
198 int provider_id, | 202 int provider_id, |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 return ServiceWorkerRegistrationHandleReference::Adopt( | 926 return ServiceWorkerRegistrationHandleReference::Adopt( |
923 info, thread_safe_sender_.get()); | 927 info, thread_safe_sender_.get()); |
924 } | 928 } |
925 | 929 |
926 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 930 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
927 const ServiceWorkerObjectInfo& info) { | 931 const ServiceWorkerObjectInfo& info) { |
928 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 932 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
929 } | 933 } |
930 | 934 |
931 } // namespace content | 935 } // namespace content |
OLD | NEW |