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

Side by Side Diff: content/browser/appcache/appcache_interceptor.cc

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: incorporated yhirano & kinuko's comment Created 4 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/appcache/appcache_interceptor.h" 5 #include "content/browser/appcache/appcache_interceptor.h"
6 6
7 #include "base/debug/crash_logging.h" 7 #include "base/debug/crash_logging.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_host.h" 9 #include "content/browser/appcache/appcache_host.h"
10 #include "content/browser/appcache/appcache_request_handler.h" 10 #include "content/browser/appcache/appcache_request_handler.h"
11 #include "content/browser/appcache/appcache_service_impl.h" 11 #include "content/browser/appcache/appcache_service_impl.h"
12 #include "content/browser/appcache/appcache_url_request_job.h" 12 #include "content/browser/appcache/appcache_url_request_job.h"
13 #include "content/browser/appcache/chrome_appcache_service.h" 13 #include "content/browser/appcache/chrome_appcache_service.h"
14 #include "content/browser/bad_message.h" 14 #include "content/browser/bad_message.h"
15 #include "content/browser/loader/resource_message_filter.h" 15 #include "content/browser/loader/resource_requester_info.h"
16 #include "content/common/appcache_interfaces.h" 16 #include "content/common/appcache_interfaces.h"
17 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
18 18
19 static int kHandlerKey; // Value is not used. 19 static int kHandlerKey; // Value is not used.
20 20
21 namespace content { 21 namespace content {
22 22
23 void AppCacheInterceptor::SetHandler(net::URLRequest* request, 23 void AppCacheInterceptor::SetHandler(net::URLRequest* request,
24 AppCacheRequestHandler* handler) { 24 AppCacheRequestHandler* handler) {
25 request->SetUserData(&kHandlerKey, handler); // request takes ownership 25 request->SetUserData(&kHandlerKey, handler); // request takes ownership
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 AppCacheRequestHandler* handler = GetHandler(request); 74 AppCacheRequestHandler* handler = GetHandler(request);
75 if (!handler) 75 if (!handler)
76 return; 76 return;
77 handler->PrepareForCrossSiteTransfer(old_process_id); 77 handler->PrepareForCrossSiteTransfer(old_process_id);
78 } 78 }
79 79
80 void AppCacheInterceptor::CompleteCrossSiteTransfer( 80 void AppCacheInterceptor::CompleteCrossSiteTransfer(
81 net::URLRequest* request, 81 net::URLRequest* request,
82 int new_process_id, 82 int new_process_id,
83 int new_host_id, 83 int new_host_id,
84 ResourceMessageFilter* filter) { 84 ResourceRequesterInfo* requester_info) {
85 // AppCache is supported only for renderer initiated requests.
86 DCHECK(requester_info->IsRenderer());
85 AppCacheRequestHandler* handler = GetHandler(request); 87 AppCacheRequestHandler* handler = GetHandler(request);
86 if (!handler) 88 if (!handler)
87 return; 89 return;
88 if (!handler->SanityCheckIsSameService(filter->appcache_service())) { 90 if (!handler->SanityCheckIsSameService(requester_info->appcache_service())) {
89 // This can happen when V2 apps and web pages end up in the same storage 91 // This can happen when V2 apps and web pages end up in the same storage
90 // partition. 92 // partition.
91 const GURL& first_party_url_for_cookies = 93 const GURL& first_party_url_for_cookies =
92 request->first_party_for_cookies(); 94 request->first_party_for_cookies();
93 if (first_party_url_for_cookies.is_valid()) { 95 if (first_party_url_for_cookies.is_valid()) {
94 // TODO(lazyboy): Remove this once we know which extensions run into this 96 // TODO(lazyboy): Remove this once we know which extensions run into this
95 // issue. See https://crbug.com/612711#c25 for details. 97 // issue. See https://crbug.com/612711#c25 for details.
96 base::debug::SetCrashKeyValue("aci_wrong_sp_extension_id", 98 base::debug::SetCrashKeyValue("aci_wrong_sp_extension_id",
97 first_party_url_for_cookies.host()); 99 first_party_url_for_cookies.host());
98 // No need to explicitly call DumpWithoutCrashing(), since 100 // No need to explicitly call DumpWithoutCrashing(), since
99 // bad_message::ReceivedBadMessage() below will do that. 101 // bad_message::ReceivedBadMessage() below will do that.
100 } 102 }
101 bad_message::ReceivedBadMessage(filter, 103 bad_message::ReceivedBadMessage(requester_info->filter(),
102 bad_message::ACI_WRONG_STORAGE_PARTITION); 104 bad_message::ACI_WRONG_STORAGE_PARTITION);
103 return; 105 return;
104 } 106 }
105 DCHECK_NE(kAppCacheNoHostId, new_host_id); 107 DCHECK_NE(kAppCacheNoHostId, new_host_id);
106 handler->CompleteCrossSiteTransfer(new_process_id, 108 handler->CompleteCrossSiteTransfer(new_process_id,
107 new_host_id); 109 new_host_id);
108 } 110 }
109 111
110 void AppCacheInterceptor::MaybeCompleteCrossSiteTransferInOldProcess( 112 void AppCacheInterceptor::MaybeCompleteCrossSiteTransferInOldProcess(
111 net::URLRequest* request, 113 net::URLRequest* request,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 145
144 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( 146 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse(
145 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { 147 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
146 AppCacheRequestHandler* handler = GetHandler(request); 148 AppCacheRequestHandler* handler = GetHandler(request);
147 if (!handler) 149 if (!handler)
148 return NULL; 150 return NULL;
149 return handler->MaybeLoadFallbackForResponse(request, network_delegate); 151 return handler->MaybeLoadFallbackForResponse(request, network_delegate);
150 } 152 }
151 153
152 } // namespace content 154 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698