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 "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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 timing.parse_start = base::TimeDelta::FromMilliseconds(5); | 404 timing.parse_start = base::TimeDelta::FromMilliseconds(5); |
405 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); | 405 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); |
406 PopulateRequiredTimingFields(&timing); | 406 PopulateRequiredTimingFields(&timing); |
407 | 407 |
408 GURL url(kDefaultTestUrl); | 408 GURL url(kDefaultTestUrl); |
409 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD); | 409 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD); |
410 SimulateTimingUpdate(timing); | 410 SimulateTimingUpdate(timing); |
411 | 411 |
412 page_load_metrics::ExtraRequestInfo resources[] = { | 412 page_load_metrics::ExtraRequestInfo resources[] = { |
413 // Cached request. | 413 // Cached request. |
414 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 414 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
415 false /* data_reduction_proxy_used*/, | 415 1024 * 20 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
416 0 /* original_network_content_length */}, | 416 0 /* original_network_content_length */}, |
417 // Uncached non-proxied request. | 417 // Uncached non-proxied request. |
418 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 418 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
419 false /* data_reduction_proxy_used*/, | 419 1024 * 40 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
420 1024 * 40 /* original_network_content_length */}, | 420 1024 * 40 /* original_network_content_length */}, |
421 }; | 421 }; |
422 | 422 |
423 int64_t network_bytes = 0; | 423 int64_t network_bytes = 0; |
424 int64_t cache_bytes = 0; | 424 int64_t cache_bytes = 0; |
425 for (const auto& request : resources) { | 425 for (const auto& request : resources) { |
426 SimulateLoadedResource(request); | 426 SimulateLoadedResource(request); |
427 if (!request.was_cached) { | 427 if (!request.was_cached) { |
428 network_bytes += request.raw_body_bytes; | 428 network_bytes += request.raw_body_bytes; |
429 } else { | 429 } else { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK | 489 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK |
490 // modifier. This test verifies that when we encounter such a page, we log it | 490 // modifier. This test verifies that when we encounter such a page, we log it |
491 // as a forward/back navigation. | 491 // as a forward/back navigation. |
492 NavigateWithPageTransitionAndCommit( | 492 NavigateWithPageTransitionAndCommit( |
493 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | | 493 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | |
494 ui::PAGE_TRANSITION_FORWARD_BACK)); | 494 ui::PAGE_TRANSITION_FORWARD_BACK)); |
495 SimulateTimingUpdate(timing); | 495 SimulateTimingUpdate(timing); |
496 | 496 |
497 page_load_metrics::ExtraRequestInfo resources[] = { | 497 page_load_metrics::ExtraRequestInfo resources[] = { |
498 // Cached request. | 498 // Cached request. |
499 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 499 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
500 false /* data_reduction_proxy_used*/, | 500 1024 * 20 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
501 0 /* original_network_content_length */}, | 501 0 /* original_network_content_length */}, |
502 // Uncached non-proxied request. | 502 // Uncached non-proxied request. |
503 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 503 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
504 false /* data_reduction_proxy_used*/, | 504 1024 * 40 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
505 1024 * 40 /* original_network_content_length */}, | 505 1024 * 40 /* original_network_content_length */}, |
506 }; | 506 }; |
507 | 507 |
508 int64_t network_bytes = 0; | 508 int64_t network_bytes = 0; |
509 int64_t cache_bytes = 0; | 509 int64_t cache_bytes = 0; |
510 for (const auto& request : resources) { | 510 for (const auto& request : resources) { |
511 SimulateLoadedResource(request); | 511 SimulateLoadedResource(request); |
512 if (!request.was_cached) { | 512 if (!request.was_cached) { |
513 network_bytes += request.raw_body_bytes; | 513 network_bytes += request.raw_body_bytes; |
514 } else { | 514 } else { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 timing.parse_start = base::TimeDelta::FromMilliseconds(5); | 568 timing.parse_start = base::TimeDelta::FromMilliseconds(5); |
569 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); | 569 timing.first_contentful_paint = base::TimeDelta::FromMilliseconds(10); |
570 PopulateRequiredTimingFields(&timing); | 570 PopulateRequiredTimingFields(&timing); |
571 | 571 |
572 GURL url(kDefaultTestUrl); | 572 GURL url(kDefaultTestUrl); |
573 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); | 573 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); |
574 SimulateTimingUpdate(timing); | 574 SimulateTimingUpdate(timing); |
575 | 575 |
576 page_load_metrics::ExtraRequestInfo resources[] = { | 576 page_load_metrics::ExtraRequestInfo resources[] = { |
577 // Cached request. | 577 // Cached request. |
578 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 578 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
579 false /* data_reduction_proxy_used*/, | 579 1024 * 20 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
580 0 /* original_network_content_length */}, | 580 0 /* original_network_content_length */}, |
581 // Uncached non-proxied request. | 581 // Uncached non-proxied request. |
582 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 582 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
583 false /* data_reduction_proxy_used*/, | 583 1024 * 40 /* raw_body_bytes */, false /* data_reduction_proxy_used*/, |
584 1024 * 40 /* original_network_content_length */}, | 584 1024 * 40 /* original_network_content_length */}, |
585 }; | 585 }; |
586 | 586 |
587 int64_t network_bytes = 0; | 587 int64_t network_bytes = 0; |
588 int64_t cache_bytes = 0; | 588 int64_t cache_bytes = 0; |
589 for (auto request : resources) { | 589 for (auto request : resources) { |
590 SimulateLoadedResource(request); | 590 SimulateLoadedResource(request); |
591 if (!request.was_cached) { | 591 if (!request.was_cached) { |
592 network_bytes += request.raw_body_bytes; | 592 network_bytes += request.raw_body_bytes; |
593 } else { | 593 } else { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 NavigateAndCommit(GURL(kDefaultTestUrl2)); | 697 NavigateAndCommit(GURL(kDefaultTestUrl2)); |
698 | 698 |
699 histogram_tester().ExpectTotalCount( | 699 histogram_tester().ExpectTotalCount( |
700 internal::kHistogramFirstMeaningfulPaint, 0); | 700 internal::kHistogramFirstMeaningfulPaint, 0); |
701 histogram_tester().ExpectTotalCount( | 701 histogram_tester().ExpectTotalCount( |
702 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 702 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
703 histogram_tester().ExpectBucketCount( | 703 histogram_tester().ExpectBucketCount( |
704 internal::kHistogramFirstMeaningfulPaintStatus, | 704 internal::kHistogramFirstMeaningfulPaintStatus, |
705 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); | 705 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); |
706 } | 706 } |
OLD | NEW |