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

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

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: moved definition up Created 3 years, 8 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 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 "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h" 5 #include "chrome/browser/page_load_metrics/observers/core_page_load_metrics_obse rver.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h" 8 #include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_ test_harness.h"
9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
10 #include "chrome/test/base/testing_browser_process.h" 10 #include "chrome/test/base/testing_browser_process.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); 406 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10);
407 PopulateRequiredTimingFields(&timing); 407 PopulateRequiredTimingFields(&timing);
408 408
409 GURL url(kDefaultTestUrl); 409 GURL url(kDefaultTestUrl);
410 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD); 410 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD);
411 SimulateTimingUpdate(timing); 411 SimulateTimingUpdate(timing);
412 412
413 page_load_metrics::ExtraRequestInfo resources[] = { 413 page_load_metrics::ExtraRequestInfo resources[] = {
414 // Cached request. 414 // Cached request.
415 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, 415 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */,
416 false /* data_reduction_proxy_used*/, 416 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
bengr 2017/04/20 17:36:18 Nit: Remove the extra space in the comments here a
RyanSturm 2017/04/20 20:25:44 Acknowledged.
417 0 /* original_network_content_length */}, 417 0 /* original_network_content_length */},
418 // Uncached non-proxied request. 418 // Uncached non-proxied request.
419 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 419 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
420 false /* data_reduction_proxy_used*/, 420 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
bengr 2017/04/20 17:36:18 Why are there no core page load metrics observer t
RyanSturm 2017/04/20 20:25:44 These are unused in most observers. I switched to
421 1024 * 40 /* original_network_content_length */}, 421 1024 * 40 /* original_network_content_length */},
422 }; 422 };
423 423
424 int64_t network_bytes = 0; 424 int64_t network_bytes = 0;
425 int64_t cache_bytes = 0; 425 int64_t cache_bytes = 0;
426 for (const auto& request : resources) { 426 for (const auto& request : resources) {
427 SimulateLoadedResource(request); 427 SimulateLoadedResource(request);
428 if (!request.was_cached) { 428 if (!request.was_cached) {
429 network_bytes += request.raw_body_bytes; 429 network_bytes += request.raw_body_bytes;
430 } else { 430 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // modifier. This test verifies that when we encounter such a page, we log it 491 // modifier. This test verifies that when we encounter such a page, we log it
492 // as a forward/back navigation. 492 // as a forward/back navigation.
493 NavigateWithPageTransitionAndCommit( 493 NavigateWithPageTransitionAndCommit(
494 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | 494 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD |
495 ui::PAGE_TRANSITION_FORWARD_BACK)); 495 ui::PAGE_TRANSITION_FORWARD_BACK));
496 SimulateTimingUpdate(timing); 496 SimulateTimingUpdate(timing);
497 497
498 page_load_metrics::ExtraRequestInfo resources[] = { 498 page_load_metrics::ExtraRequestInfo resources[] = {
499 // Cached request. 499 // Cached request.
500 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, 500 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */,
501 false /* data_reduction_proxy_used*/, 501 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
502 0 /* original_network_content_length */}, 502 0 /* original_network_content_length */},
503 // Uncached non-proxied request. 503 // Uncached non-proxied request.
504 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 504 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
505 false /* data_reduction_proxy_used*/, 505 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
506 1024 * 40 /* original_network_content_length */}, 506 1024 * 40 /* original_network_content_length */},
507 }; 507 };
508 508
509 int64_t network_bytes = 0; 509 int64_t network_bytes = 0;
510 int64_t cache_bytes = 0; 510 int64_t cache_bytes = 0;
511 for (const auto& request : resources) { 511 for (const auto& request : resources) {
512 SimulateLoadedResource(request); 512 SimulateLoadedResource(request);
513 if (!request.was_cached) { 513 if (!request.was_cached) {
514 network_bytes += request.raw_body_bytes; 514 network_bytes += request.raw_body_bytes;
515 } else { 515 } else {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); 570 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10);
571 PopulateRequiredTimingFields(&timing); 571 PopulateRequiredTimingFields(&timing);
572 572
573 GURL url(kDefaultTestUrl); 573 GURL url(kDefaultTestUrl);
574 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); 574 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK);
575 SimulateTimingUpdate(timing); 575 SimulateTimingUpdate(timing);
576 576
577 page_load_metrics::ExtraRequestInfo resources[] = { 577 page_load_metrics::ExtraRequestInfo resources[] = {
578 // Cached request. 578 // Cached request.
579 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, 579 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */,
580 false /* data_reduction_proxy_used*/, 580 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
581 0 /* original_network_content_length */}, 581 0 /* original_network_content_length */},
582 // Uncached non-proxied request. 582 // Uncached non-proxied request.
583 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, 583 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */,
584 false /* data_reduction_proxy_used*/, 584 false /* data_reduction_proxy_used*/, false /* was_lofi_response */,
585 1024 * 40 /* original_network_content_length */}, 585 1024 * 40 /* original_network_content_length */},
586 }; 586 };
587 587
588 int64_t network_bytes = 0; 588 int64_t network_bytes = 0;
589 int64_t cache_bytes = 0; 589 int64_t cache_bytes = 0;
590 for (auto request : resources) { 590 for (auto request : resources) {
591 SimulateLoadedResource(request); 591 SimulateLoadedResource(request);
592 if (!request.was_cached) { 592 if (!request.was_cached) {
593 network_bytes += request.raw_body_bytes; 593 network_bytes += request.raw_body_bytes;
594 } else { 594 } else {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 NavigateAndCommit(GURL(kDefaultTestUrl2)); 698 NavigateAndCommit(GURL(kDefaultTestUrl2));
699 699
700 histogram_tester().ExpectTotalCount( 700 histogram_tester().ExpectTotalCount(
701 internal::kHistogramFirstMeaningfulPaint, 0); 701 internal::kHistogramFirstMeaningfulPaint, 0);
702 histogram_tester().ExpectTotalCount( 702 histogram_tester().ExpectTotalCount(
703 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); 703 internal::kHistogramParseStartToFirstMeaningfulPaint, 0);
704 histogram_tester().ExpectBucketCount( 704 histogram_tester().ExpectBucketCount(
705 internal::kHistogramFirstMeaningfulPaintStatus, 705 internal::kHistogramFirstMeaningfulPaintStatus,
706 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); 706 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1);
707 } 707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698