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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_
8 #include "base/basictypes.h"
9 #include "content/common/content_export.h"
10 #include "content/public/common/resource_type.h"
11 #include "net/url_request/url_request_interceptor.h"
20 class AppCacheRequestHandler
;
21 class AppCacheServiceImpl
;
23 // An interceptor to hijack requests and potentially service them out of
25 class CONTENT_EXPORT AppCacheInterceptor
: public net::URLRequestInterceptor
{
27 // Must be called to make a request eligible for retrieval from an appcache.
28 static void SetExtraRequestInfo(net::URLRequest
* request
,
29 AppCacheServiceImpl
* service
,
32 ResourceType resource_type
,
33 bool should_reset_appcache
);
35 // May be called after response headers are complete to retrieve extra
36 // info about the response.
37 static void GetExtraResponseInfo(net::URLRequest
* request
,
41 // Methods to support cross site navigations.
42 static void PrepareForCrossSiteTransfer(net::URLRequest
* request
,
44 static void CompleteCrossSiteTransfer(net::URLRequest
* request
,
47 static void MaybeCompleteCrossSiteTransferInOldProcess(
48 net::URLRequest
* request
,
51 AppCacheInterceptor();
52 ~AppCacheInterceptor() override
;
55 // Override from net::URLRequestInterceptor:
56 net::URLRequestJob
* MaybeInterceptRequest(
57 net::URLRequest
* request
,
58 net::NetworkDelegate
* network_delegate
) const override
;
59 net::URLRequestJob
* MaybeInterceptResponse(
60 net::URLRequest
* request
,
61 net::NetworkDelegate
* network_delegate
) const override
;
62 net::URLRequestJob
* MaybeInterceptRedirect(
63 net::URLRequest
* request
,
64 net::NetworkDelegate
* network_delegate
,
65 const GURL
& location
) const override
;
68 static void SetHandler(net::URLRequest
* request
,
69 AppCacheRequestHandler
* handler
);
70 static AppCacheRequestHandler
* GetHandler(net::URLRequest
* request
);
72 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor
);
75 } // namespace content
77 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_