OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_RES OURCE_THROTTLE_H_ | |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_RES OURCE_THROTTLE_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_u i_manager.h" | |
11 #include "content/public/browser/resource_throttle.h" | |
12 #include "content/public/common/resource_type.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace net { | |
16 class URLRequest; | |
17 } | |
18 | |
19 namespace data_reduction_proxy { | |
20 | |
21 class DataReductionProxyParams; | |
22 class DataReductionProxyUIManager; | |
23 class DataReductionProxyUIService; | |
24 | |
25 // Gets notified at various points during the process of loading a resource. | |
26 // Defers the resource load when the data reduction proxy is not going to be | |
27 // used. Resumes or cancels a deferred resource load via the ResourceController. | |
28 class DataReductionProxyResourceThrottle | |
29 : public content::ResourceThrottle, | |
30 public base::SupportsWeakPtr<DataReductionProxyResourceThrottle> { | |
31 public: | |
32 // Constructs a DataReductionProxyResourceThrottle object with the given | |
33 // request, resource type, ui service, and params. | |
34 DataReductionProxyResourceThrottle( | |
35 const net::URLRequest* request, | |
36 content::ResourceType resource_type, | |
37 const DataReductionProxyUIService* ui_service, | |
38 const DataReductionProxyParams* params); | |
39 | |
40 virtual ~DataReductionProxyResourceThrottle(); | |
41 | |
42 // Overrides content::ResourceThrottle. | |
43 void WillStartUsingNetwork(bool* defer) override; | |
44 void WillRedirectRequest(const GURL& new_url, bool* defer) override; | |
45 void WillProcessResponse(bool* defer) override; | |
46 const char* GetNameForLogging() const override; | |
47 | |
48 private: | |
49 enum State { | |
bengr
2014/12/29 18:45:41
Please add a comment that describes these states.
megjablon
2014/12/30 23:40:00
Done.
| |
50 NOT_BYPASSED, | |
51 LOCAL_BYPASS, | |
52 REMOTE_BYPASS, | |
53 }; | |
54 | |
55 // Creates a bypass resource and calls StartDisplayingBlockingPage on the UI | |
56 // thread. Sets defer to true. A bypass resource is a structure used to pass | |
57 // parameters between the IO and UI thread when interacting with the blocking | |
58 // page. Virtual for testing. | |
59 virtual void DisplayBlockingPage(bool* defer); | |
60 | |
61 // Called on the IO thread when the user has decided to proceed with the | |
62 // current request, or go back. | |
63 void OnBlockingPageComplete(bool proceed); | |
64 | |
65 // Starts displaying the data reduction proxy interstitial page if it is not | |
66 // prerendering. Called on the UI thread. | |
bengr
2014/12/29 18:45:41
"Must only be called on the UI thread." Also add d
megjablon
2014/12/30 23:40:00
Done.
| |
67 static void StartDisplayingBlockingPage( | |
bengr
2014/12/29 18:45:41
static members should be declared before non-stati
megjablon
2014/12/30 23:39:59
Done.
| |
68 const base::WeakPtr<DataReductionProxyResourceThrottle>& throttle, | |
69 scoped_refptr<DataReductionProxyUIManager> ui_manager, | |
70 const DataReductionProxyUIManager::BypassResource& resource); | |
71 | |
72 // The bypass state of this. | |
73 State state_; | |
74 | |
75 // Must outlive |this|. | |
76 const net::URLRequest* request_; | |
77 | |
78 // Holds the UI manager that shows intersitials. Must outlive |this|. | |
79 const DataReductionProxyUIService* ui_service_; | |
80 | |
81 // Must outlive |this|. | |
82 const DataReductionProxyParams* params_; | |
83 | |
84 const bool is_subresource_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyResourceThrottle); | |
87 }; | |
88 | |
89 } // namespace data_reduction_proxy | |
90 | |
91 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_ RESOURCE_THROTTLE_H_ | |
OLD | NEW |