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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::ExtraRequestInfo 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 false /* data_reduction_proxy_used*/, | 421 0 /* original_network_content_length */, |
422 0 /* original_network_content_length */}, | 422 nullptr /* data_reduction_proxy_data */}, |
423 // Uncached non-proxied request. | 423 // Uncached non-proxied request. |
424 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 424 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
425 false /* data_reduction_proxy_used*/, | 425 1024 * 40 /* original_network_content_length */, |
426 1024 * 40 /* original_network_content_length */}, | 426 nullptr /* data_reduction_proxy_data */}, |
427 }; | 427 }; |
428 | 428 |
429 int64_t network_bytes = 0; | 429 int64_t network_bytes = 0; |
430 int64_t cache_bytes = 0; | 430 int64_t cache_bytes = 0; |
431 for (const auto& request : resources) { | 431 for (const auto& request : resources) { |
432 SimulateLoadedResource(request); | 432 SimulateLoadedResource(request); |
433 if (!request.was_cached) { | 433 if (!request.was_cached) { |
434 network_bytes += request.raw_body_bytes; | 434 network_bytes += request.raw_body_bytes; |
435 } else { | 435 } else { |
436 cache_bytes += request.raw_body_bytes; | 436 cache_bytes += request.raw_body_bytes; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // modifier. This test verifies that when we encounter such a page, we log it | 497 // modifier. This test verifies that when we encounter such a page, we log it |
498 // as a forward/back navigation. | 498 // as a forward/back navigation. |
499 NavigateWithPageTransitionAndCommit( | 499 NavigateWithPageTransitionAndCommit( |
500 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | | 500 url, ui::PageTransitionFromInt(ui::PAGE_TRANSITION_RELOAD | |
501 ui::PAGE_TRANSITION_FORWARD_BACK)); | 501 ui::PAGE_TRANSITION_FORWARD_BACK)); |
502 SimulateTimingUpdate(timing); | 502 SimulateTimingUpdate(timing); |
503 | 503 |
504 page_load_metrics::ExtraRequestInfo resources[] = { | 504 page_load_metrics::ExtraRequestInfo resources[] = { |
505 // Cached request. | 505 // Cached request. |
506 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 506 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, |
507 false /* data_reduction_proxy_used*/, | 507 0 /* original_network_content_length */, |
508 0 /* original_network_content_length */}, | 508 nullptr /* data_reduction_proxy_data */}, |
509 // Uncached non-proxied request. | 509 // Uncached non-proxied request. |
510 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 510 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
511 false /* data_reduction_proxy_used*/, | 511 1024 * 40 /* original_network_content_length */, |
512 1024 * 40 /* original_network_content_length */}, | 512 nullptr /* data_reduction_proxy_data */}, |
513 }; | 513 }; |
514 | 514 |
515 int64_t network_bytes = 0; | 515 int64_t network_bytes = 0; |
516 int64_t cache_bytes = 0; | 516 int64_t cache_bytes = 0; |
517 for (const auto& request : resources) { | 517 for (const auto& request : resources) { |
518 SimulateLoadedResource(request); | 518 SimulateLoadedResource(request); |
519 if (!request.was_cached) { | 519 if (!request.was_cached) { |
520 network_bytes += request.raw_body_bytes; | 520 network_bytes += request.raw_body_bytes; |
521 } else { | 521 } else { |
522 cache_bytes += request.raw_body_bytes; | 522 cache_bytes += request.raw_body_bytes; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 base::TimeDelta::FromMilliseconds(10); | 577 base::TimeDelta::FromMilliseconds(10); |
578 PopulateRequiredTimingFields(&timing); | 578 PopulateRequiredTimingFields(&timing); |
579 | 579 |
580 GURL url(kDefaultTestUrl); | 580 GURL url(kDefaultTestUrl); |
581 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); | 581 NavigateWithPageTransitionAndCommit(url, ui::PAGE_TRANSITION_LINK); |
582 SimulateTimingUpdate(timing); | 582 SimulateTimingUpdate(timing); |
583 | 583 |
584 page_load_metrics::ExtraRequestInfo resources[] = { | 584 page_load_metrics::ExtraRequestInfo resources[] = { |
585 // Cached request. | 585 // Cached request. |
586 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, | 586 {true /*was_cached*/, 1024 * 20 /* raw_body_bytes */, |
587 false /* data_reduction_proxy_used*/, | 587 0 /* original_network_content_length */, |
588 0 /* original_network_content_length */}, | 588 nullptr /* data_reduction_proxy_data */}, |
589 // Uncached non-proxied request. | 589 // Uncached non-proxied request. |
590 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, | 590 {false /*was_cached*/, 1024 * 40 /* raw_body_bytes */, |
591 false /* data_reduction_proxy_used*/, | 591 1024 * 40 /* original_network_content_length */, |
592 1024 * 40 /* original_network_content_length */}, | 592 nullptr /* data_reduction_proxy_data */}, |
593 }; | 593 }; |
594 | 594 |
595 int64_t network_bytes = 0; | 595 int64_t network_bytes = 0; |
596 int64_t cache_bytes = 0; | 596 int64_t cache_bytes = 0; |
597 for (auto request : resources) { | 597 for (const auto& request : resources) { |
598 SimulateLoadedResource(request); | 598 SimulateLoadedResource(request); |
599 if (!request.was_cached) { | 599 if (!request.was_cached) { |
600 network_bytes += request.raw_body_bytes; | 600 network_bytes += request.raw_body_bytes; |
601 } else { | 601 } else { |
602 cache_bytes += request.raw_body_bytes; | 602 cache_bytes += request.raw_body_bytes; |
603 } | 603 } |
604 } | 604 } |
605 | 605 |
606 NavigateToUntrackedUrl(); | 606 NavigateToUntrackedUrl(); |
607 | 607 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 NavigateAndCommit(GURL(kDefaultTestUrl2)); | 707 NavigateAndCommit(GURL(kDefaultTestUrl2)); |
708 | 708 |
709 histogram_tester().ExpectTotalCount( | 709 histogram_tester().ExpectTotalCount( |
710 internal::kHistogramFirstMeaningfulPaint, 0); | 710 internal::kHistogramFirstMeaningfulPaint, 0); |
711 histogram_tester().ExpectTotalCount( | 711 histogram_tester().ExpectTotalCount( |
712 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); | 712 internal::kHistogramParseStartToFirstMeaningfulPaint, 0); |
713 histogram_tester().ExpectBucketCount( | 713 histogram_tester().ExpectBucketCount( |
714 internal::kHistogramFirstMeaningfulPaintStatus, | 714 internal::kHistogramFirstMeaningfulPaintStatus, |
715 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); | 715 internal::FIRST_MEANINGFUL_PAINT_USER_INTERACTION_BEFORE_FMP, 1); |
716 } | 716 } |
OLD | NEW |