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

Side by Side Diff: components/precache/core/precache_database_unittest.cc

Issue 2123813002: Report Precache.TimeSinceLastPrecache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gclient sync Created 4 years, 5 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
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/core/precache_database.h" 5 #include "components/precache/core/precache_database.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 EXPECT_THAT(histograms_.GetAllSamples("Precache.Latency.NonPrefetch"), 374 EXPECT_THAT(histograms_.GetAllSamples("Precache.Latency.NonPrefetch"),
375 ElementsAre(Bucket(0, 6), Bucket(kLatency.InMilliseconds(), 3))); 375 ElementsAre(Bucket(0, 6), Bucket(kLatency.InMilliseconds(), 3)));
376 376
377 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved"), 377 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved"),
378 ElementsAre(Bucket(kSize1, 1), Bucket(kSize3, 1))); 378 ElementsAre(Bucket(kSize1, 1), Bucket(kSize3, 1)));
379 379
380 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved.Cellular"), 380 EXPECT_THAT(histograms_.GetAllSamples("Precache.Saved.Cellular"),
381 ElementsAre(Bucket(kSize1, 1))); 381 ElementsAre(Bucket(kSize1, 1)));
382 } 382 }
383 383
384 TEST_F(PrecacheDatabaseTest, LastPrecacheTimestamp) {
385 // So that it starts recording TimeSinceLastPrecache.
386 const base::Time kStartTime =
387 base::Time() + base::TimeDelta::FromSeconds(100);
388 precache_database_->SetLastPrecacheTimestamp(kStartTime);
389
390 RecordPrecacheFromNetwork(kURL, kLatency, kStartTime, kSize);
391 RecordPrecacheFromNetwork(kURL, kLatency, kStartTime, kSize);
392 RecordPrecacheFromNetwork(kURL, kLatency, kStartTime, kSize);
393 RecordPrecacheFromNetwork(kURL, kLatency, kStartTime, kSize);
394
395 EXPECT_THAT(histograms_.GetAllSamples("Precache.TimeSinceLastPrecache"),
396 ElementsAre());
397
398 const base::Time kTimeA = kStartTime + base::TimeDelta::FromSeconds(7);
399 const base::Time kTimeB = kStartTime + base::TimeDelta::FromMinutes(42);
400 const base::Time kTimeC = kStartTime + base::TimeDelta::FromHours(20);
401
402 RecordFetchFromCacheCellular(kURL, kTimeA, kSize);
403 RecordFetchFromCacheCellular(kURL, kTimeA, kSize);
404 RecordFetchFromNetworkCellular(kURL, kLatency, kTimeB, kSize);
405 RecordFetchFromNetworkCellular(kURL, kLatency, kTimeB, kSize);
406 RecordFetchFromCacheCellular(kURL, kTimeB, kSize);
407 RecordFetchFromCacheCellular(kURL, kTimeC, kSize);
408
409 EXPECT_THAT(histograms_.GetAllSamples("Precache.TimeSinceLastPrecache"),
410 ElementsAre(Bucket(0, 2), Bucket(2406, 3), Bucket(69347, 1)));
411 }
412
384 } // namespace 413 } // namespace
385 414
386 } // namespace precache 415 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/core/precache_database.cc ('k') | components/precache/core/precache_session_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698