Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 2888043006: ServiceWorker: Refactor CrossSiteTransfer on ServiceWorkerProviderHost (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 return true; 534 return true;
535 } 535 }
536 536
537 std::unique_ptr<ServiceWorkerProviderHost> 537 std::unique_ptr<ServiceWorkerProviderHost>
538 ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() { 538 ServiceWorkerProviderHost::PrepareForCrossSiteTransfer() {
539 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_); 539 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_);
540 DCHECK_NE(MSG_ROUTING_NONE, route_id_); 540 DCHECK_NE(MSG_ROUTING_NONE, route_id_);
541 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_); 541 DCHECK_EQ(kDocumentMainThreadId, render_thread_id_);
542 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_); 542 DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_);
543 543
544 std::unique_ptr<ServiceWorkerProviderHost> new_provider_host = 544 std::unique_ptr<ServiceWorkerProviderHost> provisional_host =
545 base::WrapUnique(new ServiceWorkerProviderHost( 545 base::WrapUnique(new ServiceWorkerProviderHost(
546 process_id(), frame_id(), provider_id(), provider_type(), 546 process_id(), frame_id(), provider_id(), provider_type(),
547 is_parent_frame_secure(), context_, dispatcher_host())); 547 is_parent_frame_secure(), context_, dispatcher_host()));
548 548
549 for (const GURL& pattern : associated_patterns_) 549 for (const GURL& pattern : associated_patterns_)
550 DecreaseProcessReference(pattern); 550 DecreaseProcessReference(pattern);
551 551
552 for (auto& key_registration : matching_registrations_) 552 for (auto& key_registration : matching_registrations_)
553 DecreaseProcessReference(key_registration.second->pattern()); 553 DecreaseProcessReference(key_registration.second->pattern());
554 554
555 if (associated_registration_.get()) { 555 if (associated_registration_.get()) {
556 if (dispatcher_host_) { 556 if (dispatcher_host_) {
557 Send(new ServiceWorkerMsg_DisassociateRegistration( 557 Send(new ServiceWorkerMsg_DisassociateRegistration(
558 render_thread_id_, provider_id())); 558 render_thread_id_, provider_id()));
559 } 559 }
560 } 560 }
561 561
562 render_process_id_ = ChildProcessHost::kInvalidUniqueID; 562 render_process_id_ = ChildProcessHost::kInvalidUniqueID;
563 route_id_ = MSG_ROUTING_NONE; 563 route_id_ = MSG_ROUTING_NONE;
564 render_thread_id_ = kInvalidEmbeddedWorkerThreadId; 564 render_thread_id_ = kInvalidEmbeddedWorkerThreadId;
565 provider_id_ = kInvalidServiceWorkerProviderId; 565 provider_id_ = kInvalidServiceWorkerProviderId;
566 provider_type_ = SERVICE_WORKER_PROVIDER_UNKNOWN; 566 provider_type_ = SERVICE_WORKER_PROVIDER_UNKNOWN;
567 dispatcher_host_ = nullptr; 567 dispatcher_host_ = nullptr;
568 return new_provider_host; 568 return provisional_host;
569 } 569 }
570 570
571 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( 571 void ServiceWorkerProviderHost::CompleteCrossSiteTransfer(
572 int new_process_id, 572 ServiceWorkerProviderHost* provisional_host) {
573 int new_frame_id,
574 int new_provider_id,
575 ServiceWorkerProviderType new_provider_type,
576 ServiceWorkerDispatcherHost* new_dispatcher_host) {
577 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); 573 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_);
578 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, new_process_id); 574 DCHECK_NE(ChildProcessHost::kInvalidUniqueID, provisional_host->process_id());
579 DCHECK_NE(MSG_ROUTING_NONE, new_frame_id); 575 DCHECK_NE(MSG_ROUTING_NONE, provisional_host->frame_id());
580 576
581 render_thread_id_ = kDocumentMainThreadId; 577 render_thread_id_ = kDocumentMainThreadId;
582 provider_id_ = new_provider_id; 578 provider_id_ = provisional_host->provider_id();
583 provider_type_ = new_provider_type; 579 provider_type_ = provisional_host->provider_type();
584 580
585 FinalizeInitialization(new_process_id, new_frame_id, new_dispatcher_host); 581 FinalizeInitialization(provisional_host->process_id(),
582 provisional_host->frame_id(),
583 provisional_host->dispatcher_host());
586 } 584 }
587 585
588 // PlzNavigate 586 // PlzNavigate
589 void ServiceWorkerProviderHost::CompleteNavigationInitialized( 587 void ServiceWorkerProviderHost::CompleteNavigationInitialized(
590 int process_id, 588 int process_id,
591 int frame_routing_id, 589 int frame_routing_id,
592 ServiceWorkerDispatcherHost* dispatcher_host) { 590 ServiceWorkerDispatcherHost* dispatcher_host) {
593 CHECK(IsBrowserSideNavigationEnabled()); 591 CHECK(IsBrowserSideNavigationEnabled());
594 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); 592 DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_);
595 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type_); 593 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type_);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 render_thread_id_, provider_id(), 784 render_thread_id_, provider_id(),
787 GetOrCreateServiceWorkerHandle( 785 GetOrCreateServiceWorkerHandle(
788 associated_registration_->active_version()), 786 associated_registration_->active_version()),
789 false /* shouldNotifyControllerChange */, 787 false /* shouldNotifyControllerChange */,
790 associated_registration_->active_version()->used_features())); 788 associated_registration_->active_version()->used_features()));
791 } 789 }
792 } 790 }
793 } 791 }
794 792
795 } // namespace content 793 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698