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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 timing.navigation_start = base::Time::FromDoubleT(1); | 408 timing.navigation_start = base::Time::FromDoubleT(1); |
409 timing.parse_timing.parse_start = base::TimeDelta::FromMilliseconds(5); | 409 timing.parse_timing.parse_start = base::TimeDelta::FromMilliseconds(5); |
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::ExtraRequestInfo resources[] = { | 418 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
419 // Cached request. | 419 // Cached request. |
420 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 420 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, |
421 0 /* original_network_content_length */, | 421 0 /* original_network_content_length */, |
422 nullptr /* data_reduction_proxy_data */}, | 422 nullptr /* data_reduction_proxy_data */, |
| 423 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
423 // Uncached non-proxied request. | 424 // Uncached non-proxied request. |
424 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 425 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
425 1024 * 40 /* original_network_content_length */, | 426 1024 * 40 /* original_network_content_length */, |
426 nullptr /* data_reduction_proxy_data */}, | 427 nullptr /* data_reduction_proxy_data */, |
| 428 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
427 }; | 429 }; |
428 | 430 |
429 int64_t network_bytes = 0; | 431 int64_t network_bytes = 0; |
430 int64_t cache_bytes = 0; | 432 int64_t cache_bytes = 0; |
431 for (const auto& request : resources) { | 433 for (const auto& request : resources) { |
432 SimulateLoadedResource(request); | 434 SimulateLoadedResource(request); |
433 if (!request.was_cached) { | 435 if (!request.was_cached) { |
434 network_bytes += request.raw_body_bytes; | 436 network_bytes += request.raw_body_bytes; |
435 } else { | 437 } else { |
436 cache_bytes += request.raw_body_bytes; | 438 cache_bytes += request.raw_body_bytes; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 GURL url(kDefaultTestUrl); | 496 GURL url(kDefaultTestUrl); |
495 // Back navigations to a page that was reloaded report a main transition type | 497 // Back navigations to a page that was reloaded report a main transition type |
496 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK | 498 // of PAGE_TRANSITION_RELOAD with a PAGE_TRANSITION_FORWARD_BACK |
497 // modifier. This test verifies that when we encounter such a page, we log it | 499 // modifier. This test verifies that when we encounter such a page, we log it |
498 // as a forward/back navigation. | 500 // as a forward/back navigation. |
499 NavigateWithPageTransitionAndCommit( | 501 NavigateWithPageTransitionAndCommit( |
500 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | | 502 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | |
501 ui::PAGE_TRANSITION_FORWARD_BACK)); | 503 ui::PAGE_TRANSITION_FORWARD_BACK)); |
502 SimulateTimingUpdate(timing); | 504 SimulateTimingUpdate(timing); |
503 | 505 |
504 page_load_metrics::ExtraRequestInfo resources[] = { | 506 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
505 // Cached request. | 507 // Cached request. |
506 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 508 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, |
507 0 /* original_network_content_length */, | 509 0 /* original_network_content_length */, |
508 nullptr /* data_reduction_proxy_data */}, | 510 nullptr /* data_reduction_proxy_data */, |
| 511 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
509 // Uncached non-proxied request. | 512 // Uncached non-proxied request. |
510 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 513 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
511 1024 * 40 /* original_network_content_length */, | 514 1024 * 40 /* original_network_content_length */, |
512 nullptr /* data_reduction_proxy_data */}, | 515 nullptr /* data_reduction_proxy_data */, |
| 516 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
513 }; | 517 }; |
514 | 518 |
515 int64_t network_bytes = 0; | 519 int64_t network_bytes = 0; |
516 int64_t cache_bytes = 0; | 520 int64_t cache_bytes = 0; |
517 for (const auto& request : resources) { | 521 for (const auto& request : resources) { |
518 SimulateLoadedResource(request); | 522 SimulateLoadedResource(request); |
519 if (!request.was_cached) { | 523 if (!request.was_cached) { |
520 network_bytes += request.raw_body_bytes; | 524 network_bytes += request.raw_body_bytes; |
521 } else { | 525 } else { |
522 cache_bytes += request.raw_body_bytes; | 526 cache_bytes += request.raw_body_bytes; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 timing.navigation_start = base::Time::FromDoubleT(1); | 578 timing.navigation_start = base::Time::FromDoubleT(1); |
575 timing.parse_timing.parse_start = base::TimeDelta::FromMilliseconds(5); | 579 timing.parse_timing.parse_start = base::TimeDelta::FromMilliseconds(5); |
576 timing.paint_timing.first_contentful_paint = | 580 timing.paint_timing.first_contentful_paint = |
577 base::TimeDelta::FromMilliseconds(10); | 581 base::TimeDelta::FromMilliseconds(10); |
578 PopulateRequiredTimingFields(&timing); | 582 PopulateRequiredTimingFields(&timing); |
579 | 583 |
580 GURL url(kDefaultTestUrl); | 584 GURL url(kDefaultTestUrl); |
581 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); | 585 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); |
582 SimulateTimingUpdate(timing); | 586 SimulateTimingUpdate(timing); |
583 | 587 |
584 page_load_metrics::ExtraRequestInfo resources[] = { | 588 page_load_metrics::ExtraRequestCompleteInfo resources[] = { |
585 // Cached request. | 589 // Cached request. |
586 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 590 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, |
587 0 /* original_network_content_length */, | 591 0 /* original_network_content_length */, |
588 nullptr /* data_reduction_proxy_data */}, | 592 nullptr /* data_reduction_proxy_data */, |
| 593 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
589 // Uncached non-proxied request. | 594 // Uncached non-proxied request. |
590 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 595 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
591 1024 * 40 /* original_network_content_length */, | 596 1024 * 40 /* original_network_content_length */, |
592 nullptr /* data_reduction_proxy_data */}, | 597 nullptr /* data_reduction_proxy_data */, |
| 598 content::ResourceType::RESOURCE_TYPE_MAIN_FRAME}, |
593 }; | 599 }; |
594 | 600 |
595 int64_t network_bytes = 0; | 601 int64_t network_bytes = 0; |
596 int64_t cache_bytes = 0; | 602 int64_t cache_bytes = 0; |
597 for (const auto& request : resources) { | 603 for (const auto& request : resources) { |
598 SimulateLoadedResource(request); | 604 SimulateLoadedResource(request); |
599 if (!request.was_cached) { | 605 if (!request.was_cached) { |
600 network_bytes += request.raw_body_bytes; | 606 network_bytes += request.raw_body_bytes; |
601 } else { | 607 } else { |
602 cache_bytes += request.raw_body_bytes; | 608 cache_bytes += request.raw_body_bytes; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 NavigateAndCommit(GURL(kDefaultTestUrl2)); | 713 NavigateAndCommit(GURL(kDefaultTestUrl2)); |
708 | 714 |
709 histogram_tester().ExpectTotalCount( | 715 histogram_tester().ExpectTotalCount( |
710 internal::kHistogramFirstMeaningfulPaint, 0); | 716 internal::kHistogramFirstMeaningfulPaint, 0); |
711 histogram_tester().ExpectTotalCount( | 717 histogram_tester().ExpectTotalCount( |
712 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 718 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
713 histogram_tester().ExpectBucketCount( | 719 histogram_tester().ExpectBucketCount( |
714 internal::kHistogramFirstMeaningfulPaintStatus, | 720 internal::kHistogramFirstMeaningfulPaintStatus, |
715 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); | 721 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); |
716 } | 722 } |
OLD | NEW |