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

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 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 bool ServiceWorkerRequestHandler::IsControlledByServiceWorker( 114 bool ServiceWorkerRequestHandler::IsControlledByServiceWorker(
115 net::URLRequest* request) { 115 net::URLRequest* request) {
116 ServiceWorkerRequestHandler* handler = GetHandler(request); 116 ServiceWorkerRequestHandler* handler = GetHandler(request);
117 if (!handler || !handler->provider_host_) 117 if (!handler || !handler->provider_host_)
118 return false; 118 return false;
119 return handler->provider_host_->associated_registration() || 119 return handler->provider_host_->associated_registration() ||
120 handler->provider_host_->running_hosted_version(); 120 handler->provider_host_->running_hosted_version();
121 } 121 }
122 122
123 void ServiceWorkerRequestHandler::PrepareForCrossSiteTransfer(
124 int old_process_id) {
125 if (!provider_host_ || !context_)
126 return;
127 old_process_id_ = old_process_id;
128 old_provider_id_ = provider_host_->provider_id();
129 host_for_cross_site_transfer_ =
130 context_->TransferProviderHostOut(old_process_id,
131 provider_host_->provider_id());
132 DCHECK_EQ(provider_host_.get(), host_for_cross_site_transfer_.get());
133 }
134
135 void ServiceWorkerRequestHandler::CompleteCrossSiteTransfer(
136 int new_process_id, int new_provider_id) {
137 if (!host_for_cross_site_transfer_.get() || !context_)
138 return;
139 DCHECK_EQ(provider_host_.get(), host_for_cross_site_transfer_.get());
140 context_->TransferProviderHostIn(
141 new_process_id,
142 new_provider_id,
143 host_for_cross_site_transfer_.Pass());
144 DCHECK_EQ(provider_host_->provider_id(), new_provider_id);
145 }
146
147 void ServiceWorkerRequestHandler::MaybeCompleteCrossSiteTransferInOldProcess(
148 int old_process_id) {
149 if (!host_for_cross_site_transfer_.get() || !context_ ||
150 old_process_id_ != old_process_id) {
151 return;
152 }
153 CompleteCrossSiteTransfer(old_process_id_, old_provider_id_);
154 }
155
123 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() { 156 ServiceWorkerRequestHandler::~ServiceWorkerRequestHandler() {
124 } 157 }
125 158
126 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler( 159 ServiceWorkerRequestHandler::ServiceWorkerRequestHandler(
127 base::WeakPtr<ServiceWorkerContextCore> context, 160 base::WeakPtr<ServiceWorkerContextCore> context,
128 base::WeakPtr<ServiceWorkerProviderHost> provider_host, 161 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
129 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, 162 base::WeakPtr<storage::BlobStorageContext> blob_storage_context,
130 ResourceType resource_type) 163 ResourceType resource_type)
131 : context_(context), 164 : context_(context),
132 provider_host_(provider_host), 165 provider_host_(provider_host),
133 blob_storage_context_(blob_storage_context), 166 blob_storage_context_(blob_storage_context),
134 resource_type_(resource_type) { 167 resource_type_(resource_type),
168 old_process_id_(0),
169 old_provider_id_(kInvalidServiceWorkerProviderId) {
135 } 170 }
136 171
137 } // namespace content 172 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698