| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "webkit/appcache/appcache_interceptor.h" | 5 #include "webkit/appcache/appcache_interceptor.h" |
| 6 | 6 |
| 7 #include "webkit/appcache/appcache_backend_impl.h" | 7 #include "webkit/appcache/appcache_backend_impl.h" |
| 8 #include "webkit/appcache/appcache_host.h" | 8 #include "webkit/appcache/appcache_host.h" |
| 9 #include "webkit/appcache/appcache_interfaces.h" | 9 #include "webkit/appcache/appcache_interfaces.h" |
| 10 #include "webkit/appcache/appcache_request_handler.h" | 10 #include "webkit/appcache/appcache_request_handler.h" |
| 11 #include "webkit/appcache/appcache_service.h" | 11 #include "webkit/appcache/appcache_service.h" |
| 12 #include "webkit/appcache/appcache_url_request_job.h" | 12 #include "webkit/appcache/appcache_url_request_job.h" |
| 13 | 13 |
| 14 namespace appcache { | 14 namespace appcache { |
| 15 | 15 |
| 16 // static |
| 17 AppCacheInterceptor* AppCacheInterceptor::GetInstance() { |
| 18 return Singleton<AppCacheInterceptor>::get(); |
| 19 } |
| 20 |
| 16 void AppCacheInterceptor::SetHandler( | 21 void AppCacheInterceptor::SetHandler( |
| 17 net::URLRequest* request, AppCacheRequestHandler* handler) { | 22 net::URLRequest* request, AppCacheRequestHandler* handler) { |
| 18 request->SetUserData(instance(), handler); // request takes ownership | 23 request->SetUserData(GetInstance(), handler); // request takes ownership |
| 19 } | 24 } |
| 20 | 25 |
| 21 AppCacheRequestHandler* AppCacheInterceptor::GetHandler( | 26 AppCacheRequestHandler* AppCacheInterceptor::GetHandler( |
| 22 net::URLRequest* request) { | 27 net::URLRequest* request) { |
| 23 return reinterpret_cast<AppCacheRequestHandler*>( | 28 return reinterpret_cast<AppCacheRequestHandler*>( |
| 24 request->GetUserData(instance())); | 29 request->GetUserData(GetInstance())); |
| 25 } | 30 } |
| 26 | 31 |
| 27 void AppCacheInterceptor::SetExtraRequestInfo( | 32 void AppCacheInterceptor::SetExtraRequestInfo( |
| 28 net::URLRequest* request, AppCacheService* service, int process_id, | 33 net::URLRequest* request, AppCacheService* service, int process_id, |
| 29 int host_id, ResourceType::Type resource_type) { | 34 int host_id, ResourceType::Type resource_type) { |
| 30 if (!service || (host_id == kNoHostId)) | 35 if (!service || (host_id == kNoHostId)) |
| 31 return; | 36 return; |
| 32 | 37 |
| 33 AppCacheBackendImpl* backend = service->GetBackend(process_id); | 38 AppCacheBackendImpl* backend = service->GetBackend(process_id); |
| 34 if (!backend) | 39 if (!backend) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 89 |
| 85 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( | 90 net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse( |
| 86 net::URLRequest* request) { | 91 net::URLRequest* request) { |
| 87 AppCacheRequestHandler* handler = GetHandler(request); | 92 AppCacheRequestHandler* handler = GetHandler(request); |
| 88 if (!handler) | 93 if (!handler) |
| 89 return NULL; | 94 return NULL; |
| 90 return handler->MaybeLoadFallbackForResponse(request); | 95 return handler->MaybeLoadFallbackForResponse(request); |
| 91 } | 96 } |
| 92 | 97 |
| 93 } // namespace appcache | 98 } // namespace appcache |
| OLD | NEW |