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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( | 129 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
130 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); | 130 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); |
131 } | 131 } |
132 | 132 |
133 void ServiceWorkerDispatcher::UpdateServiceWorker(int provider_id, | 133 void ServiceWorkerDispatcher::UpdateServiceWorker(int provider_id, |
134 int64 registration_id) { | 134 int64 registration_id) { |
135 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( | 135 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( |
136 provider_id, registration_id)); | 136 provider_id, registration_id)); |
137 } | 137 } |
138 | 138 |
139 void ServiceWorkerDispatcher::DeprecatedUnregisterServiceWorker( | |
140 int provider_id, | |
141 const GURL& pattern, | |
142 WebServiceWorkerUnregistrationCallbacks* callbacks) { | |
143 DCHECK(callbacks); | |
144 | |
145 if (pattern.possibly_invalid_spec().size() > GetMaxURLChars()) { | |
146 scoped_ptr<WebServiceWorkerUnregistrationCallbacks> | |
147 owned_callbacks(callbacks); | |
148 std::string error_message(kServiceWorkerUnregisterErrorPrefix); | |
149 error_message += "The provided scope is too long."; | |
150 scoped_ptr<WebServiceWorkerError> error( | |
151 new WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, | |
152 blink::WebString::fromUTF8(error_message))); | |
153 callbacks->onError(error.release()); | |
154 return; | |
155 } | |
156 | |
157 int request_id = pending_unregistration_callbacks_.Add(callbacks); | |
158 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", | |
159 "ServiceWorkerDispatcher::UnregisterServiceWorker", | |
160 request_id, | |
161 "Scope", pattern.spec()); | |
162 thread_safe_sender_->Send( | |
163 new ServiceWorkerHostMsg_DeprecatedUnregisterServiceWorker( | |
164 CurrentWorkerId(), request_id, provider_id, pattern)); | |
165 } | |
166 | |
167 void ServiceWorkerDispatcher::UnregisterServiceWorker( | 139 void ServiceWorkerDispatcher::UnregisterServiceWorker( |
168 int provider_id, | 140 int provider_id, |
169 int64 registration_id, | 141 int64 registration_id, |
170 WebServiceWorkerUnregistrationCallbacks* callbacks) { | 142 WebServiceWorkerUnregistrationCallbacks* callbacks) { |
171 DCHECK(callbacks); | 143 DCHECK(callbacks); |
172 int request_id = pending_unregistration_callbacks_.Add(callbacks); | 144 int request_id = pending_unregistration_callbacks_.Add(callbacks); |
173 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", | 145 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", |
174 "ServiceWorkerDispatcher::UnregisterServiceWorker", | 146 "ServiceWorkerDispatcher::UnregisterServiceWorker", |
175 request_id, "Registration ID", registration_id); | 147 request_id, "Registration ID", registration_id); |
176 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( | 148 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 bool adopt_handle = true; | 758 bool adopt_handle = true; |
787 WebServiceWorkerRegistrationImpl* registration = | 759 WebServiceWorkerRegistrationImpl* registration = |
788 CreateServiceWorkerRegistration(info, adopt_handle); | 760 CreateServiceWorkerRegistration(info, adopt_handle); |
789 registration->SetInstalling(GetServiceWorker(attrs.installing, adopt_handle)); | 761 registration->SetInstalling(GetServiceWorker(attrs.installing, adopt_handle)); |
790 registration->SetWaiting(GetServiceWorker(attrs.waiting, adopt_handle)); | 762 registration->SetWaiting(GetServiceWorker(attrs.waiting, adopt_handle)); |
791 registration->SetActive(GetServiceWorker(attrs.active, adopt_handle)); | 763 registration->SetActive(GetServiceWorker(attrs.active, adopt_handle)); |
792 return registration; | 764 return registration; |
793 } | 765 } |
794 | 766 |
795 } // namespace content | 767 } // namespace content |
OLD | NEW |