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_BROWSER_LOFI_DECIDER_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_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 mode is on for the given |request|. This means the | 23 // Returns true when Lo-Fi mode is on for the given |request|. This means the |
24 // Lo-Fi header should be added to the given request. | 24 // Lo-Fi header should be added to the given request. |
25 virtual bool IsUsingLoFiMode(const net::URLRequest& request) const = 0; | 25 virtual bool IsUsingLoFiMode(const net::URLRequest& request) const = 0; |
26 | 26 |
27 // Returns true when Lo-Fi mode is on for the given |request|. If the | 27 // Returns true when Lo-Fi mode is on for the given |request|. If the |
28 // |request| is using Lo-Fi mode, adds the "q=low" directive to the |headers|. | 28 // |request| is using Lo-Fi mode, adds the "q=low" directive to the |headers|. |
29 // If the |request| is using Lo-Fi preview mode, and it is a main frame | 29 // If the |request| is using Lo-Fi mode, lite pages are enabled, and it is a |
30 // request adds the "q=preview" and it is a main frame request directive to | 30 // main frame request adds the "q=preview" directive to the |headers|. |
31 // the |headers|. | |
32 virtual bool MaybeAddLoFiDirectiveToHeaders( | 31 virtual bool MaybeAddLoFiDirectiveToHeaders( |
33 const net::URLRequest& request, | 32 const net::URLRequest& request, |
34 net::HttpRequestHeaders* headers) const = 0; | 33 net::HttpRequestHeaders* headers) const = 0; |
35 | 34 |
36 // Returns true if the Lo-Fi specific UMA should be recorded. It is set to | 35 // Returns true if the Lo-Fi specific UMA should be recorded. It is set to |
37 // true if Lo-Fi is enabled for |request|, Chrome session is in Lo-Fi | 36 // true if Lo-Fi is enabled for |request|, Chrome session is in Lo-Fi |
38 // Enabled or Control field trial, and the network quality was slow. | 37 // Enabled or Control field trial, and the network quality was slow. |
39 virtual bool ShouldRecordLoFiUMA(const net::URLRequest& request) const = 0; | 38 virtual bool ShouldRecordLoFiUMA(const net::URLRequest& request) const = 0; |
40 }; | 39 }; |
41 | 40 |
42 } // namespace data_reduction_proxy | 41 } // namespace data_reduction_proxy |
43 | 42 |
44 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ | 43 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_LOFI_DECIDER_H_ |
OLD | NEW |