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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 class PrecacheManager : public KeyedService, | 63 class PrecacheManager : public KeyedService, |
64 public PrecacheFetcher::PrecacheDelegate, | 64 public PrecacheFetcher::PrecacheDelegate, |
65 public base::SupportsWeakPtr<PrecacheManager> { | 65 public base::SupportsWeakPtr<PrecacheManager> { |
66 public: | 66 public: |
67 typedef base::Callback<void(bool)> PrecacheCompletionCallback; | 67 typedef base::Callback<void(bool)> PrecacheCompletionCallback; |
68 | 68 |
69 PrecacheManager(content::BrowserContext* browser_context, | 69 PrecacheManager(content::BrowserContext* browser_context, |
70 const syncer::SyncService* const sync_service, | 70 const syncer::SyncService* const sync_service, |
71 const history::HistoryService* const history_service, | 71 const history::HistoryService* const history_service, |
72 const base::FilePath& db_path, | 72 const base::FilePath& db_path, |
73 std::unique_ptr<PrecacheDatabase> precache_database); | 73 std::unique_ptr<PrecacheDatabase> precache_database, |
| 74 const base::Callback<void(const base::Time&)>& |
| 75 register_synthetic_field_trial_callback); |
74 ~PrecacheManager() override; | 76 ~PrecacheManager() override; |
75 | 77 |
76 // Returns true if the client is in the experiment group -- that is, | 78 // Returns true if the client is in the experiment group -- that is, |
77 // precaching is allowed based on user settings, and enabled as part of a | 79 // precaching is allowed based on user settings, and enabled as part of a |
78 // field trial or by commandline flag. Virtual for testing. | 80 // field trial or by commandline flag. Virtual for testing. |
79 virtual bool IsInExperimentGroup() const; | 81 virtual bool IsInExperimentGroup() const; |
80 | 82 |
81 // Returns true if the client is in the control group -- that is, precaching | 83 // Returns true if the client is in the control group -- that is, precaching |
82 // is allowed based on user settings, and the browser is in the control group | 84 // is allowed based on user settings, and the browser is in the control group |
83 // of the field trial. Virtual for testing. | 85 // of the field trial. Virtual for testing. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DISALLOWED, | 137 DISALLOWED, |
136 PENDING | 138 PENDING |
137 }; | 139 }; |
138 | 140 |
139 // From KeyedService. | 141 // From KeyedService. |
140 void Shutdown() override; | 142 void Shutdown() override; |
141 | 143 |
142 // From PrecacheFetcher::PrecacheDelegate. | 144 // From PrecacheFetcher::PrecacheDelegate. |
143 void OnDone() override; | 145 void OnDone() override; |
144 | 146 |
| 147 // Registers the precache synthetic field trial for users whom the precache |
| 148 // task was run recently. |last_precache_time| is the last time precache task |
| 149 // was run. |
| 150 void RegisterSyntheticFieldTrial(const base::Time& last_precache_time); |
| 151 |
145 // Callback when fetching unfinished work from storage is done. | 152 // Callback when fetching unfinished work from storage is done. |
146 void OnGetUnfinishedWorkDone( | 153 void OnGetUnfinishedWorkDone( |
147 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); | 154 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); |
148 | 155 |
149 // From history::HistoryService::TopHosts. | 156 // From history::HistoryService::TopHosts. |
150 void OnHostsReceived(const history::TopHostsList& host_counts); | 157 void OnHostsReceived(const history::TopHostsList& host_counts); |
151 | 158 |
152 // Initializes and Starts a PrecacheFetcher with unfinished work. | 159 // Initializes and Starts a PrecacheFetcher with unfinished work. |
153 void InitializeAndStartFetcher(); | 160 void InitializeAndStartFetcher(); |
154 | 161 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // The PrecacheDatabase for tracking precache metrics. Should only be used on | 206 // The PrecacheDatabase for tracking precache metrics. Should only be used on |
200 // the DB thread. | 207 // the DB thread. |
201 std::unique_ptr<PrecacheDatabase> precache_database_; | 208 std::unique_ptr<PrecacheDatabase> precache_database_; |
202 | 209 |
203 // Flag indicating whether or not precaching is currently in progress. | 210 // Flag indicating whether or not precaching is currently in progress. |
204 bool is_precaching_; | 211 bool is_precaching_; |
205 | 212 |
206 // Work that hasn't yet finished. | 213 // Work that hasn't yet finished. |
207 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; | 214 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; |
208 | 215 |
| 216 // Callback to register the synthetic field trial. |
| 217 const base::Callback<void(const base::Time&)> |
| 218 register_synthetic_field_trial_callback_; |
| 219 |
209 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); | 220 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); |
210 }; | 221 }; |
211 | 222 |
212 } // namespace precache | 223 } // namespace precache |
213 | 224 |
214 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ | 225 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ |
OLD | NEW |