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

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

Issue 1176253002: Fix IsPrecachingAllowed() to check Sync instead of Data Saver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaks per bengr. Created 5 years, 6 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
« no previous file with comments | « components/precache/content/DEPS ('k') | components/precache/content/precache_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 namespace content { 27 namespace content {
28 class BrowserContext; 28 class BrowserContext;
29 } 29 }
30 30
31 namespace history { 31 namespace history {
32 class HistoryService; 32 class HistoryService;
33 } 33 }
34 34
35 namespace sync_driver {
36 class SyncService;
37 }
38
35 namespace precache { 39 namespace precache {
36 40
37 class PrecacheDatabase; 41 class PrecacheDatabase;
38 42
39 // Visible for test. 43 // Visible for test.
40 int NumTopHosts(); 44 int NumTopHosts();
41 45
42 // Class that manages all precaching-related activities. Owned by the 46 // Class that manages all precaching-related activities. Owned by the
43 // BrowserContext that it is constructed for. Use 47 // BrowserContext that it is constructed for. Use
44 // PrecacheManagerFactory::GetForBrowserContext to get an instance of this 48 // PrecacheManagerFactory::GetForBrowserContext to get an instance of this
45 // class. All methods must be called on the UI thread unless indicated 49 // class. All methods must be called on the UI thread unless indicated
46 // otherwise. 50 // otherwise.
47 // TODO(sclittle): Delete precache history when browsing history is deleted. 51 // TODO(sclittle): Delete precache history when browsing history is deleted.
48 // http://crbug.com/326549 52 // http://crbug.com/326549
49 class PrecacheManager : public KeyedService, 53 class PrecacheManager : public KeyedService,
50 public PrecacheFetcher::PrecacheDelegate, 54 public PrecacheFetcher::PrecacheDelegate,
51 public base::SupportsWeakPtr<PrecacheManager> { 55 public base::SupportsWeakPtr<PrecacheManager> {
52 public: 56 public:
53 typedef base::Closure PrecacheCompletionCallback; 57 typedef base::Closure PrecacheCompletionCallback;
54 58
55 explicit PrecacheManager(content::BrowserContext* browser_context); 59 PrecacheManager(content::BrowserContext* browser_context,
60 const sync_driver::SyncService* const sync_service);
56 ~PrecacheManager() override; 61 ~PrecacheManager() override;
57 62
58 // Returns true if precaching is enabled as part of a field trial or by the 63 // Returns true if precaching is enabled as part of a field trial or by the
59 // command line flag. This method can be called on any thread. 64 // command line flag. This method can be called on any thread.
60 static bool IsPrecachingEnabled(); 65 static bool IsPrecachingEnabled();
61 66
62 // Returns true if precaching is allowed for the browser context. 67 // Returns true if precaching is allowed for the browser context.
63 bool IsPrecachingAllowed(); 68 bool IsPrecachingAllowed();
64 69
65 // Starts precaching resources that the user is predicted to fetch in the 70 // Starts precaching resources that the user is predicted to fetch in the
(...skipping 20 matching lines...) Expand all
86 // From KeyedService. 91 // From KeyedService.
87 void Shutdown() override; 92 void Shutdown() override;
88 93
89 // From PrecacheFetcher::PrecacheDelegate. 94 // From PrecacheFetcher::PrecacheDelegate.
90 void OnDone() override; 95 void OnDone() override;
91 96
92 // From history::HistoryService::TopHosts. 97 // From history::HistoryService::TopHosts.
93 void OnHostsReceived(const history::TopHostsList& host_counts); 98 void OnHostsReceived(const history::TopHostsList& host_counts);
94 99
95 // The browser context that owns this PrecacheManager. 100 // The browser context that owns this PrecacheManager.
96 content::BrowserContext* browser_context_; 101 content::BrowserContext* const browser_context_;
102
103 // The sync service corresponding to the browser context. Used to determine
104 // whether precache can run. May be null.
105 const sync_driver::SyncService* const sync_service_;
97 106
98 // The PrecacheFetcher used to precache resources. Should only be used on the 107 // The PrecacheFetcher used to precache resources. Should only be used on the
99 // UI thread. 108 // UI thread.
100 scoped_ptr<PrecacheFetcher> precache_fetcher_; 109 scoped_ptr<PrecacheFetcher> precache_fetcher_;
101 110
102 // The callback that will be run if precaching finishes without being 111 // The callback that will be run if precaching finishes without being
103 // canceled. 112 // canceled.
104 PrecacheCompletionCallback precache_completion_callback_; 113 PrecacheCompletionCallback precache_completion_callback_;
105 114
106 // The PrecacheDatabase for tracking precache metrics. Should only be used on 115 // The PrecacheDatabase for tracking precache metrics. Should only be used on
107 // the DB thread. 116 // the DB thread.
108 scoped_refptr<PrecacheDatabase> precache_database_; 117 const scoped_refptr<PrecacheDatabase> precache_database_;
109 118
110 // Flag indicating whether or not precaching is currently in progress. 119 // Flag indicating whether or not precaching is currently in progress.
111 bool is_precaching_; 120 bool is_precaching_;
112 121
113 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); 122 DISALLOW_COPY_AND_ASSIGN(PrecacheManager);
114 }; 123 };
115 124
116 } // namespace precache 125 } // namespace precache
117 126
118 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ 127 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
OLDNEW
« no previous file with comments | « components/precache/content/DEPS ('k') | components/precache/content/precache_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698