| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { | 130 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { |
| 131 std::string error_message(kServiceWorkerRegisterErrorPrefix); | 131 std::string error_message(kServiceWorkerRegisterErrorPrefix); |
| 132 error_message += "The provided scriptURL or scope is too long."; | 132 error_message += "The provided scriptURL or scope is too long."; |
| 133 callbacks->OnError( | 133 callbacks->OnError( |
| 134 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, | 134 WebServiceWorkerError(WebServiceWorkerError::kErrorTypeSecurity, |
| 135 blink::WebString::FromASCII(error_message))); | 135 blink::WebString::FromASCII(error_message))); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 int request_id = pending_registration_callbacks_.Add(std::move(callbacks)); | 139 int request_id = pending_registration_callbacks_.Add(std::move(callbacks)); |
| 140 ServiceWorkerRegistrationOptions options(pattern); |
| 141 |
| 140 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", | 142 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", |
| 141 "ServiceWorkerDispatcher::RegisterServiceWorker", | 143 "ServiceWorkerDispatcher::RegisterServiceWorker", |
| 142 request_id, | 144 request_id, |
| 143 "Scope", pattern.spec(), | 145 "Scope", pattern.spec(), |
| 144 "Script URL", script_url.spec()); | 146 "Script URL", script_url.spec()); |
| 145 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( | 147 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
| 146 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); | 148 CurrentWorkerId(), request_id, provider_id, script_url, options)); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void ServiceWorkerDispatcher::UpdateServiceWorker( | 151 void ServiceWorkerDispatcher::UpdateServiceWorker( |
| 150 int provider_id, | 152 int provider_id, |
| 151 int64_t registration_id, | 153 int64_t registration_id, |
| 152 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { | 154 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { |
| 153 DCHECK(callbacks); | 155 DCHECK(callbacks); |
| 154 int request_id = pending_update_callbacks_.Add(std::move(callbacks)); | 156 int request_id = pending_update_callbacks_.Add(std::move(callbacks)); |
| 155 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( | 157 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( |
| 156 CurrentWorkerId(), request_id, provider_id, registration_id)); | 158 CurrentWorkerId(), request_id, provider_id, registration_id)); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 return ServiceWorkerRegistrationHandleReference::Adopt( | 929 return ServiceWorkerRegistrationHandleReference::Adopt( |
| 928 info, thread_safe_sender_.get()); | 930 info, thread_safe_sender_.get()); |
| 929 } | 931 } |
| 930 | 932 |
| 931 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 933 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
| 932 const ServiceWorkerObjectInfo& info) { | 934 const ServiceWorkerObjectInfo& info) { |
| 933 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 935 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
| 934 } | 936 } |
| 935 | 937 |
| 936 } // namespace content | 938 } // namespace content |
| OLD | NEW |