| 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 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
| 7 | 7 |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 #include "webkit/common/resource_type.h" | 12 #include "webkit/common/resource_type.h" |
| 13 | 13 |
| 14 namespace appcache { | 14 namespace content { |
| 15 class AppCacheRequestHandler; | 15 class AppCacheRequestHandler; |
| 16 class AppCacheServiceImpl; | 16 class AppCacheServiceImpl; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 // An interceptor to hijack requests and potentially service them out of | 21 // An interceptor to hijack requests and potentially service them out of |
| 22 // the appcache. | 22 // the appcache. |
| 23 class CONTENT_EXPORT AppCacheInterceptor | 23 class CONTENT_EXPORT AppCacheInterceptor |
| 24 : public net::URLRequest::Interceptor { | 24 : public net::URLRequest::Interceptor { |
| 25 public: | 25 public: |
| 26 // Registers a singleton instance with the net library. | 26 // Registers a singleton instance with the net library. |
| 27 // Should be called early in the IO thread prior to initiating requests. | 27 // Should be called early in the IO thread prior to initiating requests. |
| 28 static void EnsureRegistered() { | 28 static void EnsureRegistered() { |
| 29 CHECK(GetInstance()); | 29 CHECK(GetInstance()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Must be called to make a request eligible for retrieval from an appcache. | 32 // Must be called to make a request eligible for retrieval from an appcache. |
| 33 static void SetExtraRequestInfo(net::URLRequest* request, | 33 static void SetExtraRequestInfo(net::URLRequest* request, |
| 34 appcache::AppCacheServiceImpl* service, | 34 AppCacheServiceImpl* service, |
| 35 int process_id, | 35 int process_id, |
| 36 int host_id, | 36 int host_id, |
| 37 ResourceType::Type resource_type); | 37 ResourceType::Type resource_type); |
| 38 | 38 |
| 39 // May be called after response headers are complete to retrieve extra | 39 // May be called after response headers are complete to retrieve extra |
| 40 // info about the response. | 40 // info about the response. |
| 41 static void GetExtraResponseInfo(net::URLRequest* request, | 41 static void GetExtraResponseInfo(net::URLRequest* request, |
| 42 int64* cache_id, | 42 int64* cache_id, |
| 43 GURL* manifest_url); | 43 GURL* manifest_url); |
| 44 | 44 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 64 net::NetworkDelegate* network_delegate, | 64 net::NetworkDelegate* network_delegate, |
| 65 const GURL& location) OVERRIDE; | 65 const GURL& location) OVERRIDE; |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 friend struct DefaultSingletonTraits<AppCacheInterceptor>; | 68 friend struct DefaultSingletonTraits<AppCacheInterceptor>; |
| 69 | 69 |
| 70 AppCacheInterceptor(); | 70 AppCacheInterceptor(); |
| 71 virtual ~AppCacheInterceptor(); | 71 virtual ~AppCacheInterceptor(); |
| 72 | 72 |
| 73 static void SetHandler(net::URLRequest* request, | 73 static void SetHandler(net::URLRequest* request, |
| 74 appcache::AppCacheRequestHandler* handler); | 74 AppCacheRequestHandler* handler); |
| 75 static appcache::AppCacheRequestHandler* GetHandler(net::URLRequest* request); | 75 static AppCacheRequestHandler* GetHandler(net::URLRequest* request); |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); | 77 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace content | 80 } // namespace content |
| 81 | 81 |
| 82 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 82 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
| OLD | NEW |