| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // static | 90 // static |
| 91 std::unique_ptr<ServiceWorkerProviderHost> | 91 std::unique_ptr<ServiceWorkerProviderHost> |
| 92 ServiceWorkerProviderHost::PreCreateNavigationHost( | 92 ServiceWorkerProviderHost::PreCreateNavigationHost( |
| 93 base::WeakPtr<ServiceWorkerContextCore> context, | 93 base::WeakPtr<ServiceWorkerContextCore> context, |
| 94 bool are_ancestors_secure, | 94 bool are_ancestors_secure, |
| 95 const WebContentsGetter& web_contents_getter) { | 95 const WebContentsGetter& web_contents_getter) { |
| 96 CHECK(IsBrowserSideNavigationEnabled()); | 96 CHECK(IsBrowserSideNavigationEnabled()); |
| 97 // Generate a new browser-assigned id for the host. | 97 // Generate a new browser-assigned id for the host. |
| 98 int provider_id = g_next_navigation_provider_id--; | 98 int provider_id = g_next_navigation_provider_id--; |
| 99 auto host = base::WrapUnique(new ServiceWorkerProviderHost( | 99 auto host = base::WrapUnique(new ServiceWorkerProviderHost( |
| 100 ChildProcessHost::kInvalidUniqueID, | 100 ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE, provider_id, |
| 101 ServiceWorkerProviderHostInfo(provider_id, MSG_ROUTING_NONE, | 101 SERVICE_WORKER_PROVIDER_FOR_WINDOW, are_ancestors_secure, context, |
| 102 SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 102 nullptr)); |
| 103 are_ancestors_secure), | |
| 104 context, nullptr)); | |
| 105 host->web_contents_getter_ = web_contents_getter; | 103 host->web_contents_getter_ = web_contents_getter; |
| 106 return host; | 104 return host; |
| 107 } | 105 } |
| 108 | 106 |
| 109 // static | 107 // static |
| 110 std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerProviderHost::Create( | 108 std::unique_ptr<ServiceWorkerProviderHost> ServiceWorkerProviderHost::Create( |
| 111 int process_id, | 109 int process_id, |
| 112 ServiceWorkerProviderHostInfo info, | 110 ServiceWorkerProviderHostInfo info, |
| 113 base::WeakPtr<ServiceWorkerContextCore> context, | 111 base::WeakPtr<ServiceWorkerContextCore> context, |
| 114 ServiceWorkerDispatcherHost* dispatcher_host) { | 112 ServiceWorkerDispatcherHost* dispatcher_host) { |
| 115 return base::WrapUnique(new ServiceWorkerProviderHost( | 113 return base::WrapUnique(new ServiceWorkerProviderHost( |
| 116 process_id, std::move(info), context, dispatcher_host)); | 114 process_id, info.route_id, info.provider_id, info.type, |
| 115 info.is_parent_frame_secure, context, dispatcher_host)); |
| 117 } | 116 } |
| 118 | 117 |
| 119 void ServiceWorkerProviderHost::BindWorkerFetchContext( | 118 void ServiceWorkerProviderHost::BindWorkerFetchContext( |
| 120 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info) { | 119 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info) { |
| 121 DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch)); | 120 DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch)); |
| 122 mojom::ServiceWorkerWorkerClientAssociatedPtr client; | 121 mojom::ServiceWorkerWorkerClientAssociatedPtr client; |
| 123 client.Bind(std::move(client_ptr_info)); | 122 client.Bind(std::move(client_ptr_info)); |
| 124 client.set_connection_error_handler( | 123 client.set_connection_error_handler( |
| 125 base::Bind(&ServiceWorkerProviderHost::UnregisterWorkerFetchContext, | 124 base::Bind(&ServiceWorkerProviderHost::UnregisterWorkerFetchContext, |
| 126 base::Unretained(this), client.get())); | 125 base::Unretained(this), client.get())); |
| 127 | 126 |
| 128 if (controlling_version_) | 127 if (controlling_version_) |
| 129 client->SetControllerServiceWorker(controlling_version_->version_id()); | 128 client->SetControllerServiceWorker(controlling_version_->version_id()); |
| 130 | 129 |
| 131 auto result = worker_clients_.insert( | 130 auto result = worker_clients_.insert( |
| 132 std::make_pair<mojom::ServiceWorkerWorkerClient*, | 131 std::make_pair<mojom::ServiceWorkerWorkerClient*, |
| 133 mojom::ServiceWorkerWorkerClientAssociatedPtr>( | 132 mojom::ServiceWorkerWorkerClientAssociatedPtr>( |
| 134 client.get(), std::move(client))); | 133 client.get(), std::move(client))); |
| 135 DCHECK(result.second); | 134 DCHECK(result.second); |
| 136 } | 135 } |
| 137 | 136 |
| 138 void ServiceWorkerProviderHost::UnregisterWorkerFetchContext( | 137 void ServiceWorkerProviderHost::UnregisterWorkerFetchContext( |
| 139 mojom::ServiceWorkerWorkerClient* client) { | 138 mojom::ServiceWorkerWorkerClient* client) { |
| 140 DCHECK(worker_clients_.count(client)); | 139 DCHECK(worker_clients_.count(client)); |
| 141 worker_clients_.erase(client); | 140 worker_clients_.erase(client); |
| 142 } | 141 } |
| 143 | 142 |
| 144 ServiceWorkerProviderHost::ServiceWorkerProviderHost( | 143 ServiceWorkerProviderHost::ServiceWorkerProviderHost( |
| 145 int render_process_id, | 144 int render_process_id, |
| 146 ServiceWorkerProviderHostInfo info, | 145 int route_id, |
| 146 int provider_id, |
| 147 ServiceWorkerProviderType provider_type, |
| 148 bool is_parent_frame_secure, |
| 147 base::WeakPtr<ServiceWorkerContextCore> context, | 149 base::WeakPtr<ServiceWorkerContextCore> context, |
| 148 ServiceWorkerDispatcherHost* dispatcher_host) | 150 ServiceWorkerDispatcherHost* dispatcher_host) |
| 149 : client_uuid_(base::GenerateGUID()), | 151 : client_uuid_(base::GenerateGUID()), |
| 150 render_process_id_(render_process_id), | 152 render_process_id_(render_process_id), |
| 153 route_id_(route_id), |
| 151 render_thread_id_(kDocumentMainThreadId), | 154 render_thread_id_(kDocumentMainThreadId), |
| 152 info_(std::move(info)), | 155 provider_id_(provider_id), |
| 156 provider_type_(provider_type), |
| 157 is_parent_frame_secure_(is_parent_frame_secure), |
| 153 context_(context), | 158 context_(context), |
| 154 dispatcher_host_(dispatcher_host), | 159 dispatcher_host_(dispatcher_host), |
| 155 allow_association_(true) { | 160 allow_association_(true) { |
| 156 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, info_.type); | 161 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); |
| 157 | 162 |
| 158 // PlzNavigate | 163 // PlzNavigate |
| 159 CHECK(render_process_id != ChildProcessHost::kInvalidUniqueID || | 164 CHECK(render_process_id != ChildProcessHost::kInvalidUniqueID || |
| 160 IsBrowserSideNavigationEnabled()); | 165 IsBrowserSideNavigationEnabled()); |
| 161 | 166 |
| 162 if (info_.type == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { | 167 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) { |
| 163 // Actual thread id is set when the service worker context gets started. | 168 // Actual thread id is set when the service worker context gets started. |
| 164 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; | 169 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; |
| 165 } | 170 } |
| 166 context_->RegisterProviderHostByClientID(client_uuid_, this); | 171 context_->RegisterProviderHostByClientID(client_uuid_, this); |
| 167 } | 172 } |
| 168 | 173 |
| 169 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { | 174 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { |
| 170 if (context_) | 175 if (context_) |
| 171 context_->UnregisterProviderHostByClientID(client_uuid_); | 176 context_->UnregisterProviderHostByClientID(client_uuid_); |
| 172 | 177 |
| 173 // Clear docurl so the deferred activation of a waiting worker | 178 // Clear docurl so the deferred activation of a waiting worker |
| 174 // won't associate the new version with a provider being destroyed. | 179 // won't associate the new version with a provider being destroyed. |
| 175 document_url_ = GURL(); | 180 document_url_ = GURL(); |
| 176 if (controlling_version_.get()) | 181 if (controlling_version_.get()) |
| 177 controlling_version_->RemoveControllee(this); | 182 controlling_version_->RemoveControllee(this); |
| 178 | 183 |
| 179 RemoveAllMatchingRegistrations(); | 184 RemoveAllMatchingRegistrations(); |
| 180 | 185 |
| 181 for (const GURL& pattern : associated_patterns_) | 186 for (const GURL& pattern : associated_patterns_) |
| 182 DecreaseProcessReference(pattern); | 187 DecreaseProcessReference(pattern); |
| 183 } | 188 } |
| 184 | 189 |
| 185 int ServiceWorkerProviderHost::frame_id() const { | 190 int ServiceWorkerProviderHost::frame_id() const { |
| 186 if (info_.type == SERVICE_WORKER_PROVIDER_FOR_WINDOW) | 191 if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_WINDOW) |
| 187 return info_.route_id; | 192 return route_id_; |
| 188 return MSG_ROUTING_NONE; | 193 return MSG_ROUTING_NONE; |
| 189 } | 194 } |
| 190 | 195 |
| 191 bool ServiceWorkerProviderHost::IsContextSecureForServiceWorker() const { | 196 bool ServiceWorkerProviderHost::IsContextSecureForServiceWorker() const { |
| 192 // |document_url_| may be empty if loading has not begun, or | 197 // |document_url_| may be empty if loading has not begun, or |
| 193 // ServiceWorkerRequestHandler didn't handle the load (because e.g. another | 198 // ServiceWorkerRequestHandler didn't handle the load (because e.g. another |
| 194 // handler did first, or the initial request URL was such that | 199 // handler did first, or the initial request URL was such that |
| 195 // OriginCanAccessServiceWorkers returned false). | 200 // OriginCanAccessServiceWorkers returned false). |
| 196 if (!document_url_.is_valid()) | 201 if (!document_url_.is_valid()) |
| 197 return false; | 202 return false; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 297 |
| 293 void ServiceWorkerProviderHost::SetHostedVersion( | 298 void ServiceWorkerProviderHost::SetHostedVersion( |
| 294 ServiceWorkerVersion* version) { | 299 ServiceWorkerVersion* version) { |
| 295 DCHECK(!IsProviderForClient()); | 300 DCHECK(!IsProviderForClient()); |
| 296 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, version->running_status()); | 301 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, version->running_status()); |
| 297 DCHECK_EQ(render_process_id_, version->embedded_worker()->process_id()); | 302 DCHECK_EQ(render_process_id_, version->embedded_worker()->process_id()); |
| 298 running_hosted_version_ = version; | 303 running_hosted_version_ = version; |
| 299 } | 304 } |
| 300 | 305 |
| 301 bool ServiceWorkerProviderHost::IsProviderForClient() const { | 306 bool ServiceWorkerProviderHost::IsProviderForClient() const { |
| 302 switch (info_.type) { | 307 switch (provider_type_) { |
| 303 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: | 308 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: |
| 304 case SERVICE_WORKER_PROVIDER_FOR_WORKER: | 309 case SERVICE_WORKER_PROVIDER_FOR_WORKER: |
| 305 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: | 310 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: |
| 306 return true; | 311 return true; |
| 307 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: | 312 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: |
| 308 return false; | 313 return false; |
| 309 case SERVICE_WORKER_PROVIDER_UNKNOWN: | 314 case SERVICE_WORKER_PROVIDER_UNKNOWN: |
| 310 NOTREACHED() << info_.type; | 315 NOTREACHED() << provider_type_; |
| 311 } | 316 } |
| 312 NOTREACHED() << info_.type; | 317 NOTREACHED() << provider_type_; |
| 313 return false; | 318 return false; |
| 314 } | 319 } |
| 315 | 320 |
| 316 blink::WebServiceWorkerClientType ServiceWorkerProviderHost::client_type() | 321 blink::WebServiceWorkerClientType ServiceWorkerProviderHost::client_type() |
| 317 const { | 322 const { |
| 318 switch (info_.type) { | 323 switch (provider_type_) { |
| 319 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: | 324 case SERVICE_WORKER_PROVIDER_FOR_WINDOW: |
| 320 return blink::kWebServiceWorkerClientTypeWindow; | 325 return blink::kWebServiceWorkerClientTypeWindow; |
| 321 case SERVICE_WORKER_PROVIDER_FOR_WORKER: | 326 case SERVICE_WORKER_PROVIDER_FOR_WORKER: |
| 322 return blink::kWebServiceWorkerClientTypeWorker; | 327 return blink::kWebServiceWorkerClientTypeWorker; |
| 323 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: | 328 case SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER: |
| 324 return blink::kWebServiceWorkerClientTypeSharedWorker; | 329 return blink::kWebServiceWorkerClientTypeSharedWorker; |
| 325 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: | 330 case SERVICE_WORKER_PROVIDER_FOR_CONTROLLER: |
| 326 case SERVICE_WORKER_PROVIDER_UNKNOWN: | 331 case SERVICE_WORKER_PROVIDER_UNKNOWN: |
| 327 NOTREACHED() << info_.type; | 332 NOTREACHED() << provider_type_; |
| 328 } | 333 } |
| 329 NOTREACHED() << info_.type; | 334 NOTREACHED() << provider_type_; |
| 330 return blink::kWebServiceWorkerClientTypeWindow; | 335 return blink::kWebServiceWorkerClientTypeWindow; |
| 331 } | 336 } |
| 332 | 337 |
| 333 void ServiceWorkerProviderHost::AssociateRegistration( | 338 void ServiceWorkerProviderHost::AssociateRegistration( |
| 334 ServiceWorkerRegistration* registration, | 339 ServiceWorkerRegistration* registration, |
| 335 bool notify_controllerchange) { | 340 bool notify_controllerchange) { |
| 336 CHECK(IsContextSecureForServiceWorker()); | 341 CHECK(IsContextSecureForServiceWorker()); |
| 337 DCHECK(CanAssociateRegistration(registration)); | 342 DCHECK(CanAssociateRegistration(registration)); |
| 338 associated_registration_ = registration; | 343 associated_registration_ = registration; |
| 339 AddMatchingRegistration(registration); | 344 AddMatchingRegistration(registration); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (get_ready_callback_) | 530 if (get_ready_callback_) |
| 526 return false; | 531 return false; |
| 527 get_ready_callback_.reset(new OneShotGetReadyCallback(callback)); | 532 get_ready_callback_.reset(new OneShotGetReadyCallback(callback)); |
| 528 ReturnRegistrationForReadyIfNeeded(); | 533 ReturnRegistrationForReadyIfNeeded(); |
| 529 return true; | 534 return true; |
| 530 } | 535 } |
| 531 | 536 |
| 532 std::unique_ptr<ServiceWorkerProviderHost> | 537 std::unique_ptr<ServiceWorkerProviderHost> |
| 533 ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() { | 538 ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() { |
| 534 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 539 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
| 535 DCHECK_NE(MSG_ROUTING_NONE, info_.route_id); | 540 DCHECK_NE(MSG_ROUTING_NONE, route_id_); |
| 536 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); | 541 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); |
| 537 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, info_.type); | 542 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); |
| 538 | 543 |
| 539 std::unique_ptr<ServiceWorkerProviderHost> provisional_host = | 544 std::unique_ptr<ServiceWorkerProviderHost> provisional_host = |
| 540 base::WrapUnique(new ServiceWorkerProviderHost( | 545 base::WrapUnique(new ServiceWorkerProviderHost( |
| 541 process_id(), std::move(info_), context_, dispatcher_host())); | 546 process_id(), frame_id(), provider_id(), provider_type(), |
| 547 is_parent_frame_secure(), context_, dispatcher_host())); |
| 542 | 548 |
| 543 for (const GURL& pattern : associated_patterns_) | 549 for (const GURL& pattern : associated_patterns_) |
| 544 DecreaseProcessReference(pattern); | 550 DecreaseProcessReference(pattern); |
| 545 | 551 |
| 546 for (auto& key_registration : matching_registrations_) | 552 for (auto& key_registration : matching_registrations_) |
| 547 DecreaseProcessReference(key_registration.second->pattern()); | 553 DecreaseProcessReference(key_registration.second->pattern()); |
| 548 | 554 |
| 549 if (associated_registration_.get()) { | 555 if (associated_registration_.get()) { |
| 550 if (dispatcher_host_) { | 556 if (dispatcher_host_) { |
| 551 Send(new ServiceWorkerMsg_DisassociateRegistration( | 557 Send(new ServiceWorkerMsg_DisassociateRegistration( |
| 552 render_thread_id_, provider_id())); | 558 render_thread_id_, provider_id())); |
| 553 } | 559 } |
| 554 } | 560 } |
| 555 | 561 |
| 556 render_process_id_ = ChildProcessHost::kInvalidUniqueID; | 562 render_process_id_ = ChildProcessHost::kInvalidUniqueID; |
| 563 route_id_ = MSG_ROUTING_NONE; |
| 557 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; | 564 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; |
| 565 provider_id_ = kInvalidServiceWorkerProviderId; |
| 566 provider_type_ = SERVICE_WORKER_PROVIDER_UNKNOWN; |
| 558 dispatcher_host_ = nullptr; | 567 dispatcher_host_ = nullptr; |
| 559 return provisional_host; | 568 return provisional_host; |
| 560 } | 569 } |
| 561 | 570 |
| 562 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( | 571 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( |
| 563 ServiceWorkerProviderHost* provisional_host) { | 572 ServiceWorkerProviderHost* provisional_host) { |
| 564 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 573 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
| 565 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, provisional_host->process_id()); | 574 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, provisional_host->process_id()); |
| 566 DCHECK_NE(MSG_ROUTING_NONE, provisional_host->frame_id()); | 575 DCHECK_NE(MSG_ROUTING_NONE, provisional_host->frame_id()); |
| 567 | 576 |
| 568 render_thread_id_ = kDocumentMainThreadId; | 577 render_thread_id_ = kDocumentMainThreadId; |
| 569 info_.provider_id = provisional_host->provider_id(); | 578 provider_id_ = provisional_host->provider_id(); |
| 570 info_.type = provisional_host->provider_type(); | 579 provider_type_ = provisional_host->provider_type(); |
| 571 | 580 |
| 572 FinalizeInitialization(provisional_host->process_id(), | 581 FinalizeInitialization(provisional_host->process_id(), |
| 573 provisional_host->frame_id(), | 582 provisional_host->frame_id(), |
| 574 provisional_host->dispatcher_host()); | 583 provisional_host->dispatcher_host()); |
| 575 } | 584 } |
| 576 | 585 |
| 577 // PlzNavigate | 586 // PlzNavigate |
| 578 void ServiceWorkerProviderHost::CompleteNavigationInitialized( | 587 void ServiceWorkerProviderHost::CompleteNavigationInitialized( |
| 579 int process_id, | 588 int process_id, |
| 580 int frame_routing_id, | 589 int frame_routing_id, |
| 581 ServiceWorkerDispatcherHost* dispatcher_host) { | 590 ServiceWorkerDispatcherHost* dispatcher_host) { |
| 582 CHECK(IsBrowserSideNavigationEnabled()); | 591 CHECK(IsBrowserSideNavigationEnabled()); |
| 583 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); | 592 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
| 584 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, info_.type); | 593 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type_); |
| 585 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); | 594 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); |
| 586 | 595 |
| 587 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, process_id); | 596 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, process_id); |
| 588 DCHECK_NE(MSG_ROUTING_NONE, frame_routing_id); | 597 DCHECK_NE(MSG_ROUTING_NONE, frame_routing_id); |
| 589 | 598 |
| 590 FinalizeInitialization(process_id, frame_routing_id, dispatcher_host); | 599 FinalizeInitialization(process_id, frame_routing_id, dispatcher_host); |
| 591 } | 600 } |
| 592 | 601 |
| 593 void ServiceWorkerProviderHost::SendUpdateFoundMessage( | 602 void ServiceWorkerProviderHost::SendUpdateFoundMessage( |
| 594 int registration_handle_id) { | 603 int registration_handle_id) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 DCHECK(dispatcher_host_); | 761 DCHECK(dispatcher_host_); |
| 753 DCHECK(IsReadyToSendMessages()); | 762 DCHECK(IsReadyToSendMessages()); |
| 754 dispatcher_host_->Send(message); | 763 dispatcher_host_->Send(message); |
| 755 } | 764 } |
| 756 | 765 |
| 757 void ServiceWorkerProviderHost::FinalizeInitialization( | 766 void ServiceWorkerProviderHost::FinalizeInitialization( |
| 758 int process_id, | 767 int process_id, |
| 759 int frame_routing_id, | 768 int frame_routing_id, |
| 760 ServiceWorkerDispatcherHost* dispatcher_host) { | 769 ServiceWorkerDispatcherHost* dispatcher_host) { |
| 761 render_process_id_ = process_id; | 770 render_process_id_ = process_id; |
| 762 info_.route_id = frame_routing_id; | 771 route_id_ = frame_routing_id; |
| 763 dispatcher_host_ = dispatcher_host; | 772 dispatcher_host_ = dispatcher_host; |
| 764 | 773 |
| 765 for (const GURL& pattern : associated_patterns_) | 774 for (const GURL& pattern : associated_patterns_) |
| 766 IncreaseProcessReference(pattern); | 775 IncreaseProcessReference(pattern); |
| 767 | 776 |
| 768 for (auto& key_registration : matching_registrations_) | 777 for (auto& key_registration : matching_registrations_) |
| 769 IncreaseProcessReference(key_registration.second->pattern()); | 778 IncreaseProcessReference(key_registration.second->pattern()); |
| 770 | 779 |
| 771 if (associated_registration_.get()) { | 780 if (associated_registration_.get()) { |
| 772 SendAssociateRegistrationMessage(); | 781 SendAssociateRegistrationMessage(); |
| 773 if (dispatcher_host_ && associated_registration_->active_version()) { | 782 if (dispatcher_host_ && associated_registration_->active_version()) { |
| 774 Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 783 Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
| 775 render_thread_id_, provider_id(), | 784 render_thread_id_, provider_id(), |
| 776 GetOrCreateServiceWorkerHandle( | 785 GetOrCreateServiceWorkerHandle( |
| 777 associated_registration_->active_version()), | 786 associated_registration_->active_version()), |
| 778 false /* shouldNotifyControllerChange */, | 787 false /* shouldNotifyControllerChange */, |
| 779 associated_registration_->active_version()->used_features())); | 788 associated_registration_->active_version()->used_features())); |
| 780 } | 789 } |
| 781 } | 790 } |
| 782 } | 791 } |
| 783 | 792 |
| 784 } // namespace content | 793 } // namespace content |
| OLD | NEW |