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

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

Issue 702843004: Transfer serviceworker state during cross site navigations too. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_request_handler.h" 5 #include "content/browser/service_worker/service_worker_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 bool ServiceWorkerRequestHandler::IsControlledByServiceWorker( 123 bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
124 net::URLRequest* request) { 124 net::URLRequest* request) {
125 ServiceWorkerRequestHandler* handler = GetHandler(request); 125 ServiceWorkerRequestHandler* handler = GetHandler(request);
126 if (!handler || !handler->provider_host_) 126 if (!handler || !handler->provider_host_)
127 return false; 127 return false;
128 return handler->provider_host_->associated_registration() || 128 return handler->provider_host_->associated_registration() ||
129 handler->provider_host_->running_hosted_version(); 129 handler->provider_host_->running_hosted_version();
130 } 130 }
131 131
132 void ServiceWorkerRequestHandler::PrepareForCrossSiteTransfer(
133 int old_process_id) {
134 if (!provider_host_ || !context_)
135 return;
136 host_for_cross_site_transfer_ =
137 context_->TransferProviderHostOut(old_process_id,
138 provider_host_->provider_id());
139 DCHECK_EQ(provider_host_.get(), host_for_cross_site_transfer_.get());
140 }
141
142 void ServiceWorkerRequestHandler::CompleteCrossSiteTransfer(
143 int new_process_id, int new_host_id) {
144 if (!host_for_cross_site_transfer_.get() || !context_)
145 return;
146 DCHECK_EQ(provider_host_.get(), host_for_cross_site_transfer_.get());
147 context_->TransferProviderHostIn(
148 new_process_id,
149 new_host_id,
150 host_for_cross_site_transfer_.Pass());
151 DCHECK_EQ(provider_host_->provider_id(), new_host_id);
152 }
153
132 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() { 154 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() {
133 } 155 }
134 156
135 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( 157 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler(
136 base::WeakPtr<ServiceWorkerContextCore> context, 158 base::WeakPtr<ServiceWorkerContextCore> context,
137 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 159 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
138 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 160 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
139 ResourceType resource_type) 161 ResourceType resource_type)
140 : context_(context), 162 : context_(context),
141 provider_host_(provider_host), 163 provider_host_(provider_host),
142 blob_storage_context_(blob_storage_context), 164 blob_storage_context_(blob_storage_context),
143 resource_type_(resource_type) { 165 resource_type_(resource_type) {
144 } 166 }
145 167
146 } // namespace content 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698