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