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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 timing.paint_timing.first_contentful_paint = | 410 timing.paint_timing.first_contentful_paint = |
411 base::TimeDelta::FromMilliseconds(10); | 411 base::TimeDelta::FromMilliseconds(10); |
412 PopulateRequiredTimingFields(&timing); | 412 PopulateRequiredTimingFields(&timing); |
413 | 413 |
414 GURL url(kDefaultTestUrl); | 414 GURL url(kDefaultTestUrl); |
415 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD); | 415 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_RELOAD); |
416 SimulateTimingUpdate(timing); | 416 SimulateTimingUpdate(timing); |
417 | 417 |
418 page_load_metrics::ExtraRequestCompleteInfo resources[] = { | 418 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
419 // Cached request. | 419 // Cached request. |
420 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 420 |
421 0 /* original_network_content_length */, | 421 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
| 422 1024 * 20 /* raw_body_bytes */, 0 /* original_network_content_length */, |
422 nullptr /* data_reduction_proxy_data */, | 423 nullptr /* data_reduction_proxy_data */, |
423 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 424 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
424 // Uncached non-proxied request. | 425 // Uncached non-proxied request. |
425 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 426 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 427 1024 * 40 /* raw_body_bytes */, |
426 1024 * 40 /* original_network_content_length */, | 428 1024 * 40 /* original_network_content_length */, |
427 nullptr /* data_reduction_proxy_data */, | 429 nullptr /* data_reduction_proxy_data */, |
428 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 430 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
429 }; | 431 }; |
430 | 432 |
431 int64_t network_bytes = 0; | 433 int64_t network_bytes = 0; |
432 int64_t cache_bytes = 0; | 434 int64_t cache_bytes = 0; |
433 for (const auto& request : resources) { | 435 for (const auto& request : resources) { |
434 SimulateLoadedResource(request); | 436 SimulateLoadedResource(request); |
435 if (!request.was_cached) { | 437 if (!request.was_cached) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK | 500 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK |
499 // modifier. This test verifies that when we encounter such a page, we log it | 501 // modifier. This test verifies that when we encounter such a page, we log it |
500 // as a forward/back navigation. | 502 // as a forward/back navigation. |
501 NavigateWithPageTransitionAndCommit( | 503 NavigateWithPageTransitionAndCommit( |
502 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | | 504 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | |
503 ui::PAGE_TRANSITION_FORWARD_BACK)); | 505 ui::PAGE_TRANSITION_FORWARD_BACK)); |
504 SimulateTimingUpdate(timing); | 506 SimulateTimingUpdate(timing); |
505 | 507 |
506 page_load_metrics::ExtraRequestCompleteInfo resources[] = { | 508 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
507 // Cached request. | 509 // Cached request. |
508 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 510 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
509 0 /* original_network_content_length */, | 511 1024 * 20 /* raw_body_bytes */, 0 /* original_network_content_length */, |
510 nullptr /* data_reduction_proxy_data */, | 512 nullptr /* data_reduction_proxy_data */, |
511 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 513 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
512 // Uncached non-proxied request. | 514 // Uncached non-proxied request. |
513 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 515 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 516 1024 * 40 /* raw_body_bytes */, |
514 1024 * 40 /* original_network_content_length */, | 517 1024 * 40 /* original_network_content_length */, |
515 nullptr /* data_reduction_proxy_data */, | 518 nullptr /* data_reduction_proxy_data */, |
516 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 519 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
517 }; | 520 }; |
518 | 521 |
519 int64_t network_bytes = 0; | 522 int64_t network_bytes = 0; |
520 int64_t cache_bytes = 0; | 523 int64_t cache_bytes = 0; |
521 for (const auto& request : resources) { | 524 for (const auto& request : resources) { |
522 SimulateLoadedResource(request); | 525 SimulateLoadedResource(request); |
523 if (!request.was_cached) { | 526 if (!request.was_cached) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 timing.paint_timing.first_contentful_paint = | 583 timing.paint_timing.first_contentful_paint = |
581 base::TimeDelta::FromMilliseconds(10); | 584 base::TimeDelta::FromMilliseconds(10); |
582 PopulateRequiredTimingFields(&timing); | 585 PopulateRequiredTimingFields(&timing); |
583 | 586 |
584 GURL url(kDefaultTestUrl); | 587 GURL url(kDefaultTestUrl); |
585 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); | 588 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); |
586 SimulateTimingUpdate(timing); | 589 SimulateTimingUpdate(timing); |
587 | 590 |
588 page_load_metrics::ExtraRequestCompleteInfo resources[] = { | 591 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
589 // Cached request. | 592 // Cached request. |
590 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 593 {GURL(), -1 /* frame_tree_node_id */, true /*was_cached*/, |
591 0 /* original_network_content_length */, | 594 1024 * 20 /* raw_body_bytes */, 0 /* original_network_content_length */, |
592 nullptr /* data_reduction_proxy_data */, | 595 nullptr /* data_reduction_proxy_data */, |
593 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 596 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
594 // Uncached non-proxied request. | 597 // Uncached non-proxied request. |
595 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 598 {GURL(), -1 /* frame_tree_node_id */, false /*was_cached*/, |
| 599 1024 * 40 /* raw_body_bytes */, |
596 1024 * 40 /* original_network_content_length */, | 600 1024 * 40 /* original_network_content_length */, |
597 nullptr /* data_reduction_proxy_data */, | 601 nullptr /* data_reduction_proxy_data */, |
598 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, | 602 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
599 }; | 603 }; |
600 | 604 |
601 int64_t network_bytes = 0; | 605 int64_t network_bytes = 0; |
602 int64_t cache_bytes = 0; | 606 int64_t cache_bytes = 0; |
603 for (const auto& request : resources) { | 607 for (const auto& request : resources) { |
604 SimulateLoadedResource(request); | 608 SimulateLoadedResource(request); |
605 if (!request.was_cached) { | 609 if (!request.was_cached) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 NavigateAndCommit(GURL(kDefaultTestUrl2)); | 717 NavigateAndCommit(GURL(kDefaultTestUrl2)); |
714 | 718 |
715 histogram_tester().ExpectTotalCount( | 719 histogram_tester().ExpectTotalCount( |
716 internal::kHistogramFirstMeaningfulPaint, 0); | 720 internal::kHistogramFirstMeaningfulPaint, 0); |
717 histogram_tester().ExpectTotalCount( | 721 histogram_tester().ExpectTotalCount( |
718 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 722 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
719 histogram_tester().ExpectBucketCount( | 723 histogram_tester().ExpectBucketCount( |
720 internal::kHistogramFirstMeaningfulPaintStatus, | 724 internal::kHistogramFirstMeaningfulPaintStatus, |
721 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); | 725 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); |
722 } | 726 } |
OLD | NEW |