| 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/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/service_worker/embedded_worker_registry.h" | 8 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 thread_id, | 107 thread_id, |
| 108 request_id, | 108 request_id, |
| 109 WebServiceWorkerError::SecurityError, | 109 WebServiceWorkerError::SecurityError, |
| 110 base::ASCIIToUTF16(kDomainMismatchErrorMessage))); | 110 base::ASCIIToUTF16(kDomainMismatchErrorMessage))); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 | 113 |
| 114 context_->RegisterServiceWorker( | 114 context_->RegisterServiceWorker( |
| 115 pattern, | 115 pattern, |
| 116 script_url, | 116 script_url, |
| 117 render_process_id_, |
| 117 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, | 118 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, |
| 118 this, | 119 this, |
| 119 thread_id, | 120 thread_id, |
| 120 request_id)); | 121 request_id)); |
| 121 } | 122 } |
| 122 | 123 |
| 123 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( | 124 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
| 124 int32 thread_id, | 125 int32 thread_id, |
| 125 int32 request_id, | 126 int32 request_id, |
| 126 const GURL& pattern) { | 127 const GURL& pattern) { |
| 127 // TODO(alecflett): This check is insufficient for release. Add a | 128 // TODO(alecflett): This check is insufficient for release. Add a |
| 128 // ServiceWorker-specific policy query in | 129 // ServiceWorker-specific policy query in |
| 129 // ChildProcessSecurityImpl. See http://crbug.com/311631. | 130 // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| 130 if (!context_ || !context_->IsEnabled()) { | 131 if (!context_ || !context_->IsEnabled()) { |
| 131 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 132 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 132 thread_id, | 133 thread_id, |
| 133 request_id, | 134 request_id, |
| 134 blink::WebServiceWorkerError::DisabledError, | 135 blink::WebServiceWorkerError::DisabledError, |
| 135 base::ASCIIToUTF16(kDisabledErrorMessage))); | 136 base::ASCIIToUTF16(kDisabledErrorMessage))); |
| 136 return; | 137 return; |
| 137 } | 138 } |
| 138 | 139 |
| 139 context_->UnregisterServiceWorker( | 140 context_->UnregisterServiceWorker( |
| 140 pattern, | 141 pattern, |
| 142 render_process_id_, |
| 141 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, | 143 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, |
| 142 this, | 144 this, |
| 143 thread_id, | 145 thread_id, |
| 144 request_id)); | 146 request_id)); |
| 145 } | 147 } |
| 146 | 148 |
| 147 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) { | 149 void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) { |
| 148 if (!context_) | 150 if (!context_) |
| 149 return; | 151 return; |
| 150 if (context_->GetProviderHost(render_process_id_, provider_id)) { | 152 if (context_->GetProviderHost(render_process_id_, provider_id)) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 ServiceWorkerStatusCode status) { | 224 ServiceWorkerStatusCode status) { |
| 223 base::string16 error_message; | 225 base::string16 error_message; |
| 224 blink::WebServiceWorkerError::ErrorType error_type; | 226 blink::WebServiceWorkerError::ErrorType error_type; |
| 225 GetServiceWorkerRegistrationStatusResponse( | 227 GetServiceWorkerRegistrationStatusResponse( |
| 226 status, &error_type, &error_message); | 228 status, &error_type, &error_message); |
| 227 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 229 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 228 thread_id, request_id, error_type, error_message)); | 230 thread_id, request_id, error_type, error_message)); |
| 229 } | 231 } |
| 230 | 232 |
| 231 } // namespace content | 233 } // namespace content |
| OLD | NEW |