Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: components/precache/content/precache_manager.h

Issue 2762673002: predictors: Pass manifests from Bork to store in ResourcePrefetchPredictor. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 namespace syncer { 50 namespace syncer {
51 class SyncService; 51 class SyncService;
52 } 52 }
53 53
54 namespace precache { 54 namespace precache {
55 55
56 class PrecacheDatabase; 56 class PrecacheDatabase;
57 class PrecacheUnfinishedWork; 57 class PrecacheUnfinishedWork;
58 class PrecacheManifest;
59 class PrecacheManifestDelegate;
58 60
59 extern const char kPrecacheFieldTrialName[]; 61 extern const char kPrecacheFieldTrialName[];
60 62
61 // Visible for test. 63 // Visible for test.
62 extern const char kMinCacheSizeParam[]; 64 extern const char kMinCacheSizeParam[];
63 size_t NumTopHosts(); 65 size_t NumTopHosts();
64 66
65 // Class that manages all precaching-related activities. Owned by the 67 // Class that manages all precaching-related activities. Owned by the
66 // BrowserContext that it is constructed for. Use 68 // BrowserContext that it is constructed for. Use
67 // PrecacheManagerFactory::GetForBrowserContext to get an instance of this 69 // PrecacheManagerFactory::GetForBrowserContext to get an instance of this
68 // class. All methods must be called on the UI thread unless indicated 70 // class. All methods must be called on the UI thread unless indicated
69 // otherwise. 71 // otherwise.
70 // TODO(sclittle): Delete precache history when browsing history is deleted. 72 // TODO(sclittle): Delete precache history when browsing history is deleted.
71 // http://crbug.com/326549 73 // http://crbug.com/326549
72 class PrecacheManager : public KeyedService, 74 class PrecacheManager : public KeyedService,
73 public PrecacheFetcher::PrecacheDelegate, 75 public PrecacheFetcher::PrecacheDelegate,
74 public base::SupportsWeakPtr<PrecacheManager> { 76 public base::SupportsWeakPtr<PrecacheManager> {
75 public: 77 public:
76 typedef base::Callback<void(bool)> PrecacheCompletionCallback; 78 typedef base::Callback<void(bool)> PrecacheCompletionCallback;
77 79
78 PrecacheManager(content::BrowserContext* browser_context, 80 PrecacheManager(content::BrowserContext* browser_context,
79 const syncer::SyncService* sync_service, 81 const syncer::SyncService* sync_service,
80 const history::HistoryService* history_service, 82 const history::HistoryService* history_service,
81 const data_reduction_proxy::DataReductionProxySettings* 83 const data_reduction_proxy::DataReductionProxySettings*
82 data_reduction_proxy_settings, 84 data_reduction_proxy_settings,
85 PrecacheManifestDelegate* precache_manifest_delegate,
83 const base::FilePath& db_path, 86 const base::FilePath& db_path,
84 std::unique_ptr<PrecacheDatabase> precache_database); 87 std::unique_ptr<PrecacheDatabase> precache_database);
85 ~PrecacheManager() override; 88 ~PrecacheManager() override;
86 89
87 // Returns true if the client is in the experiment group -- that is, 90 // 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 91 // precaching is allowed based on user settings, and enabled as part of a
89 // field trial or by commandline flag. Virtual for testing. 92 // field trial or by commandline flag. Virtual for testing.
90 virtual bool IsInExperimentGroup() const; 93 virtual bool IsInExperimentGroup() const;
91 94
92 // Returns true if the client is in the control group -- that is, precaching 95 // Returns true if the client is in the control group -- that is, precaching
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ALLOWED, 149 ALLOWED,
147 DISALLOWED, 150 DISALLOWED,
148 PENDING 151 PENDING
149 }; 152 };
150 153
151 // From KeyedService. 154 // From KeyedService.
152 void Shutdown() override; 155 void Shutdown() override;
153 156
154 // From PrecacheFetcher::PrecacheDelegate. 157 // From PrecacheFetcher::PrecacheDelegate.
155 void OnDone() override; 158 void OnDone() override;
159 void OnManifestFetched(const std::string& host,
160 const PrecacheManifest& manifest) override;
156 161
157 // Registers the precache synthetic field trial for users whom the precache 162 // Registers the precache synthetic field trial for users whom the precache
158 // task was run recently. |last_precache_time| is the last time precache task 163 // task was run recently. |last_precache_time| is the last time precache task
159 // was run. 164 // was run.
160 void RegisterSyntheticFieldTrial(const base::Time last_precache_time); 165 void RegisterSyntheticFieldTrial(const base::Time last_precache_time);
161 166
162 // Callback when fetching unfinished work from storage is done. 167 // Callback when fetching unfinished work from storage is done.
163 void OnGetUnfinishedWorkDone( 168 void OnGetUnfinishedWorkDone(
164 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); 169 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work);
165 170
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 217
213 // The history service corresponding to the browser context. Used to determine 218 // The history service corresponding to the browser context. Used to determine
214 // the list of top hosts. May be null. 219 // the list of top hosts. May be null.
215 const history::HistoryService* const history_service_; 220 const history::HistoryService* const history_service_;
216 221
217 // The data reduction proxy settings object corresponding to the browser 222 // The data reduction proxy settings object corresponding to the browser
218 // context. Used to determine if the proxy is enabled. 223 // context. Used to determine if the proxy is enabled.
219 const data_reduction_proxy::DataReductionProxySettings* const 224 const data_reduction_proxy::DataReductionProxySettings* const
220 data_reduction_proxy_settings_; 225 data_reduction_proxy_settings_;
221 226
227 // The PrecacheManifestDelegate corresponding to the browser context. Used to
228 // notify browser about new manifest available. May be null.
Benoit L 2017/03/20 16:51:53 nit: notify the browser about a new available mani
alexilin 2017/03/21 09:50:35 Done.
229 PrecacheManifestDelegate* precache_manifest_delegate_;
230
222 // The PrecacheFetcher used to precache resources. Should only be used on the 231 // The PrecacheFetcher used to precache resources. Should only be used on the
223 // UI thread. 232 // UI thread.
224 std::unique_ptr<PrecacheFetcher> precache_fetcher_; 233 std::unique_ptr<PrecacheFetcher> precache_fetcher_;
225 234
226 // The callback that will be run if precaching finishes without being 235 // The callback that will be run if precaching finishes without being
227 // canceled. 236 // canceled.
228 PrecacheCompletionCallback precache_completion_callback_; 237 PrecacheCompletionCallback precache_completion_callback_;
229 238
230 // The PrecacheDatabase for tracking precache metrics. Should only be used on 239 // The PrecacheDatabase for tracking precache metrics. Should only be used on
231 // the DB thread. 240 // the DB thread.
(...skipping 13 matching lines...) Expand all
245 254
246 // Work that hasn't yet finished. 255 // Work that hasn't yet finished.
247 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; 256 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_;
248 257
249 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); 258 DISALLOW_COPY_AND_ASSIGN(PrecacheManager);
250 }; 259 };
251 260
252 } // namespace precache 261 } // namespace precache
253 262
254 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ 263 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698