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

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

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

Powered by Google App Engine
This is Rietveld 408576698