Chromium Code Reviews| 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/web_service_worker_provider_impl.h" | 5 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 6 | 6 |
| 7 #include "content/child/service_worker/service_worker_dispatcher.h" | 7 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 8 #include "content/child/service_worker/service_worker_handle_reference.h" | 8 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 9 #include "content/child/service_worker/service_worker_provider_context.h" | 9 #include "content/child/service_worker/service_worker_provider_context.h" |
| 10 #include "content/child/service_worker/web_service_worker_impl.h" | 10 #include "content/child/service_worker/web_service_worker_impl.h" |
| 11 #include "content/child/thread_safe_sender.h" | 11 #include "content/child/thread_safe_sender.h" |
| 12 #include "content/common/service_worker/service_worker_utils.h" | |
| 12 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" | 13 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" |
| 13 #include "third_party/WebKit/public/platform/WebURL.h" | 14 #include "third_party/WebKit/public/platform/WebURL.h" |
| 14 | 15 |
| 15 using blink::WebURL; | 16 using blink::WebURL; |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl( | 20 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl( |
| 20 ThreadSafeSender* thread_safe_sender, | 21 ThreadSafeSender* thread_safe_sender, |
| 21 ServiceWorkerProviderContext* context) | 22 ServiceWorkerProviderContext* context) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 WebServiceWorkerGetRegistrationsCallbacks* callbacks) { | 70 WebServiceWorkerGetRegistrationsCallbacks* callbacks) { |
| 70 GetDispatcher()->GetRegistrations( | 71 GetDispatcher()->GetRegistrations( |
| 71 context_->provider_id(), callbacks); | 72 context_->provider_id(), callbacks); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void WebServiceWorkerProviderImpl::getRegistrationForReady( | 75 void WebServiceWorkerProviderImpl::getRegistrationForReady( |
| 75 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) { | 76 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) { |
| 76 GetDispatcher()->GetRegistrationForReady(context_->provider_id(), callbacks); | 77 GetDispatcher()->GetRegistrationForReady(context_->provider_id(), callbacks); |
| 77 } | 78 } |
| 78 | 79 |
| 80 bool WebServiceWorkerProviderImpl::validateScopeAndScriptURL( | |
| 81 const blink::WebURL& scope, | |
| 82 const blink::WebURL& script_url, | |
| 83 blink::WebString* error_message) { | |
| 84 std::string error; | |
| 85 bool has_error = ServiceWorkerUtils::ContainsDisallowedCharacter( | |
| 86 scope, script_url, &error); | |
| 87 if (has_error) | |
| 88 *error_message = | |
| 89 blink::WebString::fromUTF8(kServiceWorkerRegisterErrorPrefix + error); | |
|
falken
2015/08/03 03:56:32
There's some discussion on the Blink patch about t
| |
| 90 return !has_error; | |
| 91 } | |
| 92 | |
| 79 int WebServiceWorkerProviderImpl::provider_id() const { | 93 int WebServiceWorkerProviderImpl::provider_id() const { |
| 80 return context_->provider_id(); | 94 return context_->provider_id(); |
| 81 } | 95 } |
| 82 | 96 |
| 83 void WebServiceWorkerProviderImpl::RemoveProviderClient() { | 97 void WebServiceWorkerProviderImpl::RemoveProviderClient() { |
| 84 // Remove the provider client, but only if the dispatcher is still there. | 98 // Remove the provider client, but only if the dispatcher is still there. |
| 85 // (For cleanup path we don't need to bother creating a new dispatcher) | 99 // (For cleanup path we don't need to bother creating a new dispatcher) |
| 86 ServiceWorkerDispatcher* dispatcher = | 100 ServiceWorkerDispatcher* dispatcher = |
| 87 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 101 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 88 if (dispatcher) | 102 if (dispatcher) |
| 89 dispatcher->RemoveProviderClient(context_->provider_id()); | 103 dispatcher->RemoveProviderClient(context_->provider_id()); |
| 90 } | 104 } |
| 91 | 105 |
| 92 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { | 106 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { |
| 93 return ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 107 return ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 94 } | 108 } |
| 95 | 109 |
| 96 } // namespace content | 110 } // namespace content |
| OLD | NEW |