OLD | NEW |
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 | 11 |
11 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
17 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "components/history/core/browser/history_constants.h" | 19 #include "components/history/core/browser/history_constants.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 namespace { | 24 namespace { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const base::Time& fetch_time, | 101 const base::Time& fetch_time, |
102 int64_t size); | 102 int64_t size); |
103 | 103 |
104 // Must be declared first so that it is destroyed last. | 104 // Must be declared first so that it is destroyed last. |
105 base::ScopedTempDir scoped_temp_dir_; | 105 base::ScopedTempDir scoped_temp_dir_; |
106 | 106 |
107 // Having this MessageLoop member variable causes base::MessageLoop::current() | 107 // Having this MessageLoop member variable causes base::MessageLoop::current() |
108 // to be set properly. | 108 // to be set properly. |
109 base::MessageLoopForUI loop_; | 109 base::MessageLoopForUI loop_; |
110 | 110 |
111 scoped_ptr<PrecacheDatabase> precache_database_; | 111 std::unique_ptr<PrecacheDatabase> precache_database_; |
112 base::HistogramTester histograms_; | 112 base::HistogramTester histograms_; |
113 base::HistogramTester::CountsMap expected_histogram_counts_; | 113 base::HistogramTester::CountsMap expected_histogram_counts_; |
114 | 114 |
115 void ExpectNewSample(const std::string& histogram_name, | 115 void ExpectNewSample(const std::string& histogram_name, |
116 base::HistogramBase::Sample sample) { | 116 base::HistogramBase::Sample sample) { |
117 histograms_.ExpectUniqueSample(histogram_name, sample, 1); | 117 histograms_.ExpectUniqueSample(histogram_name, sample, 1); |
118 expected_histogram_counts_[histogram_name]++; | 118 expected_histogram_counts_[histogram_name]++; |
119 } | 119 } |
120 | 120 |
121 void ExpectNoOtherSamples() { | 121 void ExpectNoOtherSamples() { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } // namespace | 384 } // namespace |
385 | 385 |
386 } // namespace precache | 386 } // namespace precache |
OLD | NEW |