blob: 1844860e57845c38cd1123bd49f036dfd26f038d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_
#define CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_
#pragma once
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/offline/offline_load_page.h"
#include "content/public/browser/resource_throttle.h"
#include "net/base/completion_callback.h"
class ChromeAppCacheService;
class ResourceDispatcherHost;
namespace content {
class ResourceContext;
}
namespace net {
class URLRequest;
} // namespace net
// Used to show an offline interstitial page when the network is not available.
class OfflineResourceThrottle
: public content::ResourceThrottle,
public base::SupportsWeakPtr<OfflineResourceThrottle> {
public:
OfflineResourceThrottle(int render_process_id,
int render_view_id,
net::URLRequest* request,
content::ResourceContext* resource_context);
virtual ~OfflineResourceThrottle();
// content::ResourceThrottle implementation:
virtual void WillStartRequest(bool* defer) OVERRIDE;
private:
// OfflineLoadPage callback.
void OnBlockingPageComplete(bool proceed);
// Erase the state associated with a deferred load request.
void ClearRequestInfo();
bool IsRemote(const GURL& url) const;
// True if chrome should show the offline page.
bool ShouldShowOfflinePage(const GURL& url) const;
// A callback to tell if an appcache exists.
void OnCanHandleOfflineComplete(int rv);
int render_process_id_;
int render_view_id_;
net::URLRequest* request_;
// Safe to keep a pointer around since ResourceContext outlives all requests.
content::ResourceContext* resource_context_;
net::CancelableCompletionCallback appcache_completion_callback_;
DISALLOW_COPY_AND_ASSIGN(OfflineResourceThrottle);
};
#endif // CHROME_BROWSER_RENDERER_HOST_OFFLINE_RESOURCE_THROTTLE_H_
|