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 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 5 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 public base::SupportsWeakPtr<PrecacheManager> { | 74 public base::SupportsWeakPtr<PrecacheManager> { |
75 public: | 75 public: |
76 typedef base::Callback<void(bool)> PrecacheCompletionCallback; | 76 typedef base::Callback<void(bool)> PrecacheCompletionCallback; |
77 | 77 |
78 PrecacheManager(content::BrowserContext* browser_context, | 78 PrecacheManager(content::BrowserContext* browser_context, |
79 const syncer::SyncService* sync_service, | 79 const syncer::SyncService* sync_service, |
80 const history::HistoryService* history_service, | 80 const history::HistoryService* history_service, |
81 const data_reduction_proxy::DataReductionProxySettings* | 81 const data_reduction_proxy::DataReductionProxySettings* |
82 data_reduction_proxy_settings, | 82 data_reduction_proxy_settings, |
83 const base::FilePath& db_path, | 83 const base::FilePath& db_path, |
84 std::unique_ptr<PrecacheDatabase> precache_database); | 84 std::unique_ptr<PrecacheDatabase> precache_database, |
85 const base::Callback<void(const base::Time&)>& | |
jamartin
2016/12/21 23:54:33
Idem.
twifkak
2017/01/05 23:53:14
Done.
| |
86 register_synthetic_field_trial_callback); | |
85 ~PrecacheManager() override; | 87 ~PrecacheManager() override; |
86 | 88 |
87 // Returns true if the client is in the experiment group -- that is, | 89 // Returns true if the client is in the experiment group -- that is, |
88 // precaching is allowed based on user settings, and enabled as part of a | 90 // precaching is allowed based on user settings, and enabled as part of a |
89 // field trial or by commandline flag. Virtual for testing. | 91 // field trial or by commandline flag. Virtual for testing. |
90 virtual bool IsInExperimentGroup() const; | 92 virtual bool IsInExperimentGroup() const; |
91 | 93 |
92 // Returns true if the client is in the control group -- that is, precaching | 94 // Returns true if the client is in the control group -- that is, precaching |
93 // is allowed based on user settings, and the browser is in the control group | 95 // is allowed based on user settings, and the browser is in the control group |
94 // of the field trial. Virtual for testing. | 96 // of the field trial. Virtual for testing. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 DISALLOWED, | 148 DISALLOWED, |
147 PENDING | 149 PENDING |
148 }; | 150 }; |
149 | 151 |
150 // From KeyedService. | 152 // From KeyedService. |
151 void Shutdown() override; | 153 void Shutdown() override; |
152 | 154 |
153 // From PrecacheFetcher::PrecacheDelegate. | 155 // From PrecacheFetcher::PrecacheDelegate. |
154 void OnDone() override; | 156 void OnDone() override; |
155 | 157 |
158 // Registers the precache synthetic field trial for users whom the precache | |
159 // task was run recently. |last_precache_time| is the last time precache task | |
160 // was run. | |
161 void RegisterSyntheticFieldTrial(const base::Time& last_precache_time); | |
jamartin
2016/12/21 23:54:33
Idem.
twifkak
2017/01/05 23:53:14
Done.
| |
162 | |
156 // Callback when fetching unfinished work from storage is done. | 163 // Callback when fetching unfinished work from storage is done. |
157 void OnGetUnfinishedWorkDone( | 164 void OnGetUnfinishedWorkDone( |
158 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); | 165 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); |
159 | 166 |
160 // From history::HistoryService::TopHosts. | 167 // From history::HistoryService::TopHosts. |
161 void OnHostsReceived(const history::TopHostsList& host_counts); | 168 void OnHostsReceived(const history::TopHostsList& host_counts); |
162 | 169 |
163 // Initializes and Starts a PrecacheFetcher with unfinished work. | 170 // Initializes and Starts a PrecacheFetcher with unfinished work. |
164 void InitializeAndStartFetcher(); | 171 void InitializeAndStartFetcher(); |
165 | 172 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 // It should only be accessed from the IO thread. | 239 // It should only be accessed from the IO thread. |
233 disk_cache::Backend* cache_backend_; | 240 disk_cache::Backend* cache_backend_; |
234 | 241 |
235 // The minimum cache size allowed for precaching. Initialized by | 242 // The minimum cache size allowed for precaching. Initialized by |
236 // StartPrecaching and read by OnCacheSizeReceivedInUIThread. | 243 // StartPrecaching and read by OnCacheSizeReceivedInUIThread. |
237 int min_cache_size_bytes_; | 244 int min_cache_size_bytes_; |
238 | 245 |
239 // Work that hasn't yet finished. | 246 // Work that hasn't yet finished. |
240 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; | 247 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; |
241 | 248 |
249 // Callback to register the synthetic field trial. | |
250 const base::Callback<void(const base::Time&)> | |
jamartin
2016/12/21 23:54:33
Idem.
twifkak
2017/01/05 23:53:14
Done.
| |
251 register_synthetic_field_trial_callback_; | |
252 | |
242 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); | 253 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); |
243 }; | 254 }; |
244 | 255 |
245 } // namespace precache | 256 } // namespace precache |
246 | 257 |
247 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 258 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
OLD | NEW |