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_provider_host.h" | 5 #include "content/browser/service_worker/service_worker_provider_host.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 render_process_id_(render_process_id), | 78 render_process_id_(render_process_id), |
79 route_id_(route_id), | 79 route_id_(route_id), |
80 render_thread_id_(kDocumentMainThreadId), | 80 render_thread_id_(kDocumentMainThreadId), |
81 provider_id_(provider_id), | 81 provider_id_(provider_id), |
82 provider_type_(provider_type), | 82 provider_type_(provider_type), |
83 context_(context), | 83 context_(context), |
84 dispatcher_host_(dispatcher_host), | 84 dispatcher_host_(dispatcher_host), |
85 allow_association_(true) { | 85 allow_association_(true) { |
86 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 86 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
87 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); | 87 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); |
| 88 DCHECK_NE(SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME, provider_type_); |
88 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { | 89 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { |
89 // Actual thread id is set when the service worker context gets started. | 90 // Actual thread id is set when the service worker context gets started. |
90 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; | 91 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; |
91 } | 92 } |
92 context_->RegisterProviderHostByClientID(client_uuid_, this); | 93 context_->RegisterProviderHostByClientID(client_uuid_, this); |
93 } | 94 } |
94 | 95 |
95 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { | 96 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { |
96 if (context_) | 97 if (context_) |
97 context_->UnregisterProviderHostByClientID(client_uuid_); | 98 context_->UnregisterProviderHostByClientID(client_uuid_); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return true; | 214 return true; |
214 } | 215 } |
215 | 216 |
216 bool ServiceWorkerProviderHost::IsProviderForClient() const { | 217 bool ServiceWorkerProviderHost::IsProviderForClient() const { |
217 switch (provider_type_) { | 218 switch (provider_type_) { |
218 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: | 219 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: |
219 case SERVICE_WORKER_PROVIDER_FOR_WORKER: | 220 case SERVICE_WORKER_PROVIDER_FOR_WORKER: |
220 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: | 221 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: |
221 return true; | 222 return true; |
222 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: | 223 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: |
| 224 return false; |
| 225 case SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME: |
223 case SERVICE_WORKER_PROVIDER_UNKNOWN: | 226 case SERVICE_WORKER_PROVIDER_UNKNOWN: |
224 return false; | 227 NOTREACHED() << provider_type_; |
225 } | 228 } |
226 NOTREACHED() << provider_type_; | 229 NOTREACHED() << provider_type_; |
227 return false; | 230 return false; |
228 } | 231 } |
229 | 232 |
230 blink::WebServiceWorkerClientType ServiceWorkerProviderHost::client_type() | 233 blink::WebServiceWorkerClientType ServiceWorkerProviderHost::client_type() |
231 const { | 234 const { |
232 switch (provider_type_) { | 235 switch (provider_type_) { |
233 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: | 236 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: |
234 return blink::WebServiceWorkerClientTypeWindow; | 237 return blink::WebServiceWorkerClientTypeWindow; |
235 case SERVICE_WORKER_PROVIDER_FOR_WORKER: | 238 case SERVICE_WORKER_PROVIDER_FOR_WORKER: |
236 return blink::WebServiceWorkerClientTypeWorker; | 239 return blink::WebServiceWorkerClientTypeWorker; |
237 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: | 240 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: |
238 return blink::WebServiceWorkerClientTypeSharedWorker; | 241 return blink::WebServiceWorkerClientTypeSharedWorker; |
239 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: | 242 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: |
| 243 case SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME: |
240 case SERVICE_WORKER_PROVIDER_UNKNOWN: | 244 case SERVICE_WORKER_PROVIDER_UNKNOWN: |
241 NOTREACHED() << provider_type_; | 245 NOTREACHED() << provider_type_; |
242 } | 246 } |
243 NOTREACHED() << provider_type_; | 247 NOTREACHED() << provider_type_; |
244 return blink::WebServiceWorkerClientTypeWindow; | 248 return blink::WebServiceWorkerClientTypeWindow; |
245 } | 249 } |
246 | 250 |
247 void ServiceWorkerProviderHost::AssociateRegistration( | 251 void ServiceWorkerProviderHost::AssociateRegistration( |
248 ServiceWorkerRegistration* registration, | 252 ServiceWorkerRegistration* registration, |
249 bool notify_controllerchange) { | 253 bool notify_controllerchange) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 return context_ != NULL; | 664 return context_ != NULL; |
661 } | 665 } |
662 | 666 |
663 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | 667 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { |
664 DCHECK(dispatcher_host_); | 668 DCHECK(dispatcher_host_); |
665 DCHECK(IsReadyToSendMessages()); | 669 DCHECK(IsReadyToSendMessages()); |
666 dispatcher_host_->Send(message); | 670 dispatcher_host_->Send(message); |
667 } | 671 } |
668 | 672 |
669 } // namespace content | 673 } // namespace content |
OLD | NEW |