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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 } | 123 } |
124 | 124 |
125 bool was_on_done_called() const { | 125 bool was_on_done_called() const { |
126 return was_on_done_called_; | 126 return was_on_done_called_; |
127 } | 127 } |
128 | 128 |
129 private: | 129 private: |
130 bool was_on_done_called_; | 130 bool was_on_done_called_; |
131 }; | 131 }; |
132 | 132 |
133 void RegisterSyntheticFieldTrial(const base::Time& last_precache_time) {} | |
jamartin
2016/12/21 23:54:34
Maybe test that this is eventually called with the
jamartin
2016/12/21 23:54:34
Idem.
twifkak
2017/01/05 23:53:14
Done.
twifkak
2017/01/05 23:53:14
Done.
| |
134 | |
133 class PrecacheManagerUnderTest : public PrecacheManager { | 135 class PrecacheManagerUnderTest : public PrecacheManager { |
134 public: | 136 public: |
135 PrecacheManagerUnderTest( | 137 PrecacheManagerUnderTest( |
136 content::BrowserContext* browser_context, | 138 content::BrowserContext* browser_context, |
137 const syncer::SyncService* sync_service, | 139 const syncer::SyncService* sync_service, |
138 const history::HistoryService* history_service, | 140 const history::HistoryService* history_service, |
139 const data_reduction_proxy::DataReductionProxySettings* | 141 const data_reduction_proxy::DataReductionProxySettings* |
140 data_reduction_proxy_settings, | 142 data_reduction_proxy_settings, |
141 const base::FilePath& db_path, | 143 const base::FilePath& db_path, |
142 std::unique_ptr<PrecacheDatabase> precache_database) | 144 std::unique_ptr<PrecacheDatabase> precache_database) |
143 : PrecacheManager(browser_context, | 145 : PrecacheManager(browser_context, |
144 sync_service, | 146 sync_service, |
145 history_service, | 147 history_service, |
146 data_reduction_proxy_settings, | 148 data_reduction_proxy_settings, |
147 db_path, | 149 db_path, |
148 std::move(precache_database)), | 150 std::move(precache_database), |
151 base::Bind(&precache::RegisterSyntheticFieldTrial)), | |
149 control_group_(false) {} | 152 control_group_(false) {} |
150 bool IsInExperimentGroup() const override { return !control_group_; } | 153 bool IsInExperimentGroup() const override { return !control_group_; } |
151 bool IsInControlGroup() const override { return control_group_; } | 154 bool IsInControlGroup() const override { return control_group_; } |
152 bool IsPrecachingAllowed() const override { return true; } | 155 bool IsPrecachingAllowed() const override { return true; } |
153 void SetInControlGroup(bool in_control_group) { | 156 void SetInControlGroup(bool in_control_group) { |
154 control_group_ = in_control_group; | 157 control_group_ = in_control_group; |
155 } | 158 } |
156 | 159 |
157 private: | 160 private: |
158 bool control_group_; | 161 bool control_group_; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 expected_histogram_count_map["Precache.Saved"] += 2; | 650 expected_histogram_count_map["Precache.Saved"] += 2; |
648 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; | 651 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; |
649 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; | 652 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; |
650 | 653 |
651 base::RunLoop().RunUntilIdle(); | 654 base::RunLoop().RunUntilIdle(); |
652 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), | 655 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), |
653 ContainerEq(expected_histogram_count_map)); | 656 ContainerEq(expected_histogram_count_map)); |
654 } | 657 } |
655 | 658 |
656 } // namespace precache | 659 } // namespace precache |
OLD | NEW |