| 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_COMMON_DATA_REDUCTION_PROXY_EVENT_C
REATOR_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_EVENT_C
REATOR_H_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_EVENT_C
REATOR_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_EVENT_C
REATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_storage_delegate.h" | 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_storage_delegate.h" |
| 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
| 17 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
| 18 #include "net/log/net_log_event_type.h" | 18 #include "net/log/net_log_event_type.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class TimeDelta; | 23 class TimeDelta; |
| 24 class Value; | 24 class Value; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 class BoundNetLog; | 28 class NetLogWithSource; |
| 29 class ProxyServer; | 29 class ProxyServer; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace data_reduction_proxy { | 32 namespace data_reduction_proxy { |
| 33 | 33 |
| 34 // Central location for creating debug events for the Data Reduction Proxy. | 34 // Central location for creating debug events for the Data Reduction Proxy. |
| 35 // This object lives on the IO thread and all of its methods are expected to be | 35 // This object lives on the IO thread and all of its methods are expected to be |
| 36 // called from there. | 36 // called from there. |
| 37 class DataReductionProxyEventCreator { | 37 class DataReductionProxyEventCreator { |
| 38 public: | 38 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 net::NetLog* net_log, | 50 net::NetLog* net_log, |
| 51 bool secure_transport_restricted, | 51 bool secure_transport_restricted, |
| 52 const std::vector<net::ProxyServer>& proxies_for_http); | 52 const std::vector<net::ProxyServer>& proxies_for_http); |
| 53 | 53 |
| 54 // Adds the DATA_REDUCTION_PROXY_ENABLED event (with enabled=false) to the | 54 // Adds the DATA_REDUCTION_PROXY_ENABLED event (with enabled=false) to the |
| 55 // event store. | 55 // event store. |
| 56 void AddProxyDisabledEvent(net::NetLog* net_log); | 56 void AddProxyDisabledEvent(net::NetLog* net_log); |
| 57 | 57 |
| 58 // Adds a DATA_REDUCTION_PROXY_BYPASS_REQUESTED event to the event store | 58 // Adds a DATA_REDUCTION_PROXY_BYPASS_REQUESTED event to the event store |
| 59 // when the bypass reason is initiated by the data reduction proxy. | 59 // when the bypass reason is initiated by the data reduction proxy. |
| 60 void AddBypassActionEvent(const net::BoundNetLog& net_log, | 60 void AddBypassActionEvent(const net::NetLogWithSource& net_log, |
| 61 DataReductionProxyBypassAction bypass_action, | 61 DataReductionProxyBypassAction bypass_action, |
| 62 const std::string& request_method, | 62 const std::string& request_method, |
| 63 const GURL& gurl, | 63 const GURL& gurl, |
| 64 bool should_retry, | 64 bool should_retry, |
| 65 const base::TimeDelta& bypass_duration); | 65 const base::TimeDelta& bypass_duration); |
| 66 | 66 |
| 67 // Adds a DATA_REDUCTION_PROXY_BYPASS_REQUESTED event to the event store | 67 // Adds a DATA_REDUCTION_PROXY_BYPASS_REQUESTED event to the event store |
| 68 // when the bypass reason is not initiated by the data reduction proxy, such | 68 // when the bypass reason is not initiated by the data reduction proxy, such |
| 69 // as HTTP errors. | 69 // as HTTP errors. |
| 70 void AddBypassTypeEvent(const net::BoundNetLog& net_log, | 70 void AddBypassTypeEvent(const net::NetLogWithSource& net_log, |
| 71 DataReductionProxyBypassType bypass_type, | 71 DataReductionProxyBypassType bypass_type, |
| 72 const std::string& request_method, | 72 const std::string& request_method, |
| 73 const GURL& gurl, | 73 const GURL& gurl, |
| 74 bool should_retry, | 74 bool should_retry, |
| 75 const base::TimeDelta& bypass_duration); | 75 const base::TimeDelta& bypass_duration); |
| 76 | 76 |
| 77 // Adds a DATA_REDUCTION_PROXY_FALLBACK event to the event store when there | 77 // Adds a DATA_REDUCTION_PROXY_FALLBACK event to the event store when there |
| 78 // is a network error in attempting to use a Data Reduction Proxy server. | 78 // is a network error in attempting to use a Data Reduction Proxy server. |
| 79 void AddProxyFallbackEvent(net::NetLog* net_log, | 79 void AddProxyFallbackEvent(net::NetLog* net_log, |
| 80 const std::string& proxy_url, | 80 const std::string& proxy_url, |
| 81 int net_error); | 81 int net_error); |
| 82 | 82 |
| 83 // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store | 83 // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store |
| 84 // when the secure proxy request has started. | 84 // when the secure proxy request has started. |
| 85 void BeginSecureProxyCheck(const net::BoundNetLog& net_log, const GURL& gurl); | 85 void BeginSecureProxyCheck(const net::NetLogWithSource& net_log, |
| 86 const GURL& gurl); |
| 86 | 87 |
| 87 // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store | 88 // Adds a DATA_REDUCTION_PROXY_CANARY_REQUEST event to the event store |
| 88 // when the secure proxy request has ended. | 89 // when the secure proxy request has ended. |
| 89 void EndSecureProxyCheck(const net::BoundNetLog& net_log, | 90 void EndSecureProxyCheck(const net::NetLogWithSource& net_log, |
| 90 int net_error, | 91 int net_error, |
| 91 int http_response_code, | 92 int http_response_code, |
| 92 bool succeeded); | 93 bool succeeded); |
| 93 | 94 |
| 94 // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store | 95 // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store |
| 95 // when the config request has started. | 96 // when the config request has started. |
| 96 void BeginConfigRequest(const net::BoundNetLog& net_log, const GURL& url); | 97 void BeginConfigRequest(const net::NetLogWithSource& net_log, |
| 98 const GURL& url); |
| 97 | 99 |
| 98 // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store | 100 // Adds a DATA_REDUCTION_PROXY_CONFIG_REQUEST event to the event store |
| 99 // when the config request has ended. | 101 // when the config request has ended. |
| 100 void EndConfigRequest(const net::BoundNetLog& net_log, | 102 void EndConfigRequest(const net::NetLogWithSource& net_log, |
| 101 int net_error, | 103 int net_error, |
| 102 int http_response_code, | 104 int http_response_code, |
| 103 int failure_count, | 105 int failure_count, |
| 104 const std::vector<net::ProxyServer>& proxies_for_http, | 106 const std::vector<net::ProxyServer>& proxies_for_http, |
| 105 const base::TimeDelta& refresh_duration, | 107 const base::TimeDelta& refresh_duration, |
| 106 const base::TimeDelta& retry_delay); | 108 const base::TimeDelta& retry_delay); |
| 107 | 109 |
| 108 private: | 110 private: |
| 109 // Prepare and post a generic Data Reduction Proxy event with no additional | 111 // Prepare and post a generic Data Reduction Proxy event with no additional |
| 110 // parameters. | 112 // parameters. |
| 111 void PostEvent(net::NetLog* net_log, | 113 void PostEvent(net::NetLog* net_log, |
| 112 net::NetLogEventType type, | 114 net::NetLogEventType type, |
| 113 const net::NetLog::ParametersCallback& callback); | 115 const net::NetLog::ParametersCallback& callback); |
| 114 | 116 |
| 115 // Prepare and post enabling/disabling proxy events for the event store on the | 117 // Prepare and post enabling/disabling proxy events for the event store on the |
| 116 // a net::NetLog. | 118 // a net::NetLog. |
| 117 void PostEnabledEvent(net::NetLog* net_log, | 119 void PostEnabledEvent(net::NetLog* net_log, |
| 118 net::NetLogEventType type, | 120 net::NetLogEventType type, |
| 119 bool enable, | 121 bool enable, |
| 120 const net::NetLog::ParametersCallback& callback); | 122 const net::NetLog::ParametersCallback& callback); |
| 121 | 123 |
| 122 // Prepare and post a Data Reduction Proxy bypass event for the event store | 124 // Prepare and post a Data Reduction Proxy bypass event for the event store |
| 123 // on a BoundNetLog. | 125 // on a NetLogWithSource. |
| 124 void PostBoundNetLogBypassEvent( | 126 void PostNetLogWithSourceBypassEvent( |
| 125 const net::BoundNetLog& net_log, | 127 const net::NetLogWithSource& net_log, |
| 126 net::NetLogEventType type, | 128 net::NetLogEventType type, |
| 127 net::NetLogEventPhase phase, | 129 net::NetLogEventPhase phase, |
| 128 int64_t expiration_ticks, | 130 int64_t expiration_ticks, |
| 129 const net::NetLog::ParametersCallback& callback); | 131 const net::NetLog::ParametersCallback& callback); |
| 130 | 132 |
| 131 // Prepare and post a secure proxy check event for the event store on a | 133 // Prepare and post a secure proxy check event for the event store on a |
| 132 // BoundNetLog. | 134 // NetLogWithSource. |
| 133 void PostBoundNetLogSecureProxyCheckEvent( | 135 void PostNetLogWithSourceSecureProxyCheckEvent( |
| 134 const net::BoundNetLog& net_log, | 136 const net::NetLogWithSource& net_log, |
| 135 net::NetLogEventType type, | 137 net::NetLogEventType type, |
| 136 net::NetLogEventPhase phase, | 138 net::NetLogEventPhase phase, |
| 137 DataReductionProxyEventStorageDelegate::SecureProxyCheckState state, | 139 DataReductionProxyEventStorageDelegate::SecureProxyCheckState state, |
| 138 const net::NetLog::ParametersCallback& callback); | 140 const net::NetLog::ParametersCallback& callback); |
| 139 | 141 |
| 140 // Prepare and post a config request event for the event store on a | 142 // Prepare and post a config request event for the event store on a |
| 141 // BoundNetLog. | 143 // NetLogWithSource. |
| 142 void PostBoundNetLogConfigRequestEvent( | 144 void PostNetLogWithSourceConfigRequestEvent( |
| 143 const net::BoundNetLog& net_log, | 145 const net::NetLogWithSource& net_log, |
| 144 net::NetLogEventType type, | 146 net::NetLogEventType type, |
| 145 net::NetLogEventPhase phase, | 147 net::NetLogEventPhase phase, |
| 146 const net::NetLog::ParametersCallback& callback); | 148 const net::NetLog::ParametersCallback& callback); |
| 147 | 149 |
| 148 // Must outlive |this|. Used for posting calls to the UI thread. | 150 // Must outlive |this|. Used for posting calls to the UI thread. |
| 149 DataReductionProxyEventStorageDelegate* storage_delegate_; | 151 DataReductionProxyEventStorageDelegate* storage_delegate_; |
| 150 | 152 |
| 151 // Enforce usage on the IO thread. | 153 // Enforce usage on the IO thread. |
| 152 base::ThreadChecker thread_checker_; | 154 base::ThreadChecker thread_checker_; |
| 153 | 155 |
| 154 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyEventCreator); | 156 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyEventCreator); |
| 155 }; | 157 }; |
| 156 | 158 |
| 157 } // namespace data_reduction_proxy | 159 } // namespace data_reduction_proxy |
| 158 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_EVEN
T_CREATOR_H_ | 160 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_COMMON_DATA_REDUCTION_PROXY_EVEN
T_CREATOR_H_ |
| OLD | NEW |