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

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

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Fix content_browsertests rednesss 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"
(...skipping 14 matching lines...) Expand all
25 AppCacheRequestHandler* handler) { 25 AppCacheRequestHandler* handler) {
26 request->SetUserData(&kHandlerKey, handler); // request takes ownership 26 request->SetUserData(&kHandlerKey, handler); // request takes ownership
27 } 27 }
28 28
29 AppCacheRequestHandler* AppCacheInterceptor::GetHandler( 29 AppCacheRequestHandler* AppCacheInterceptor::GetHandler(
30 net::URLRequest* request) { 30 net::URLRequest* request) {
31 return static_cast<AppCacheRequestHandler*>( 31 return static_cast<AppCacheRequestHandler*>(
32 request->GetUserData(&kHandlerKey)); 32 request->GetUserData(&kHandlerKey));
33 } 33 }
34 34
35 void AppCacheInterceptor::SetExtraRequestInfo( 35 void AppCacheInterceptor::SetExtraRequestInfo(net::URLRequest* request,
36 net::URLRequest* request, 36 AppCacheServiceImpl* service,
37 AppCacheServiceImpl* service, 37 int process_id,
38 int process_id, 38 int host_id,
39 int host_id, 39 ResourceType resource_type,
40 ResourceType resource_type, 40 bool should_reset_appcache) {
41 bool should_reset_appcache) {
42 if (!service || (host_id == kAppCacheNoHostId)) 41 if (!service || (host_id == kAppCacheNoHostId))
43 return; 42 return;
44 43
45 AppCacheBackendImpl* backend = service->GetBackend(process_id); 44 AppCacheBackendImpl* backend = service->GetBackend(process_id);
46 if (!backend) 45 if (!backend)
47 return; 46 return;
48 47
49 // TODO(michaeln): An invalid host id is indicative of bad data 48 // TODO(michaeln): An invalid host id is indicative of bad data
50 // from a child process. How should we handle that here? 49 // from a child process. How should we handle that here?
51 AppCacheHost* host = backend->GetHost(host_id); 50 AppCacheHost* host = backend->GetHost(host_id);
52 if (!host) 51 if (!host)
53 return; 52 return;
54 53
54 SetExtraRequestInfoForHost(request, host, resource_type,
55 should_reset_appcache);
56 }
57
58 void AppCacheInterceptor::SetExtraRequestInfoForHost(
59 net::URLRequest* request,
60 AppCacheHost* host,
61 ResourceType resource_type,
62 bool should_reset_appcache) {
55 // Create a handler for this request and associate it with the request. 63 // Create a handler for this request and associate it with the request.
56 AppCacheRequestHandler* handler = 64 AppCacheRequestHandler* handler =
57 host->CreateRequestHandler(request, resource_type, should_reset_appcache); 65 host->CreateRequestHandler(request, resource_type, should_reset_appcache);
58 if (handler) 66 if (handler)
59 SetHandler(request, handler); 67 SetHandler(request, handler);
60 } 68 }
61 69
62 void AppCacheInterceptor::GetExtraResponseInfo(net::URLRequest* request, 70 void AppCacheInterceptor::GetExtraResponseInfo(net::URLRequest* request,
63 int64_t* cache_id, 71 int64_t* cache_id,
64 GURL* manifest_url) { 72 GURL* manifest_url) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 154
147 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( 155 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse(
148 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { 156 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
149 AppCacheRequestHandler* handler = GetHandler(request); 157 AppCacheRequestHandler* handler = GetHandler(request);
150 if (!handler) 158 if (!handler)
151 return NULL; 159 return NULL;
152 return handler->MaybeLoadFallbackForResponse(request, network_delegate); 160 return handler->MaybeLoadFallbackForResponse(request, network_delegate);
153 } 161 }
154 162
155 } // namespace content 163 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698