Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/page_load_metrics/observers/data_reduction_proxy_metrics_observer_unittest.cc

Issue 2857963002: Revert "[PageLoadMetrics] Keep track of Ad Sizes on Pages" (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
422 page_load_metrics::ExtraRequestCompleteInfo resource = { 421 page_load_metrics::ExtraRequestCompleteInfo resource = {
423 GURL(), 422 true /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
424 -1 /* frame_tree_node_id */, 423 0 /* original_network_content_length */, std::move(data),
425 true /*was_cached*/,
426 1024 * 40 /* raw_body_bytes */,
427 0 /* original_network_content_length */,
428 std::move(data),
429 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}; 424 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME};
430 425
431 RunTest(true, false); 426 RunTest(true, false);
432 SimulateLoadedResource(resource); 427 SimulateLoadedResource(resource);
433 NavigateToUntrackedUrl(); 428 NavigateToUntrackedUrl();
434 ValidateTimes(); 429 ValidateTimes();
435 ValidateLoFiInPingback(true); 430 ValidateLoFiInPingback(true);
436 431
437 ResetTest(); 432 ResetTest();
438 // Verify that when data reduction proxy was not used, SendPingback is not 433 // Verify that when data reduction proxy was not used, SendPingback is not
(...skipping 15 matching lines...) Expand all
454 449
455 RunTest(true, false); 450 RunTest(true, false);
456 451
457 std::unique_ptr<DataReductionProxyData> data = 452 std::unique_ptr<DataReductionProxyData> data =
458 base::MakeUnique<DataReductionProxyData>(); 453 base::MakeUnique<DataReductionProxyData>();
459 data->set_used_data_reduction_proxy(true); 454 data->set_used_data_reduction_proxy(true);
460 455
461 // Prepare 4 resources of varying size and configurations. 456 // Prepare 4 resources of varying size and configurations.
462 page_load_metrics::ExtraRequestCompleteInfo resources[] = { 457 page_load_metrics::ExtraRequestCompleteInfo resources[] = {
463 // Cached request. 458 // Cached request.
464 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, 459 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
465 1024 * 40 /* raw_body_bytes */, 0 /* original_network_content_length */, 460 0 /* original_network_content_length */,
466 nullptr /* data_reduction_proxy_data */, 461 nullptr /* data_reduction_proxy_data */,
467 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 462 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
468 // Uncached non-proxied request. 463 // Uncached non-proxied request.
469 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 464 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
470 1024 * 40 /* raw_body_bytes */,
471 1024 * 40 /* original_network_content_length */, 465 1024 * 40 /* original_network_content_length */,
472 nullptr /* data_reduction_proxy_data */, 466 nullptr /* data_reduction_proxy_data */,
473 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 467 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
474 // Uncached proxied request with .1 compression ratio. 468 // Uncached proxied request with .1 compression ratio.
475 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 469 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
476 1024 * 40 /* raw_body_bytes */,
477 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy(), 470 1024 * 40 * 10 /* original_network_content_length */, data->DeepCopy(),
478 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 471 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
479 // Uncached proxied request with .5 compression ratio. 472 // Uncached proxied request with .5 compression ratio.
480 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 473 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
481 1024 * 40 /* raw_body_bytes */,
482 1024 * 40 * 5 /* original_network_content_length */, std::move(data), 474 1024 * 40 * 5 /* original_network_content_length */, std::move(data),
483 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 475 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
484 }; 476 };
485 477
486 int network_resources = 0; 478 int network_resources = 0;
487 int drp_resources = 0; 479 int drp_resources = 0;
488 int64_t network_bytes = 0; 480 int64_t network_bytes = 0;
489 int64_t drp_bytes = 0; 481 int64_t drp_bytes = 0;
490 int64_t ocl_bytes = 0; 482 int64_t ocl_bytes = 0;
491 for (const auto& request : resources) { 483 for (const auto& request : resources) {
(...skipping 21 matching lines...) Expand all
513 505
514 RunTest(true, false); 506 RunTest(true, false);
515 507
516 std::unique_ptr<DataReductionProxyData> data = 508 std::unique_ptr<DataReductionProxyData> data =
517 base::MakeUnique<DataReductionProxyData>(); 509 base::MakeUnique<DataReductionProxyData>();
518 data->set_used_data_reduction_proxy(true); 510 data->set_used_data_reduction_proxy(true);
519 511
520 // Prepare 4 resources of varying size and configurations. 512 // Prepare 4 resources of varying size and configurations.
521 page_load_metrics::ExtraRequestCompleteInfo resources[] = { 513 page_load_metrics::ExtraRequestCompleteInfo resources[] = {
522 // Cached request. 514 // Cached request.
523 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, 515 {true /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
524 1024 * 40 /* raw_body_bytes */, 0 /* original_network_content_length */, 516 0 /* original_network_content_length */,
525 nullptr /* data_reduction_proxy_data */, 517 nullptr /* data_reduction_proxy_data */,
526 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 518 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
527 // Uncached non-proxied request. 519 // Uncached non-proxied request.
528 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 520 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
529 1024 * 40 /* raw_body_bytes */,
530 1024 * 40 /* original_network_content_length */, 521 1024 * 40 /* original_network_content_length */,
531 nullptr /* data_reduction_proxy_data */, 522 nullptr /* data_reduction_proxy_data */,
532 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 523 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
533 // Uncached proxied request with .1 compression ratio. 524 // Uncached proxied request with .1 compression ratio.
534 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 525 {false /*was_cached*/, 1024 * 40 * 10 /* raw_body_bytes */,
535 1024 * 40 * 10 /* raw_body_bytes */,
536 1024 * 40 /* original_network_content_length */, data->DeepCopy(), 526 1024 * 40 /* original_network_content_length */, data->DeepCopy(),
537 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 527 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
538 // Uncached proxied request with .5 compression ratio. 528 // Uncached proxied request with .5 compression ratio.
539 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, 529 {false /*was_cached*/, 1024 * 40 * 5 /* raw_body_bytes */,
540 1024 * 40 * 5 /* raw_body_bytes */,
541 1024 * 40 /* original_network_content_length */, std::move(data), 530 1024 * 40 /* original_network_content_length */, std::move(data),
542 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, 531 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME},
543 }; 532 };
544 533
545 int network_resources = 0; 534 int network_resources = 0;
546 int drp_resources = 0; 535 int drp_resources = 0;
547 int64_t network_bytes = 0; 536 int64_t network_bytes = 0;
548 int64_t drp_bytes = 0; 537 int64_t drp_bytes = 0;
549 int64_t ocl_bytes = 0; 538 int64_t ocl_bytes = 0;
550 for (const auto& request : resources) { 539 for (const auto& request : resources) {
(...skipping 10 matching lines...) Expand all
561 } 550 }
562 } 551 }
563 552
564 NavigateToUntrackedUrl(); 553 NavigateToUntrackedUrl();
565 554
566 ValidateDataHistograms(network_resources, drp_resources, network_bytes, 555 ValidateDataHistograms(network_resources, drp_resources, network_bytes,
567 drp_bytes, ocl_bytes); 556 drp_bytes, ocl_bytes);
568 } 557 }
569 558
570 } // namespace data_reduction_proxy 559 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698