Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1018)

Side by Side Diff: components/data_reduction_proxy/content/browser/data_reduction_proxy_resource_throttle.h

Issue 684223003: Data Reduction Proxy Interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing bengr comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 //
29 // Displays a warning if the data reduction proxy returns a response that
30 // triggers a bypass, when the proxy will not be used for a request because it
31 // isn't configured (a previous bypass), when the proxy is supposed to be used,
32 // but there is a connection error. Will not warn when the data reduction proxy
33 // is bypassed by local rules, or when the url scheme is not proxied by the data
34 // reduction proxy.
35 //
36 // This feature is for users that wish to be warned when configurations that are
bengr 2014/12/31 01:10:21 Reword: This class is useful, e.g., for users that
megjablon 2014/12/31 02:12:28 Done.
37 // able to go through the data reduction proxy are bypassed.
38 class DataReductionProxyResourceThrottle
39 : public content::ResourceThrottle,
40 public base::SupportsWeakPtr<DataReductionProxyResourceThrottle> {
41 public:
42 // Constructs a DataReductionProxyResourceThrottle object with the given
43 // request, resource type, ui service, and params.
44 DataReductionProxyResourceThrottle(
45 const net::URLRequest* request,
46 content::ResourceType resource_type,
47 const DataReductionProxyUIService* ui_service,
48 const DataReductionProxyParams* params);
49
50 virtual ~DataReductionProxyResourceThrottle();
51
52 // Overrides content::ResourceThrottle.
53 void WillStartUsingNetwork(bool* defer) override;
54 void WillRedirectRequest(const GURL& new_url, bool* defer) override;
55 void WillProcessResponse(bool* defer) override;
56 const char* GetNameForLogging() const override;
57
58 private:
59 enum State {
60 NOT_BYPASSED, // A warning has not been shown yet for this request.
61 LOCAL_BYPASS, // The request was bypassed by local bypass rules.
62 REMOTE_BYPASS, // The request was bypassed by the data reduction proxy.
63 };
64
65 // Starts displaying the data reduction proxy blocking page if it is not
66 // prerendering. Must only be called on the UI thread. Takes a bypass
67 // resource, which is a structure used to pass parameters between the IO and
68 // UI thread, and shows a blocking page for the resource using the given
69 // ui_manager.
70 static void StartDisplayingBlockingPage(
71 scoped_refptr<DataReductionProxyUIManager> ui_manager,
72 const DataReductionProxyUIManager::BypassResource& resource);
73
74 // Creates a bypass resource and calls StartDisplayingBlockingPage on the UI
75 // thread. Sets defer to true. A bypass resource is a structure used to pass
76 // parameters between the IO and UI thread when interacting with the blocking
77 // page. Virtual for testing.
78 virtual void DisplayBlockingPage(bool* defer);
79
80 // Called on the IO thread when the user has decided to proceed with the
81 // current request, or go back.
82 void OnBlockingPageComplete(bool proceed);
83
84 // The bypass state of this.
85 State state_;
86
87 // Must outlive |this|.
88 const net::URLRequest* request_;
89
90 // Holds the UI manager that shows intersitials. Must outlive |this|.
91 const DataReductionProxyUIService* ui_service_;
92
93 // Must outlive |this|.
94 const DataReductionProxyParams* params_;
95
96 const bool is_subresource_;
97
98 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyResourceThrottle);
99 };
100
101 } // namespace data_reduction_proxy
102
103 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_ RESOURCE_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698