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 "content/public/common/resource_type.h" | 10 #include "content/public/common/resource_type.h" |
11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
12 #include "net/url_request/url_request_interceptor.h" | |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 class AppCacheRequestHandler; | 16 class AppCacheRequestHandler; |
16 class AppCacheServiceImpl; | 17 class AppCacheServiceImpl; |
17 | 18 |
18 // An interceptor to hijack requests and potentially service them out of | 19 // An interceptor to hijack requests and potentially service them out of |
19 // the appcache. | 20 // the appcache. |
20 class CONTENT_EXPORT AppCacheInterceptor | 21 class CONTENT_EXPORT AppCacheInterceptor |
21 : public net::URLRequest::Interceptor { | 22 : public net::URLRequest::Interceptor { |
(...skipping 19 matching lines...) Expand all Loading... | |
41 | 42 |
42 // Methods to support cross site navigations. | 43 // Methods to support cross site navigations. |
43 static void PrepareForCrossSiteTransfer(net::URLRequest* request, | 44 static void PrepareForCrossSiteTransfer(net::URLRequest* request, |
44 int old_process_id); | 45 int old_process_id); |
45 static void CompleteCrossSiteTransfer(net::URLRequest* request, | 46 static void CompleteCrossSiteTransfer(net::URLRequest* request, |
46 int new_process_id, | 47 int new_process_id, |
47 int new_host_id); | 48 int new_host_id); |
48 | 49 |
49 static AppCacheInterceptor* GetInstance(); | 50 static AppCacheInterceptor* GetInstance(); |
50 | 51 |
52 // The appcache system employs two different interceptors. The singleton | |
53 // AppCacheInterceptor derives URLRequest::Interceptor and is used | |
54 // to hijack request handling upon receipt of the response or a redirect. | |
55 // A seperate URLRequestInterceptor derivative is used to hijack handling | |
falken
2014/10/14 01:24:49
nittttty nit: separate
| |
56 // at the very start of request processing. The seperate handler allows the | |
falken
2014/10/14 01:24:49
separate
| |
57 // content lib to order its collection of net::URLRequestInterceptors. | |
58 static scoped_ptr<net::URLRequestInterceptor> CreateStartInterceptor(); | |
59 | |
51 protected: | 60 protected: |
52 // Override from net::URLRequest::Interceptor: | 61 // Override from net::URLRequest::Interceptor: |
53 virtual net::URLRequestJob* MaybeIntercept( | 62 virtual net::URLRequestJob* MaybeIntercept( |
54 net::URLRequest* request, | 63 net::URLRequest* request, |
55 net::NetworkDelegate* network_delegate) override; | 64 net::NetworkDelegate* network_delegate) override; |
56 virtual net::URLRequestJob* MaybeInterceptResponse( | 65 virtual net::URLRequestJob* MaybeInterceptResponse( |
57 net::URLRequest* request, | 66 net::URLRequest* request, |
58 net::NetworkDelegate* network_delegate) override; | 67 net::NetworkDelegate* network_delegate) override; |
59 virtual net::URLRequestJob* MaybeInterceptRedirect( | 68 virtual net::URLRequestJob* MaybeInterceptRedirect( |
60 net::URLRequest* request, | 69 net::URLRequest* request, |
61 net::NetworkDelegate* network_delegate, | 70 net::NetworkDelegate* network_delegate, |
62 const GURL& location) override; | 71 const GURL& location) override; |
63 | 72 |
64 private: | 73 private: |
65 friend struct DefaultSingletonTraits<AppCacheInterceptor>; | 74 friend struct DefaultSingletonTraits<AppCacheInterceptor>; |
75 class StartInterceptor; | |
66 | 76 |
67 AppCacheInterceptor(); | 77 AppCacheInterceptor(); |
68 virtual ~AppCacheInterceptor(); | 78 virtual ~AppCacheInterceptor(); |
69 | 79 |
70 static void SetHandler(net::URLRequest* request, | 80 static void SetHandler(net::URLRequest* request, |
71 AppCacheRequestHandler* handler); | 81 AppCacheRequestHandler* handler); |
72 static AppCacheRequestHandler* GetHandler(net::URLRequest* request); | 82 static AppCacheRequestHandler* GetHandler(net::URLRequest* request); |
73 | 83 |
74 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); | 84 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor); |
75 }; | 85 }; |
76 | 86 |
77 } // namespace content | 87 } // namespace content |
78 | 88 |
79 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ | 89 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_ |
OLD | NEW |