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/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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 } | 118 } |
119 | 119 |
120 bool was_on_done_called() const { | 120 bool was_on_done_called() const { |
121 return was_on_done_called_; | 121 return was_on_done_called_; |
122 } | 122 } |
123 | 123 |
124 private: | 124 private: |
125 bool was_on_done_called_; | 125 bool was_on_done_called_; |
126 }; | 126 }; |
127 | 127 |
128 void RegisterSyntheticFieldTrial(const base::Time& last_precache_time) {} | |
twifkak
2016/12/08 21:49:22
Would be nice to add a small check that this is ca
| |
129 | |
128 class PrecacheManagerUnderTest : public PrecacheManager { | 130 class PrecacheManagerUnderTest : public PrecacheManager { |
129 public: | 131 public: |
130 PrecacheManagerUnderTest(content::BrowserContext* browser_context, | 132 PrecacheManagerUnderTest(content::BrowserContext* browser_context, |
131 const syncer::SyncService* const sync_service, | 133 const syncer::SyncService* const sync_service, |
132 const history::HistoryService* const history_service, | 134 const history::HistoryService* const history_service, |
133 const base::FilePath& db_path, | 135 const base::FilePath& db_path, |
134 std::unique_ptr<PrecacheDatabase> precache_database) | 136 std::unique_ptr<PrecacheDatabase> precache_database) |
135 : PrecacheManager(browser_context, | 137 : PrecacheManager(browser_context, |
136 sync_service, | 138 sync_service, |
137 history_service, | 139 history_service, |
138 db_path, | 140 db_path, |
139 std::move(precache_database)), | 141 std::move(precache_database), |
142 base::Bind(&precache::RegisterSyntheticFieldTrial)), | |
140 control_group_(false) {} | 143 control_group_(false) {} |
141 bool IsInExperimentGroup() const override { return !control_group_; } | 144 bool IsInExperimentGroup() const override { return !control_group_; } |
142 bool IsInControlGroup() const override { return control_group_; } | 145 bool IsInControlGroup() const override { return control_group_; } |
143 bool IsPrecachingAllowed() const override { return true; } | 146 bool IsPrecachingAllowed() const override { return true; } |
144 void SetInControlGroup(bool in_control_group) { | 147 void SetInControlGroup(bool in_control_group) { |
145 control_group_ = in_control_group; | 148 control_group_ = in_control_group; |
146 } | 149 } |
147 | 150 |
148 private: | 151 private: |
149 bool control_group_; | 152 bool control_group_; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 expected_histogram_count_map["Precache.Saved"] += 2; | 566 expected_histogram_count_map["Precache.Saved"] += 2; |
564 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; | 567 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; |
565 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; | 568 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; |
566 | 569 |
567 base::RunLoop().RunUntilIdle(); | 570 base::RunLoop().RunUntilIdle(); |
568 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), | 571 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), |
569 ContainerEq(expected_histogram_count_map)); | 572 ContainerEq(expected_histogram_count_map)); |
570 } | 573 } |
571 | 574 |
572 } // namespace precache | 575 } // namespace precache |
OLD | NEW |