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

Side by Side Diff: content/browser/appcache/appcache_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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/appcache/appcache_request_handler.h" 5 #include "content/browser/appcache/appcache_request_handler.h"
6 6
7 #include "content/browser/appcache/appcache.h" 7 #include "content/browser/appcache/appcache.h"
8 #include "content/browser/appcache/appcache_backend_impl.h" 8 #include "content/browser/appcache/appcache_backend_impl.h"
9 #include "content/browser/appcache/appcache_policy.h" 9 #include "content/browser/appcache/appcache_policy.h"
10 #include "content/browser/appcache/appcache_url_request_job.h" 10 #include "content/browser/appcache/appcache_url_request_job.h"
11 #include "content/browser/service_worker/service_worker_request_handler.h" 11 #include "content/browser/service_worker/service_worker_request_handler.h"
12 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
13 #include "net/url_request/url_request_job.h" 13 #include "net/url_request/url_request_job.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, 17 AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host,
18 ResourceType resource_type, 18 ResourceType resource_type,
19 bool should_reset_appcache) 19 bool should_reset_appcache)
20 : host_(host), 20 : host_(host),
21 resource_type_(resource_type), 21 resource_type_(resource_type),
22 should_reset_appcache_(should_reset_appcache), 22 should_reset_appcache_(should_reset_appcache),
23 is_waiting_for_cache_selection_(false), 23 is_waiting_for_cache_selection_(false),
24 found_group_id_(0), 24 found_group_id_(0),
25 found_cache_id_(0), 25 found_cache_id_(0),
26 found_network_namespace_(false), 26 found_network_namespace_(false),
27 cache_entry_not_found_(false), 27 cache_entry_not_found_(false),
28 maybe_load_resource_executed_(false) { 28 maybe_load_resource_executed_(false),
29 old_process_id_(0),
30 old_host_id_(kAppCacheNoHostId) {
29 DCHECK(host_); 31 DCHECK(host_);
30 host_->AddObserver(this); 32 host_->AddObserver(this);
31 } 33 }
32 34
33 AppCacheRequestHandler::~AppCacheRequestHandler() { 35 AppCacheRequestHandler::~AppCacheRequestHandler() {
34 if (host_) { 36 if (host_) {
35 storage()->CancelDelegateCallbacks(this); 37 storage()->CancelDelegateCallbacks(this);
36 host_->RemoveObserver(this); 38 host_->RemoveObserver(this);
37 } 39 }
38 } 40 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (job_.get() && job_->is_delivering_appcache_response()) { 180 if (job_.get() && job_->is_delivering_appcache_response()) {
179 *cache_id = job_->cache_id(); 181 *cache_id = job_->cache_id();
180 *manifest_url = job_->manifest_url(); 182 *manifest_url = job_->manifest_url();
181 } 183 }
182 } 184 }
183 185
184 void AppCacheRequestHandler::PrepareForCrossSiteTransfer(int old_process_id) { 186 void AppCacheRequestHandler::PrepareForCrossSiteTransfer(int old_process_id) {
185 if (!host_) 187 if (!host_)
186 return; 188 return;
187 AppCacheBackendImpl* backend = host_->service()->GetBackend(old_process_id); 189 AppCacheBackendImpl* backend = host_->service()->GetBackend(old_process_id);
190 old_process_id_ = old_process_id;
191 old_host_id_ = host_->host_id();
188 host_for_cross_site_transfer_ = backend->TransferHostOut(host_->host_id()); 192 host_for_cross_site_transfer_ = backend->TransferHostOut(host_->host_id());
189 DCHECK_EQ(host_, host_for_cross_site_transfer_.get()); 193 DCHECK_EQ(host_, host_for_cross_site_transfer_.get());
190 } 194 }
191 195
192 void AppCacheRequestHandler::CompleteCrossSiteTransfer( 196 void AppCacheRequestHandler::CompleteCrossSiteTransfer(
193 int new_process_id, int new_host_id) { 197 int new_process_id, int new_host_id) {
194 if (!host_for_cross_site_transfer_.get()) 198 if (!host_for_cross_site_transfer_.get())
195 return; 199 return;
196 DCHECK_EQ(host_, host_for_cross_site_transfer_.get()); 200 DCHECK_EQ(host_, host_for_cross_site_transfer_.get());
197 AppCacheBackendImpl* backend = host_->service()->GetBackend(new_process_id); 201 AppCacheBackendImpl* backend = host_->service()->GetBackend(new_process_id);
198 backend->TransferHostIn(new_host_id, host_for_cross_site_transfer_.Pass()); 202 backend->TransferHostIn(new_host_id, host_for_cross_site_transfer_.Pass());
199 } 203 }
200 204
205 void AppCacheRequestHandler::MaybeCompleteCrossSiteTransferInOldProcess(
206 int old_process_id) {
207 if (!host_ || !host_for_cross_site_transfer_.get() ||
208 old_process_id != old_process_id_) {
209 return;
210 }
211 CompleteCrossSiteTransfer(old_process_id_, old_host_id_);
212 }
213
201 void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) { 214 void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) {
202 storage()->CancelDelegateCallbacks(this); 215 storage()->CancelDelegateCallbacks(this);
203 host_ = NULL; // no need to RemoveObserver, the host is being deleted 216 host_ = NULL; // no need to RemoveObserver, the host is being deleted
204 217
205 // Since the host is being deleted, we don't have to complete any job 218 // Since the host is being deleted, we don't have to complete any job
206 // that is current running. It's destined for the bit bucket anyway. 219 // that is current running. It's destined for the bit bucket anyway.
207 if (job_.get()) { 220 if (job_.get()) {
208 job_->Kill(); 221 job_->Kill();
209 job_ = NULL; 222 job_ = NULL;
210 } 223 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 if (!host_->associated_cache() || 430 if (!host_->associated_cache() ||
418 !host_->associated_cache()->is_complete()) { 431 !host_->associated_cache()->is_complete()) {
419 DeliverNetworkResponse(); 432 DeliverNetworkResponse();
420 return; 433 return;
421 } 434 }
422 435
423 ContinueMaybeLoadSubResource(); 436 ContinueMaybeLoadSubResource();
424 } 437 }
425 438
426 } // namespace content 439 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698