Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / appcache / appcache_interceptor.h
blobb584919f9a885b4a54852706f2c92590e4bab6f8
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/memory/singleton.h"
9 #include "content/common/content_export.h"
10 #include "content/public/common/resource_type.h"
11 #include "net/url_request/url_request.h"
12 #include "url/gurl.h"
14 namespace content {
15 class AppCacheRequestHandler;
16 class AppCacheServiceImpl;
18 // An interceptor to hijack requests and potentially service them out of
19 // the appcache.
20 class CONTENT_EXPORT AppCacheInterceptor
21 : public net::URLRequest::Interceptor {
22 public:
23 // Registers a singleton instance with the net library.
24 // Should be called early in the IO thread prior to initiating requests.
25 static void EnsureRegistered() {
26 CHECK(GetInstance());
29 // Must be called to make a request eligible for retrieval from an appcache.
30 static void SetExtraRequestInfo(net::URLRequest* request,
31 AppCacheServiceImpl* service,
32 int process_id,
33 int host_id,
34 ResourceType resource_type);
36 // May be called after response headers are complete to retrieve extra
37 // info about the response.
38 static void GetExtraResponseInfo(net::URLRequest* request,
39 int64* cache_id,
40 GURL* manifest_url);
42 // Methods to support cross site navigations.
43 static void PrepareForCrossSiteTransfer(net::URLRequest* request,
44 int old_process_id);
45 static void CompleteCrossSiteTransfer(net::URLRequest* request,
46 int new_process_id,
47 int new_host_id);
49 static AppCacheInterceptor* GetInstance();
51 protected:
52 // Override from net::URLRequest::Interceptor:
53 virtual net::URLRequestJob* MaybeIntercept(
54 net::URLRequest* request,
55 net::NetworkDelegate* network_delegate) OVERRIDE;
56 virtual net::URLRequestJob* MaybeInterceptResponse(
57 net::URLRequest* request,
58 net::NetworkDelegate* network_delegate) OVERRIDE;
59 virtual net::URLRequestJob* MaybeInterceptRedirect(
60 net::URLRequest* request,
61 net::NetworkDelegate* network_delegate,
62 const GURL& location) OVERRIDE;
64 private:
65 friend struct DefaultSingletonTraits<AppCacheInterceptor>;
67 AppCacheInterceptor();
68 virtual ~AppCacheInterceptor();
70 static void SetHandler(net::URLRequest* request,
71 AppCacheRequestHandler* handler);
72 static AppCacheRequestHandler* GetHandler(net::URLRequest* request);
74 DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor);
77 } // namespace content
79 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_