OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 AppCacheRequestHandler* handler) { | 24 AppCacheRequestHandler* handler) { |
25 request->SetUserData(&kHandlerKey, handler); // request takes ownership | 25 request->SetUserData(&kHandlerKey, handler); // request takes ownership |
26 } | 26 } |
27 | 27 |
28 AppCacheRequestHandler* AppCacheInterceptor::GetHandler( | 28 AppCacheRequestHandler* AppCacheInterceptor::GetHandler( |
29 net::URLRequest* request) { | 29 net::URLRequest* request) { |
30 return static_cast<AppCacheRequestHandler*>( | 30 return static_cast<AppCacheRequestHandler*>( |
31 request->GetUserData(&kHandlerKey)); | 31 request->GetUserData(&kHandlerKey)); |
32 } | 32 } |
33 | 33 |
34 void AppCacheInterceptor::SetExtraRequestInfo( | 34 void AppCacheInterceptor::SetExtraRequestInfo(net::URLRequest* request, |
35 net::URLRequest* request, | 35 AppCacheServiceImpl* service, |
36 AppCacheServiceImpl* service, | 36 int process_id, |
37 int process_id, | 37 int frame_id, |
38 int host_id, | 38 int host_id, |
39 ResourceType resource_type, | 39 ResourceType resource_type, |
40 bool should_reset_appcache) { | 40 bool should_reset_appcache) { |
41 if (!service || (host_id == kAppCacheNoHostId)) | 41 if (!service || (host_id == kAppCacheNoHostId)) |
42 return; | 42 return; |
43 | 43 |
44 AppCacheBackendImpl* backend = service->GetBackend(process_id); | 44 AppCacheBackendImpl* backend = service->GetBackend(process_id); |
45 if (!backend) | 45 if (!backend) { |
46 return; | 46 backend = service->GetBackendForFrame(frame_id); |
| 47 if (!backend) |
| 48 return; |
| 49 } |
47 | 50 |
48 // TODO(michaeln): An invalid host id is indicative of bad data | 51 // TODO(michaeln): An invalid host id is indicative of bad data |
49 // from a child process. How should we handle that here? | 52 // from a child process. How should we handle that here? |
50 AppCacheHost* host = backend->GetHost(host_id); | 53 AppCacheHost* host = backend->GetHost(host_id); |
51 if (!host) | 54 if (!host) |
52 return; | 55 return; |
53 | 56 |
54 // Create a handler for this request and associate it with the request. | 57 // Create a handler for this request and associate it with the request. |
55 AppCacheRequestHandler* handler = | 58 AppCacheRequestHandler* handler = |
56 host->CreateRequestHandler(request, resource_type, should_reset_appcache); | 59 host->CreateRequestHandler(request, resource_type, should_reset_appcache); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |