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

Side by Side Diff: components/precache/content/precache_manager_unittest.cc

Issue 2628513002: Add Precache.CacheStatus.Prefetch UMA. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | components/precache/core/precache_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/precache/content/precache_manager.h" 5 #include "components/precache/content/precache_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 EXPECT_TRUE(precache_manager_->IsPrecaching()); 488 EXPECT_TRUE(precache_manager_->IsPrecaching());
489 RecordStatsForPrecacheFetch(GURL("http://url.com"), std::string(), 489 RecordStatsForPrecacheFetch(GURL("http://url.com"), std::string(),
490 base::TimeDelta(), base::Time(), info_, 1000); 490 base::TimeDelta(), base::Time(), info_, 1000);
491 base::RunLoop().RunUntilIdle(); 491 base::RunLoop().RunUntilIdle();
492 precache_manager_->CancelPrecaching(); 492 precache_manager_->CancelPrecaching();
493 493
494 // For PrecacheFetcher and RecordURLPrecached. 494 // For PrecacheFetcher and RecordURLPrecached.
495 base::RunLoop().RunUntilIdle(); 495 base::RunLoop().RunUntilIdle();
496 EXPECT_THAT( 496 EXPECT_THAT(
497 histograms_.GetTotalCountsForPrefix("Precache."), 497 histograms_.GetTotalCountsForPrefix("Precache."),
498 UnorderedElementsAre(Pair("Precache.CacheSize.AllEntries", 1), 498 UnorderedElementsAre(Pair("Precache.CacheStatus.Prefetch", 1),
499 Pair("Precache.CacheSize.AllEntries", 1),
499 Pair("Precache.DownloadedPrecacheMotivated", 1), 500 Pair("Precache.DownloadedPrecacheMotivated", 1),
500 Pair("Precache.Fetch.PercentCompleted", 1), 501 Pair("Precache.Fetch.PercentCompleted", 1),
501 Pair("Precache.Fetch.ResponseBytes.Network", 1), 502 Pair("Precache.Fetch.ResponseBytes.Network", 1),
502 Pair("Precache.Fetch.ResponseBytes.Total", 1), 503 Pair("Precache.Fetch.ResponseBytes.Total", 1),
503 Pair("Precache.Fetch.TimeToComplete", 1), 504 Pair("Precache.Fetch.TimeToComplete", 1),
504 Pair("Precache.Latency.Prefetch", 1), 505 Pair("Precache.Latency.Prefetch", 1),
505 Pair("Precache.Freshness.Prefetch", 1))); 506 Pair("Precache.Freshness.Prefetch", 1)));
506 } 507 }
507 508
508 TEST_F(PrecacheManagerTest, RecordStatsForFetchHTTP) { 509 TEST_F(PrecacheManagerTest, RecordStatsForFetchHTTP) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // Precache a bunch of URLs, with different fetch times. 570 // Precache a bunch of URLs, with different fetch times.
570 RecordStatsForPrecacheFetch( 571 RecordStatsForPrecacheFetch(
571 GURL("http://old-fetch.com"), std::string(), base::TimeDelta(), 572 GURL("http://old-fetch.com"), std::string(), base::TimeDelta(),
572 kCurrentTime - base::TimeDelta::FromDays(61), info_, 1000); 573 kCurrentTime - base::TimeDelta::FromDays(61), info_, 1000);
573 RecordStatsForPrecacheFetch( 574 RecordStatsForPrecacheFetch(
574 GURL("http://recent-fetch.com"), std::string(), base::TimeDelta(), 575 GURL("http://recent-fetch.com"), std::string(), base::TimeDelta(),
575 kCurrentTime - base::TimeDelta::FromDays(59), info_, 1000); 576 kCurrentTime - base::TimeDelta::FromDays(59), info_, 1000);
576 RecordStatsForPrecacheFetch( 577 RecordStatsForPrecacheFetch(
577 GURL("http://yesterday-fetch.com"), std::string(), base::TimeDelta(), 578 GURL("http://yesterday-fetch.com"), std::string(), base::TimeDelta(),
578 kCurrentTime - base::TimeDelta::FromDays(1), info_, 1000); 579 kCurrentTime - base::TimeDelta::FromDays(1), info_, 1000);
580 expected_histogram_count_map["Precache.CacheStatus.Prefetch"] += 3;
579 expected_histogram_count_map["Precache.CacheSize.AllEntries"]++; 581 expected_histogram_count_map["Precache.CacheSize.AllEntries"]++;
580 expected_histogram_count_map["Precache.DownloadedPrecacheMotivated"] += 3; 582 expected_histogram_count_map["Precache.DownloadedPrecacheMotivated"] += 3;
581 expected_histogram_count_map["Precache.Fetch.PercentCompleted"]++; 583 expected_histogram_count_map["Precache.Fetch.PercentCompleted"]++;
582 expected_histogram_count_map["Precache.Fetch.ResponseBytes.Network"]++; 584 expected_histogram_count_map["Precache.Fetch.ResponseBytes.Network"]++;
583 expected_histogram_count_map["Precache.Fetch.ResponseBytes.Total"]++; 585 expected_histogram_count_map["Precache.Fetch.ResponseBytes.Total"]++;
584 expected_histogram_count_map["Precache.Fetch.TimeToComplete"]++; 586 expected_histogram_count_map["Precache.Fetch.TimeToComplete"]++;
585 expected_histogram_count_map["Precache.Latency.Prefetch"] += 3; 587 expected_histogram_count_map["Precache.Latency.Prefetch"] += 3;
586 expected_histogram_count_map["Precache.Freshness.Prefetch"] += 3; 588 expected_histogram_count_map["Precache.Freshness.Prefetch"] += 3;
587 base::RunLoop().RunUntilIdle(); 589 base::RunLoop().RunUntilIdle();
588 590
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 expected_histogram_count_map["Precache.Saved"] += 2; 649 expected_histogram_count_map["Precache.Saved"] += 2;
648 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; 650 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2;
649 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; 651 expected_histogram_count_map["Precache.Saved.Freshness"] = 2;
650 652
651 base::RunLoop().RunUntilIdle(); 653 base::RunLoop().RunUntilIdle();
652 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), 654 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."),
653 ContainerEq(expected_histogram_count_map)); 655 ContainerEq(expected_histogram_count_map));
654 } 656 }
655 657
656 } // namespace precache 658 } // namespace precache
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698