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(net::URLRequest
* request
,
29 content::AppCacheService
* appcache_service
);
30 ~OfflineResourceThrottle() override
;
32 // content::ResourceThrottle implementation:
33 void WillStartRequest(bool* defer
) override
;
34 const char* GetNameForLogging() const override
;
37 void OnBlockingPageComplete(bool proceed
);
38 void ClearRequestInfo();
39 bool IsRemote(const GURL
& url
) const;
40 bool ShouldShowOfflinePage(const GURL
& url
) const;
41 void OnCanHandleOfflineComplete(int rv
);
43 net::URLRequest
* request_
;
44 // Safe to keep a pointer around since AppCacheService outlives all requests.
45 content::AppCacheService
* appcache_service_
;
46 net::CancelableCompletionCallback completion_callback_
;
47 int pending_callbacks_
;
49 DISALLOW_COPY_AND_ASSIGN(OfflineResourceThrottle
);
52 #endif // CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_