| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_DATA_REDUCTION_PROXY_DATA_H
_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_DATA_H
_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_DATA_H
_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_DATA_H
_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <memory> | 10 #include <memory> |
| 9 #include <string> | 11 #include <string> |
| 10 | 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/optional.h" | 14 #include "base/optional.h" |
| 13 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
| 14 #include "net/nqe/effective_connection_type.h" | 16 #include "net/nqe/effective_connection_type.h" |
| 15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 } | 36 } |
| 35 | 37 |
| 36 // Whether Lo-Fi was requested for this request or navigation. True if the | 38 // Whether Lo-Fi was requested for this request or navigation. True if the |
| 37 // session is in Lo-Fi control or enabled group, and the network quality is | 39 // session is in Lo-Fi control or enabled group, and the network quality is |
| 38 // slow. | 40 // slow. |
| 39 bool lofi_requested() const { return lofi_requested_; } | 41 bool lofi_requested() const { return lofi_requested_; } |
| 40 void set_lofi_requested(bool lofi_requested) { | 42 void set_lofi_requested(bool lofi_requested) { |
| 41 lofi_requested_ = lofi_requested; | 43 lofi_requested_ = lofi_requested; |
| 42 } | 44 } |
| 43 | 45 |
| 44 // The session key used for this request. | 46 // Whether a lite page response was seen for the request or navigation. |
| 47 bool lite_page_received() const { return lite_page_received_; } |
| 48 void set_lite_page_received(bool lite_page_received) { |
| 49 lite_page_received_ = lite_page_received; |
| 50 } |
| 51 |
| 52 // Whether a lite page response was seen for the request or navigation. |
| 53 bool lofi_received() const { return lofi_received_; } |
| 54 void set_lofi_received(bool lofi_received) { lofi_received_ = lofi_received; } |
| 55 |
| 56 // The session key used for this request. Only set for main frame requests. |
| 45 std::string session_key() const { return session_key_; } | 57 std::string session_key() const { return session_key_; } |
| 46 void set_session_key(const std::string& session_key) { | 58 void set_session_key(const std::string& session_key) { |
| 47 session_key_ = session_key; | 59 session_key_ = session_key; |
| 48 } | 60 } |
| 49 | 61 |
| 50 // The URL the frame is navigating to. This may change during the navigation | 62 // The URL the frame is navigating to. This may change during the navigation |
| 51 // when encountering a server redirect. | 63 // when encountering a server redirect. Only set for main frame requests. |
| 52 GURL request_url() const { return request_url_; } | 64 GURL request_url() const { return request_url_; } |
| 53 void set_request_url(const GURL& request_url) { request_url_ = request_url; } | 65 void set_request_url(const GURL& request_url) { request_url_ = request_url; } |
| 54 | 66 |
| 55 // The EffectiveConnectionType after the proxy is resolved. This is set for | 67 // The EffectiveConnectionType after the proxy is resolved. This is set for |
| 56 // main frame requests only. | 68 // main frame requests only. |
| 57 net::EffectiveConnectionType effective_connection_type() const { | 69 net::EffectiveConnectionType effective_connection_type() const { |
| 58 return effective_connection_type_; | 70 return effective_connection_type_; |
| 59 } | 71 } |
| 60 void set_effective_connection_type( | 72 void set_effective_connection_type( |
| 61 const net::EffectiveConnectionType& effective_connection_type) { | 73 const net::EffectiveConnectionType& effective_connection_type) { |
| 62 effective_connection_type_ = effective_connection_type; | 74 effective_connection_type_ = effective_connection_type; |
| 63 } | 75 } |
| 64 | 76 |
| 65 // An identifier that is guaranteed to be unique to each page load during a | 77 // An identifier that is guaranteed to be unique to each page load during a |
| 66 // data saver session. Only present on main frame requests. | 78 // data saver session. Only present on main frame requests. |
| 67 base::Optional<uint64_t> page_id() const { return page_id_; } | 79 const base::Optional<uint64_t>& page_id() const { return page_id_; } |
| 68 void set_page_id(uint64_t page_id) { page_id_ = page_id; } | 80 void set_page_id(uint64_t page_id) { page_id_ = page_id; } |
| 69 | 81 |
| 70 // Removes |this| from |request|. | 82 // Removes |this| from |request|. |
| 71 static void ClearData(net::URLRequest* request); | 83 static void ClearData(net::URLRequest* request); |
| 72 | 84 |
| 73 // Returns the Data from the URLRequest's UserData. | 85 // Returns the Data from the URLRequest's UserData. |
| 74 static DataReductionProxyData* GetData(const net::URLRequest& request); | 86 static DataReductionProxyData* GetData(const net::URLRequest& request); |
| 75 // Returns the Data for a given URLRequest. If there is currently no | 87 // Returns the Data for a given URLRequest. If there is currently no |
| 76 // DataReductionProxyData on URLRequest, it creates one, and adds it to the | 88 // DataReductionProxyData on URLRequest, it creates one, and adds it to the |
| 77 // URLRequest's UserData, and returns a raw pointer to the new instance. | 89 // URLRequest's UserData, and returns a raw pointer to the new instance. |
| 78 static DataReductionProxyData* GetDataAndCreateIfNecessary( | 90 static DataReductionProxyData* GetDataAndCreateIfNecessary( |
| 79 net::URLRequest* request); | 91 net::URLRequest* request); |
| 80 | 92 |
| 81 // Create a brand new instance of DataReductionProxyData that could be used in | 93 // Create a brand new instance of DataReductionProxyData that could be used in |
| 82 // a different thread. Several of deep copies may occur per navigation, so | 94 // a different thread. Several of deep copies may occur per navigation, so |
| 83 // this is inexpensive. | 95 // this is inexpensive. |
| 84 std::unique_ptr<DataReductionProxyData> DeepCopy() const; | 96 std::unique_ptr<DataReductionProxyData> DeepCopy() const; |
| 85 | 97 |
| 86 private: | 98 private: |
| 87 // Whether the DataReductionProxy was used for this request or navigation. | 99 // Whether the DataReductionProxy was used for this request or navigation. |
| 88 bool used_data_reduction_proxy_; | 100 bool used_data_reduction_proxy_; |
| 89 | 101 |
| 90 // Whether Lo-Fi was requested for this request or navigation. True if the | 102 // Whether Lo-Fi was requested for this request or navigation. True if the |
| 91 // session is in Lo-Fi control or enabled group, and the network quality is | 103 // session is in Lo-Fi control or enabled group, and the network quality is |
| 92 // slow. | 104 // slow. |
| 93 bool lofi_requested_; | 105 bool lofi_requested_; |
| 94 | 106 |
| 107 // Whether a lite page response was seen for the request or navigation. |
| 108 bool lite_page_received_; |
| 109 |
| 110 // Whether a lite page response was seen for the request or navigation. |
| 111 bool lofi_received_; |
| 112 |
| 95 // The session key used for this request or navigation. | 113 // The session key used for this request or navigation. |
| 96 std::string session_key_; | 114 std::string session_key_; |
| 97 | 115 |
| 98 // The URL the frame is navigating to. This may change during the navigation | 116 // The URL the frame is navigating to. This may change during the navigation |
| 99 // when encountering a server redirect. | 117 // when encountering a server redirect. |
| 100 GURL request_url_; | 118 GURL request_url_; |
| 101 | 119 |
| 102 // The EffectiveConnectionType when the request or navigation starts. This is | 120 // The EffectiveConnectionType when the request or navigation starts. This is |
| 103 // set for main frame requests only. | 121 // set for main frame requests only. |
| 104 net::EffectiveConnectionType effective_connection_type_; | 122 net::EffectiveConnectionType effective_connection_type_; |
| 105 | 123 |
| 106 // An identifier that is guaranteed to be unique to each page load during a | 124 // An identifier that is guaranteed to be unique to each page load during a |
| 107 // data saver session. Only present on main frame requests. | 125 // data saver session. Only present on main frame requests. |
| 108 base::Optional<uint64_t> page_id_; | 126 base::Optional<uint64_t> page_id_; |
| 109 | 127 |
| 110 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyData); | 128 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyData); |
| 111 }; | 129 }; |
| 112 | 130 |
| 113 } // namespace data_reduction_proxy | 131 } // namespace data_reduction_proxy |
| 114 | 132 |
| 115 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_DAT
A_H_ | 133 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_DAT
A_H_ |
| OLD | NEW |