OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_LOFI_DECIDER_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_LOFI_DECIDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 class HttpRequestHeaders; | 11 class HttpRequestHeaders; |
12 class URLRequest; | 12 class URLRequest; |
13 } | 13 } |
14 | 14 |
15 namespace data_reduction_proxy { | 15 namespace data_reduction_proxy { |
16 | 16 |
17 // Interface to determine if a request should be made for a low fidelity version | 17 // Interface to determine if a request should be made for a low fidelity version |
18 // of the resource. | 18 // of the resource. |
19 class LoFiDecider { | 19 class LoFiDecider { |
20 public: | 20 public: |
21 virtual ~LoFiDecider() {} | 21 virtual ~LoFiDecider() {} |
22 | 22 |
23 // Returns true when Lo-Fi Previews are on for the given |request|. This means | 23 // Returns true when Lo-Fi Previews are on for the given |request|. This means |
24 // the Lo-Fi header should be added to the given request. | 24 // the Lo-Fi header should be added to the given request. |
25 virtual bool IsUsingLoFi(const net::URLRequest& request) const = 0; | 25 virtual bool IsUsingLoFi(const net::URLRequest& request) const = 0; |
26 | 26 |
27 // Adds a previews-specific directive to the Chrome-Proxy-Accept-Transform | 27 // Adds a previews-specific directive to the Chrome-Proxy-Accept-Transform |
28 // header if needed. If a slow page preview is triggered, adds "lite-page" or | 28 // header if needed. If a preview is triggered, adds "lite-page" or |
29 // "empty-image", depending on whether the request is for the main frame | 29 // "empty-image", depending on whether the request is for the main frame |
30 // and lite pages are enabled, or for a subresource and Lo-Fi mode is enabled, | 30 // and lite pages are enabled, or for a subresource and Lo-Fi mode is enabled, |
31 // respectively. If a slow page preview is not triggered, "lite-page;if-heavy" | 31 // respectively. |
32 // and "empty-image;if-heavy" are added in the respective aforementioned cases | |
33 // to request that the server transform the page if it determines it to be | |
34 // heavy. Previews-related transformation headers are never added if | |
35 // |is_previews_disabled| is true. | |
36 virtual void MaybeSetAcceptTransformHeader( | 32 virtual void MaybeSetAcceptTransformHeader( |
37 const net::URLRequest& request, | 33 const net::URLRequest& request, |
bengr
2017/05/01 16:53:14
This doesn't need the whole request. It uses the r
| |
38 bool are_previews_disabled, | |
39 net::HttpRequestHeaders* headers) const = 0; | 34 net::HttpRequestHeaders* headers) const = 0; |
40 | 35 |
41 // Returns true if |headers| contains the Chrome-Proxy-Accept-Transform | 36 // Returns true if |headers| contains the Chrome-Proxy-Accept-Transform |
42 // header and a slow page previews directive ("lite-page" or "empty-image") | 37 // header and a slow page previews directive ("lite-page" or "empty-image") |
43 // is present and not conditioned on "if-heavy". | 38 // is present and not conditioned on "if-heavy". |
44 virtual bool IsSlowPagePreviewRequested( | 39 virtual bool IsSlowPagePreviewRequested( |
45 const net::HttpRequestHeaders& headers) const = 0; | 40 const net::HttpRequestHeaders& headers) const = 0; |
46 | 41 |
47 // Returns true if |headers| contains the Chrome-Proxy-Accept-Transform | 42 // Returns true if |headers| contains the Chrome-Proxy-Accept-Transform |
48 // header with the "lite-page" directive. | 43 // header with the "lite-page" directive. |
49 virtual bool IsLitePagePreviewRequested( | 44 virtual bool IsLitePagePreviewRequested( |
50 const net::HttpRequestHeaders& headers) const = 0; | 45 const net::HttpRequestHeaders& headers) const = 0; |
51 | 46 |
52 // Unconditionally removes the Chrome-Proxy-Accept-Transform header from | 47 // Unconditionally removes the Chrome-Proxy-Accept-Transform header from |
53 // |headers.| | 48 // |headers.| |
54 virtual void RemoveAcceptTransformHeader( | 49 virtual void RemoveAcceptTransformHeader( |
55 net::HttpRequestHeaders* headers) const = 0; | 50 net::HttpRequestHeaders* headers) const = 0; |
56 | 51 |
57 // Adds a directive to tell the server to ignore blacklists when a Lite Page | 52 // Adds a directive to tell the server to return a Lite Page preview due to |
58 // preview is being requested due to command line flags being set. | 53 // command line flags being set (in spite of a good network connection, the |
bengr
2017/05/01 16:53:14
I would stay away from commenting on the types of
| |
59 virtual void MaybeSetIgnorePreviewsBlacklistDirective( | 54 // page being blacklisted, or the page not being heavy). |
55 virtual void MaybeSetForceLitePageDirective( | |
60 net::HttpRequestHeaders* headers) const = 0; | 56 net::HttpRequestHeaders* headers) const = 0; |
61 | 57 |
62 // Returns true if the Lo-Fi specific UMA should be recorded. It is set to | 58 // Returns true if the Previews specific UMA should be recorded. It is set to |
bengr
2017/05/01 16:53:14
Previews specific -> Previews-specific
Also, prev
| |
63 // true if Lo-Fi is enabled for |request|, Chrome session is in Lo-Fi | 59 // true if Lo-Fi is enabled for |request| and Chrome session is in Lo-Fi |
64 // Enabled or Control field trial, and the network quality was slow. | 60 // Enabled or Control field trial. |
65 virtual bool ShouldRecordLoFiUMA(const net::URLRequest& request) const = 0; | 61 virtual bool ShouldRecordPreviewsUMA( |
62 const net::URLRequest& request) const = 0; | |
66 }; | 63 }; |
67 | 64 |
68 } // namespace data_reduction_proxy | 65 } // namespace data_reduction_proxy |
69 | 66 |
70 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ | 67 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_LOFI_DECIDER_H_ |
OLD | NEW |