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/stl_util.h" | 8 #include "base/stl_util.h" |
8 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
9 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
10 #include "content/browser/frame_host/render_frame_host_impl.h" | 11 #include "content/browser/frame_host/render_frame_host_impl.h" |
11 #include "content/browser/message_port_message_filter.h" | 12 #include "content/browser/message_port_message_filter.h" |
12 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
13 #include "content/browser/service_worker/service_worker_context_request_handler.
h" | 14 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
14 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" | 15 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" |
15 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 16 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
16 #include "content/browser/service_worker/service_worker_handle.h" | 17 #include "content/browser/service_worker/service_worker_handle.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 59 |
59 } // anonymous namespace | 60 } // anonymous namespace |
60 | 61 |
61 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 62 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
62 int render_process_id, | 63 int render_process_id, |
63 int render_frame_id, | 64 int render_frame_id, |
64 int provider_id, | 65 int provider_id, |
65 ServiceWorkerProviderType provider_type, | 66 ServiceWorkerProviderType provider_type, |
66 base::WeakPtr<ServiceWorkerContextCore> context, | 67 base::WeakPtr<ServiceWorkerContextCore> context, |
67 ServiceWorkerDispatcherHost* dispatcher_host) | 68 ServiceWorkerDispatcherHost* dispatcher_host) |
68 : render_process_id_(render_process_id), | 69 : client_uuid_(base::GenerateGUID()), |
| 70 render_process_id_(render_process_id), |
69 render_frame_id_(render_frame_id), | 71 render_frame_id_(render_frame_id), |
70 render_thread_id_(kDocumentMainThreadId), | 72 render_thread_id_(kDocumentMainThreadId), |
71 provider_id_(provider_id), | 73 provider_id_(provider_id), |
72 provider_type_(provider_type), | 74 provider_type_(provider_type), |
73 context_(context), | 75 context_(context), |
74 dispatcher_host_(dispatcher_host), | 76 dispatcher_host_(dispatcher_host), |
75 allow_association_(true), | 77 allow_association_(true), |
76 is_claiming_(false) { | 78 is_claiming_(false) { |
77 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 79 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
78 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); | 80 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); |
79 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { | 81 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { |
80 // Actual thread id is set when the service worker context gets started. | 82 // Actual thread id is set when the service worker context gets started. |
81 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; | 83 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; |
82 } | 84 } |
| 85 context_->RegisterClientIDForProviderHost(client_uuid_, this); |
83 } | 86 } |
84 | 87 |
85 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { | 88 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { |
86 // Clear docurl so the deferred activation of a waiting worker | 89 // Clear docurl so the deferred activation of a waiting worker |
87 // won't associate the new version with a provider being destroyed. | 90 // won't associate the new version with a provider being destroyed. |
88 document_url_ = GURL(); | 91 document_url_ = GURL(); |
89 if (controlling_version_.get()) | 92 if (controlling_version_.get()) |
90 controlling_version_->RemoveControllee(this); | 93 controlling_version_->RemoveControllee(this); |
91 if (associated_registration_.get()) { | 94 if (associated_registration_.get()) { |
92 DecreaseProcessReference(associated_registration_->pattern()); | 95 DecreaseProcessReference(associated_registration_->pattern()); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 return context_ != NULL; | 515 return context_ != NULL; |
513 } | 516 } |
514 | 517 |
515 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { | 518 void ServiceWorkerProviderHost::Send(IPC::Message* message) const { |
516 DCHECK(dispatcher_host_); | 519 DCHECK(dispatcher_host_); |
517 DCHECK(IsReadyToSendMessages()); | 520 DCHECK(IsReadyToSendMessages()); |
518 dispatcher_host_->Send(message); | 521 dispatcher_host_->Send(message); |
519 } | 522 } |
520 | 523 |
521 } // namespace content | 524 } // namespace content |
OLD | NEW |