1 // Copyright (c) 2012 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 CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_
6 #define CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/offline/offline_load_page.h"
13 #include "content/public/browser/resource_throttle.h"
14 #include "net/base/completion_callback.h"
17 class AppCacheService
;
23 // Used to show an offline interstitial page when the network is not available.
24 class OfflineResourceThrottle
25 : public content::ResourceThrottle
,
26 public base::SupportsWeakPtr
<OfflineResourceThrottle
> {
28 OfflineResourceThrottle(int render_process_id
,
30 net::URLRequest
* request
,
31 appcache::AppCacheService
* appcache_service
);
32 virtual ~OfflineResourceThrottle();
34 // content::ResourceThrottle implementation:
35 virtual void WillStartRequest(bool* defer
) OVERRIDE
;
38 // OfflineLoadPage callback.
39 void OnBlockingPageComplete(bool proceed
);
41 // Erase the state associated with a deferred load request.
42 void ClearRequestInfo();
43 bool IsRemote(const GURL
& url
) const;
45 // True if chrome should show the offline page.
46 bool ShouldShowOfflinePage(const GURL
& url
) const;
48 // A callback to tell if an appcache exists.
49 void OnCanHandleOfflineComplete(int rv
);
51 int render_process_id_
;
53 net::URLRequest
* request_
;
54 // Safe to keep a pointer around since AppCacheService outlives all requests.
55 appcache::AppCacheService
* appcache_service_
;
56 net::CancelableCompletionCallback appcache_completion_callback_
;
58 DISALLOW_COPY_AND_ASSIGN(OfflineResourceThrottle
);
61 #endif // CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_