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 #ifndef WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
6 #define WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
7 | 7 |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
11 #include "webkit/glue/resource_type.h" | 11 #include "webkit/glue/resource_type.h" |
12 | 12 |
13 namespace appcache { | 13 namespace appcache { |
14 | 14 |
| 15 class AppCacheRequestHandler; |
15 class AppCacheService; | 16 class AppCacheService; |
16 | 17 |
17 // An interceptor to hijack requests and potentially service them out of | 18 // An interceptor to hijack requests and potentially service them out of |
18 // the appcache. | 19 // the appcache. |
19 class AppCacheInterceptor : public URLRequest::Interceptor { | 20 class AppCacheInterceptor : public URLRequest::Interceptor { |
20 public: | 21 public: |
21 // Registers a singleton instance with the net library. | 22 // Registers a singleton instance with the net library. |
22 // Should be called early in the IO thread prior to initiating requests. | 23 // Should be called early in the IO thread prior to initiating requests. |
23 static void EnsureRegistered() { | 24 static void EnsureRegistered() { |
24 CHECK(instance()); | 25 CHECK(instance()); |
(...skipping 14 matching lines...) Expand all Loading... |
39 | 40 |
40 protected: | 41 protected: |
41 // URLRequest::Interceptor overrides | 42 // URLRequest::Interceptor overrides |
42 virtual URLRequestJob* MaybeIntercept(URLRequest* request); | 43 virtual URLRequestJob* MaybeIntercept(URLRequest* request); |
43 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request); | 44 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request); |
44 virtual URLRequestJob* MaybeInterceptRedirect(URLRequest* request, | 45 virtual URLRequestJob* MaybeInterceptRedirect(URLRequest* request, |
45 const GURL& location); | 46 const GURL& location); |
46 | 47 |
47 private: | 48 private: |
48 friend struct DefaultSingletonTraits<AppCacheInterceptor>; | 49 friend struct DefaultSingletonTraits<AppCacheInterceptor>; |
| 50 |
49 static AppCacheInterceptor* instance() { | 51 static AppCacheInterceptor* instance() { |
50 return Singleton<AppCacheInterceptor>::get(); | 52 return Singleton<AppCacheInterceptor>::get(); |
51 } | 53 } |
52 struct ExtraInfo; | 54 |
53 AppCacheInterceptor(); | 55 AppCacheInterceptor(); |
54 virtual ~AppCacheInterceptor(); | 56 virtual ~AppCacheInterceptor(); |
| 57 |
| 58 static void SetHandler(URLRequest* request, AppCacheRequestHandler* handler); |
| 59 static AppCacheRequestHandler* GetHandler(URLRequest* request); |
| 60 |
55 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); | 61 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); |
56 }; | 62 }; |
57 | 63 |
58 } // namespace appcache | 64 } // namespace appcache |
59 | 65 |
60 #endif // WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 66 #endif // WEBKIT_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
OLD | NEW |