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 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_creator.h" | 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_creator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void DataReductionProxyEventCreator::AddProxyDisabledEvent( | 185 void DataReductionProxyEventCreator::AddProxyDisabledEvent( |
186 net::NetLog* net_log) { | 186 net::NetLog* net_log) { |
187 DCHECK(thread_checker_.CalledOnValidThread()); | 187 DCHECK(thread_checker_.CalledOnValidThread()); |
188 const net::NetLog::ParametersCallback& parameters_callback = | 188 const net::NetLog::ParametersCallback& parameters_callback = |
189 base::Bind(&DisableDataReductionProxyCallback); | 189 base::Bind(&DisableDataReductionProxyCallback); |
190 PostEnabledEvent(net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_ENABLED, | 190 PostEnabledEvent(net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_ENABLED, |
191 false, parameters_callback); | 191 false, parameters_callback); |
192 } | 192 } |
193 | 193 |
194 void DataReductionProxyEventCreator::AddBypassActionEvent( | 194 void DataReductionProxyEventCreator::AddBypassActionEvent( |
195 const net::BoundNetLog& net_log, | 195 const net::NetLogWithSource& net_log, |
196 DataReductionProxyBypassAction bypass_action, | 196 DataReductionProxyBypassAction bypass_action, |
197 const std::string& request_method, | 197 const std::string& request_method, |
198 const GURL& url, | 198 const GURL& url, |
199 bool should_retry, | 199 bool should_retry, |
200 const base::TimeDelta& bypass_duration) { | 200 const base::TimeDelta& bypass_duration) { |
201 DCHECK(thread_checker_.CalledOnValidThread()); | 201 DCHECK(thread_checker_.CalledOnValidThread()); |
202 int64_t expiration_ticks = GetExpirationTicks(bypass_duration.InSeconds()); | 202 int64_t expiration_ticks = GetExpirationTicks(bypass_duration.InSeconds()); |
203 const net::NetLog::ParametersCallback& parameters_callback = | 203 const net::NetLog::ParametersCallback& parameters_callback = |
204 base::Bind(&UrlBypassActionCallback, bypass_action, request_method, url, | 204 base::Bind(&UrlBypassActionCallback, bypass_action, request_method, url, |
205 should_retry, bypass_duration.InSeconds(), expiration_ticks); | 205 should_retry, bypass_duration.InSeconds(), expiration_ticks); |
206 PostBoundNetLogBypassEvent( | 206 PostNetLogWithSourceBypassEvent( |
207 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_BYPASS_REQUESTED, | 207 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_BYPASS_REQUESTED, |
208 net::NetLogEventPhase::NONE, expiration_ticks, parameters_callback); | 208 net::NetLogEventPhase::NONE, expiration_ticks, parameters_callback); |
209 } | 209 } |
210 | 210 |
211 void DataReductionProxyEventCreator::AddBypassTypeEvent( | 211 void DataReductionProxyEventCreator::AddBypassTypeEvent( |
212 const net::BoundNetLog& net_log, | 212 const net::NetLogWithSource& net_log, |
213 DataReductionProxyBypassType bypass_type, | 213 DataReductionProxyBypassType bypass_type, |
214 const std::string& request_method, | 214 const std::string& request_method, |
215 const GURL& url, | 215 const GURL& url, |
216 bool should_retry, | 216 bool should_retry, |
217 const base::TimeDelta& bypass_duration) { | 217 const base::TimeDelta& bypass_duration) { |
218 DCHECK(thread_checker_.CalledOnValidThread()); | 218 DCHECK(thread_checker_.CalledOnValidThread()); |
219 int64_t expiration_ticks = GetExpirationTicks(bypass_duration.InSeconds()); | 219 int64_t expiration_ticks = GetExpirationTicks(bypass_duration.InSeconds()); |
220 const net::NetLog::ParametersCallback& parameters_callback = | 220 const net::NetLog::ParametersCallback& parameters_callback = |
221 base::Bind(&UrlBypassTypeCallback, bypass_type, request_method, url, | 221 base::Bind(&UrlBypassTypeCallback, bypass_type, request_method, url, |
222 should_retry, bypass_duration.InSeconds(), expiration_ticks); | 222 should_retry, bypass_duration.InSeconds(), expiration_ticks); |
223 PostBoundNetLogBypassEvent( | 223 PostNetLogWithSourceBypassEvent( |
224 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_BYPASS_REQUESTED, | 224 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_BYPASS_REQUESTED, |
225 net::NetLogEventPhase::NONE, expiration_ticks, parameters_callback); | 225 net::NetLogEventPhase::NONE, expiration_ticks, parameters_callback); |
226 } | 226 } |
227 | 227 |
228 void DataReductionProxyEventCreator::AddProxyFallbackEvent( | 228 void DataReductionProxyEventCreator::AddProxyFallbackEvent( |
229 net::NetLog* net_log, | 229 net::NetLog* net_log, |
230 const std::string& proxy_url, | 230 const std::string& proxy_url, |
231 int net_error) { | 231 int net_error) { |
232 DCHECK(thread_checker_.CalledOnValidThread()); | 232 DCHECK(thread_checker_.CalledOnValidThread()); |
233 const net::NetLog::ParametersCallback& parameters_callback = | 233 const net::NetLog::ParametersCallback& parameters_callback = |
234 base::Bind(&FallbackCallback, proxy_url, net_error); | 234 base::Bind(&FallbackCallback, proxy_url, net_error); |
235 PostEvent(net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_FALLBACK, | 235 PostEvent(net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_FALLBACK, |
236 parameters_callback); | 236 parameters_callback); |
237 } | 237 } |
238 | 238 |
239 void DataReductionProxyEventCreator::BeginSecureProxyCheck( | 239 void DataReductionProxyEventCreator::BeginSecureProxyCheck( |
240 const net::BoundNetLog& net_log, | 240 const net::NetLogWithSource& net_log, |
241 const GURL& url) { | 241 const GURL& url) { |
242 DCHECK(thread_checker_.CalledOnValidThread()); | 242 DCHECK(thread_checker_.CalledOnValidThread()); |
243 // This callback must be invoked synchronously | 243 // This callback must be invoked synchronously |
244 const net::NetLog::ParametersCallback& parameters_callback = | 244 const net::NetLog::ParametersCallback& parameters_callback = |
245 net::NetLog::StringCallback("url", &url.spec()); | 245 net::NetLog::StringCallback("url", &url.spec()); |
246 PostBoundNetLogSecureProxyCheckEvent( | 246 PostNetLogWithSourceSecureProxyCheckEvent( |
247 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CANARY_REQUEST, | 247 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CANARY_REQUEST, |
248 net::NetLogEventPhase::BEGIN, | 248 net::NetLogEventPhase::BEGIN, |
249 DataReductionProxyEventStorageDelegate::CHECK_PENDING, | 249 DataReductionProxyEventStorageDelegate::CHECK_PENDING, |
250 parameters_callback); | 250 parameters_callback); |
251 } | 251 } |
252 | 252 |
253 void DataReductionProxyEventCreator::EndSecureProxyCheck( | 253 void DataReductionProxyEventCreator::EndSecureProxyCheck( |
254 const net::BoundNetLog& net_log, | 254 const net::NetLogWithSource& net_log, |
255 int net_error, | 255 int net_error, |
256 int http_response_code, | 256 int http_response_code, |
257 bool succeeded) { | 257 bool succeeded) { |
258 DCHECK(thread_checker_.CalledOnValidThread()); | 258 DCHECK(thread_checker_.CalledOnValidThread()); |
259 const net::NetLog::ParametersCallback& parameters_callback = base::Bind( | 259 const net::NetLog::ParametersCallback& parameters_callback = base::Bind( |
260 &EndCanaryRequestCallback, net_error, http_response_code, succeeded); | 260 &EndCanaryRequestCallback, net_error, http_response_code, succeeded); |
261 PostBoundNetLogSecureProxyCheckEvent( | 261 PostNetLogWithSourceSecureProxyCheckEvent( |
262 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CANARY_REQUEST, | 262 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CANARY_REQUEST, |
263 net::NetLogEventPhase::END, | 263 net::NetLogEventPhase::END, |
264 succeeded ? DataReductionProxyEventStorageDelegate::CHECK_SUCCESS | 264 succeeded ? DataReductionProxyEventStorageDelegate::CHECK_SUCCESS |
265 : DataReductionProxyEventStorageDelegate::CHECK_FAILED, | 265 : DataReductionProxyEventStorageDelegate::CHECK_FAILED, |
266 parameters_callback); | 266 parameters_callback); |
267 } | 267 } |
268 | 268 |
269 void DataReductionProxyEventCreator::BeginConfigRequest( | 269 void DataReductionProxyEventCreator::BeginConfigRequest( |
270 const net::BoundNetLog& net_log, | 270 const net::NetLogWithSource& net_log, |
271 const GURL& url) { | 271 const GURL& url) { |
272 // This callback must be invoked synchronously. | 272 // This callback must be invoked synchronously. |
273 const net::NetLog::ParametersCallback& parameters_callback = | 273 const net::NetLog::ParametersCallback& parameters_callback = |
274 net::NetLog::StringCallback("url", &url.spec()); | 274 net::NetLog::StringCallback("url", &url.spec()); |
275 PostBoundNetLogConfigRequestEvent( | 275 PostNetLogWithSourceConfigRequestEvent( |
276 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CONFIG_REQUEST, | 276 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CONFIG_REQUEST, |
277 net::NetLogEventPhase::BEGIN, parameters_callback); | 277 net::NetLogEventPhase::BEGIN, parameters_callback); |
278 } | 278 } |
279 | 279 |
280 void DataReductionProxyEventCreator::EndConfigRequest( | 280 void DataReductionProxyEventCreator::EndConfigRequest( |
281 const net::BoundNetLog& net_log, | 281 const net::NetLogWithSource& net_log, |
282 int net_error, | 282 int net_error, |
283 int http_response_code, | 283 int http_response_code, |
284 int failure_count, | 284 int failure_count, |
285 const std::vector<net::ProxyServer>& proxies_for_http, | 285 const std::vector<net::ProxyServer>& proxies_for_http, |
286 const base::TimeDelta& refresh_duration, | 286 const base::TimeDelta& refresh_duration, |
287 const base::TimeDelta& retry_delay) { | 287 const base::TimeDelta& retry_delay) { |
288 int64_t refresh_duration_minutes = refresh_duration.InMinutes(); | 288 int64_t refresh_duration_minutes = refresh_duration.InMinutes(); |
289 int64_t expiration_ticks = GetExpirationTicks(retry_delay.InSeconds()); | 289 int64_t expiration_ticks = GetExpirationTicks(retry_delay.InSeconds()); |
290 const net::NetLog::ParametersCallback& parameters_callback = base::Bind( | 290 const net::NetLog::ParametersCallback& parameters_callback = base::Bind( |
291 &EndConfigRequestCallback, net_error, http_response_code, failure_count, | 291 &EndConfigRequestCallback, net_error, http_response_code, failure_count, |
292 proxies_for_http, refresh_duration_minutes, expiration_ticks); | 292 proxies_for_http, refresh_duration_minutes, expiration_ticks); |
293 PostBoundNetLogConfigRequestEvent( | 293 PostNetLogWithSourceConfigRequestEvent( |
294 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CONFIG_REQUEST, | 294 net_log, net::NetLogEventType::DATA_REDUCTION_PROXY_CONFIG_REQUEST, |
295 net::NetLogEventPhase::END, parameters_callback); | 295 net::NetLogEventPhase::END, parameters_callback); |
296 } | 296 } |
297 | 297 |
298 void DataReductionProxyEventCreator::PostEvent( | 298 void DataReductionProxyEventCreator::PostEvent( |
299 net::NetLog* net_log, | 299 net::NetLog* net_log, |
300 net::NetLogEventType type, | 300 net::NetLogEventType type, |
301 const net::NetLog::ParametersCallback& callback) { | 301 const net::NetLog::ParametersCallback& callback) { |
302 std::unique_ptr<base::Value> event = BuildDataReductionProxyEvent( | 302 std::unique_ptr<base::Value> event = BuildDataReductionProxyEvent( |
303 type, net::NetLog::Source(), net::NetLogEventPhase::NONE, callback); | 303 type, net::NetLog::Source(), net::NetLogEventPhase::NONE, callback); |
(...skipping 11 matching lines...) Expand all Loading... |
315 const net::NetLog::ParametersCallback& callback) { | 315 const net::NetLog::ParametersCallback& callback) { |
316 std::unique_ptr<base::Value> event = BuildDataReductionProxyEvent( | 316 std::unique_ptr<base::Value> event = BuildDataReductionProxyEvent( |
317 type, net::NetLog::Source(), net::NetLogEventPhase::NONE, callback); | 317 type, net::NetLog::Source(), net::NetLogEventPhase::NONE, callback); |
318 if (event) | 318 if (event) |
319 storage_delegate_->AddEnabledEvent(std::move(event), enabled); | 319 storage_delegate_->AddEnabledEvent(std::move(event), enabled); |
320 | 320 |
321 if (net_log) | 321 if (net_log) |
322 net_log->AddGlobalEntry(type, callback); | 322 net_log->AddGlobalEntry(type, callback); |
323 } | 323 } |
324 | 324 |
325 void DataReductionProxyEventCreator::PostBoundNetLogBypassEvent( | 325 void DataReductionProxyEventCreator::PostNetLogWithSourceBypassEvent( |
326 const net::BoundNetLog& net_log, | 326 const net::NetLogWithSource& net_log, |
327 net::NetLogEventType type, | 327 net::NetLogEventType type, |
328 net::NetLogEventPhase phase, | 328 net::NetLogEventPhase phase, |
329 int64_t expiration_ticks, | 329 int64_t expiration_ticks, |
330 const net::NetLog::ParametersCallback& callback) { | 330 const net::NetLog::ParametersCallback& callback) { |
331 std::unique_ptr<base::Value> event = | 331 std::unique_ptr<base::Value> event = |
332 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback); | 332 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback); |
333 if (event) | 333 if (event) |
334 storage_delegate_->AddAndSetLastBypassEvent(std::move(event), | 334 storage_delegate_->AddAndSetLastBypassEvent(std::move(event), |
335 expiration_ticks); | 335 expiration_ticks); |
336 net_log.AddEntry(type, phase, callback); | 336 net_log.AddEntry(type, phase, callback); |
337 } | 337 } |
338 | 338 |
339 void DataReductionProxyEventCreator::PostBoundNetLogSecureProxyCheckEvent( | 339 void DataReductionProxyEventCreator::PostNetLogWithSourceSecureProxyCheckEvent( |
340 const net::BoundNetLog& net_log, | 340 const net::NetLogWithSource& net_log, |
341 net::NetLogEventType type, | 341 net::NetLogEventType type, |
342 net::NetLogEventPhase phase, | 342 net::NetLogEventPhase phase, |
343 DataReductionProxyEventStorageDelegate::SecureProxyCheckState state, | 343 DataReductionProxyEventStorageDelegate::SecureProxyCheckState state, |
344 const net::NetLog::ParametersCallback& callback) { | 344 const net::NetLog::ParametersCallback& callback) { |
345 std::unique_ptr<base::Value> event( | 345 std::unique_ptr<base::Value> event( |
346 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback)); | 346 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback)); |
347 if (event) | 347 if (event) |
348 storage_delegate_->AddEventAndSecureProxyCheckState(std::move(event), | 348 storage_delegate_->AddEventAndSecureProxyCheckState(std::move(event), |
349 state); | 349 state); |
350 net_log.AddEntry(type, phase, callback); | 350 net_log.AddEntry(type, phase, callback); |
351 } | 351 } |
352 | 352 |
353 void DataReductionProxyEventCreator::PostBoundNetLogConfigRequestEvent( | 353 void DataReductionProxyEventCreator::PostNetLogWithSourceConfigRequestEvent( |
354 const net::BoundNetLog& net_log, | 354 const net::NetLogWithSource& net_log, |
355 net::NetLogEventType type, | 355 net::NetLogEventType type, |
356 net::NetLogEventPhase phase, | 356 net::NetLogEventPhase phase, |
357 const net::NetLog::ParametersCallback& callback) { | 357 const net::NetLog::ParametersCallback& callback) { |
358 std::unique_ptr<base::Value> event( | 358 std::unique_ptr<base::Value> event( |
359 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback)); | 359 BuildDataReductionProxyEvent(type, net_log.source(), phase, callback)); |
360 if (event) { | 360 if (event) { |
361 storage_delegate_->AddEvent(std::move(event)); | 361 storage_delegate_->AddEvent(std::move(event)); |
362 net_log.AddEntry(type, phase, callback); | 362 net_log.AddEntry(type, phase, callback); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 } // namespace data_reduction_proxy | 366 } // namespace data_reduction_proxy |
OLD | NEW |