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 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/data_reduction_proxy_metric
s_observer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <functional> | 9 #include <functional> |
10 #include <memory> | 10 #include <memory> |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 ValidateLoFiInPingback(false); | 411 ValidateLoFiInPingback(false); |
412 | 412 |
413 ResetTest(); | 413 ResetTest(); |
414 | 414 |
415 std::unique_ptr<DataReductionProxyData> data = | 415 std::unique_ptr<DataReductionProxyData> data = |
416 base::MakeUnique<DataReductionProxyData>(); | 416 base::MakeUnique<DataReductionProxyData>(); |
417 data->set_used_data_reduction_proxy(true); | 417 data->set_used_data_reduction_proxy(true); |
418 data->set_lofi_received(true); | 418 data->set_lofi_received(true); |
419 | 419 |
420 // Verify LoFi is tracked when a LoFi response is received. | 420 // Verify LoFi is tracked when a LoFi response is received. |
| 421 |
421 page_load_metrics::ExtraRequestCompleteInfo resource = { | 422 page_load_metrics::ExtraRequestCompleteInfo resource = { |
422 true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 423 GURL(), |
423 0 /* original_network_content_length */, std::move(data), | 424 -1 /* frame_tree_node_id */, |
| 425 true /*was_cached*/, |
| 426 1024 * 40 /* raw_body_bytes */, |
| 427 0 /* original_network_content_length */, |
| 428 std::move(data), |
424 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}; | 429 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}; |
425 | 430 |
426 RunTest(true, false); | 431 RunTest(true, false); |
427 SimulateLoadedResource(resource); | 432 SimulateLoadedResource(resource); |
428 NavigateToUntrackedUrl(); | 433 NavigateToUntrackedUrl(); |
429 ValidateTimes(); | 434 ValidateTimes(); |
430 ValidateLoFiInPingback(true); | 435 ValidateLoFiInPingback(true); |
431 | 436 |
432 ResetTest(); | 437 ResetTest(); |
433 // Verify that when data reduction proxy was not used, SendPingback is not | 438 // Verify that when data reduction proxy was not used, SendPingback is not |
(...skipping 15 matching lines...) Expand all Loading... |
449 | 454 |
450 RunTest(true, false); | 455 RunTest(true, false); |
451 | 456 |
452 std::unique_ptr<DataReductionProxyData> data = | 457 std::unique_ptr<DataReductionProxyData> data = |
453 base::MakeUnique<DataReductionProxyData>(); | 458 base::MakeUnique<DataReductionProxyData>(); |
454 data->set_used_data_reduction_proxy(true); | 459 data->set_used_data_reduction_proxy(true); |
455 | 460 |
456 // Prepare 4 resources of varying size and configurations. | 461 // Prepare 4 resources of varying size and configurations. |
457 page_load_metrics::ExtraRequestCompleteInfo resources[] = { | 462 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
458 // Cached request. | 463 // Cached request. |
459 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 464 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
460 0 /* original_network_content_length */, | 465 1024 * 40 /* raw_body_bytes */, 0 /* original_network_content_length */, |
461 nullptr /* data_reduction_proxy_data */, | 466 nullptr /* data_reduction_proxy_data */, |
462 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 467 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
463 // Uncached non-proxied request. | 468 // Uncached non-proxied request. |
464 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 469 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 470 1024 * 40 /* raw_body_bytes */, |
465 1024 * 40 /* original_network_content_length */, | 471 1024 * 40 /* original_network_content_length */, |
466 nullptr /* data_reduction_proxy_data */, | 472 nullptr /* data_reduction_proxy_data */, |
467 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 473 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
468 // Uncached proxied request with .1 compression ratio. | 474 // Uncached proxied request with .1 compression ratio. |
469 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 475 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 476 1024 * 40 /* raw_body_bytes */, |
470 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy(), | 477 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy(), |
471 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 478 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
472 // Uncached proxied request with .5 compression ratio. | 479 // Uncached proxied request with .5 compression ratio. |
473 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 480 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 481 1024 * 40 /* raw_body_bytes */, |
474 1024 * 40 * 5 /* original_network_content_length */, std::move(data), | 482 1024 * 40 * 5 /* original_network_content_length */, std::move(data), |
475 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 483 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
476 }; | 484 }; |
477 | 485 |
478 int network_resources = 0; | 486 int network_resources = 0; |
479 int drp_resources = 0; | 487 int drp_resources = 0; |
480 int64_t network_bytes = 0; | 488 int64_t network_bytes = 0; |
481 int64_t drp_bytes = 0; | 489 int64_t drp_bytes = 0; |
482 int64_t ocl_bytes = 0; | 490 int64_t ocl_bytes = 0; |
483 for (const auto& request : resources) { | 491 for (const auto& request : resources) { |
(...skipping 21 matching lines...) Expand all Loading... |
505 | 513 |
506 RunTest(true, false); | 514 RunTest(true, false); |
507 | 515 |
508 std::unique_ptr<DataReductionProxyData> data = | 516 std::unique_ptr<DataReductionProxyData> data = |
509 base::MakeUnique<DataReductionProxyData>(); | 517 base::MakeUnique<DataReductionProxyData>(); |
510 data->set_used_data_reduction_proxy(true); | 518 data->set_used_data_reduction_proxy(true); |
511 | 519 |
512 // Prepare 4 resources of varying size and configurations. | 520 // Prepare 4 resources of varying size and configurations. |
513 page_load_metrics::ExtraRequestCompleteInfo resources[] = { | 521 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
514 // Cached request. | 522 // Cached request. |
515 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 523 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
516 0 /* original_network_content_length */, | 524 1024 * 40 /* raw_body_bytes */, 0 /* original_network_content_length */, |
517 nullptr /* data_reduction_proxy_data */, | 525 nullptr /* data_reduction_proxy_data */, |
518 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 526 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
519 // Uncached non-proxied request. | 527 // Uncached non-proxied request. |
520 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 528 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 529 1024 * 40 /* raw_body_bytes */, |
521 1024 * 40 /* original_network_content_length */, | 530 1024 * 40 /* original_network_content_length */, |
522 nullptr /* data_reduction_proxy_data */, | 531 nullptr /* data_reduction_proxy_data */, |
523 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 532 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
524 // Uncached proxied request with .1 compression ratio. | 533 // Uncached proxied request with .1 compression ratio. |
525 {false /*was_cached*/, 1024 * 40 * 10 /* raw_body_bytes */, | 534 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 535 1024 * 40 * 10 /* raw_body_bytes */, |
526 1024 * 40 /* original_network_content_length */, data->DeepCopy(), | 536 1024 * 40 /* original_network_content_length */, data->DeepCopy(), |
527 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 537 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
528 // Uncached proxied request with .5 compression ratio. | 538 // Uncached proxied request with .5 compression ratio. |
529 {false /*was_cached*/, 1024 * 40 * 5 /* raw_body_bytes */, | 539 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 540 1024 * 40 * 5 /* raw_body_bytes */, |
530 1024 * 40 /* original_network_content_length */, std::move(data), | 541 1024 * 40 /* original_network_content_length */, std::move(data), |
531 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 542 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
532 }; | 543 }; |
533 | 544 |
534 int network_resources = 0; | 545 int network_resources = 0; |
535 int drp_resources = 0; | 546 int drp_resources = 0; |
536 int64_t network_bytes = 0; | 547 int64_t network_bytes = 0; |
537 int64_t drp_bytes = 0; | 548 int64_t drp_bytes = 0; |
538 int64_t ocl_bytes = 0; | 549 int64_t ocl_bytes = 0; |
539 for (const auto& request : resources) { | 550 for (const auto& request : resources) { |
(...skipping 10 matching lines...) Expand all Loading... |
550 } | 561 } |
551 } | 562 } |
552 | 563 |
553 NavigateToUntrackedUrl(); | 564 NavigateToUntrackedUrl(); |
554 | 565 |
555 ValidateDataHistograms(network_resources, drp_resources, network_bytes, | 566 ValidateDataHistograms(network_resources, drp_resources, network_bytes, |
556 drp_bytes, ocl_bytes); | 567 drp_bytes, ocl_bytes); |
557 } | 568 } |
558 | 569 |
559 } // namespace data_reduction_proxy | 570 } // namespace data_reduction_proxy |
OLD | NEW |