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

Side by Side Diff: chrome/browser/prerender/prerender_local_predictor.h

Issue 642623004: Rename VisitDatabaseObserver to HistoryServiceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326
Patch Set: Rebase Created 6 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "chrome/browser/history/visit_database.h" 16 #include "chrome/browser/history/visit_database.h"
17 #include "components/history/core/browser/history_service_observer.h"
17 #include "content/public/browser/session_storage_namespace.h" 18 #include "content/public/browser/session_storage_namespace.h"
18 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 class HistoryService; 22 class HistoryService;
22 23
23 namespace base { 24 namespace base {
24 class DictionaryValue; 25 class DictionaryValue;
25 } 26 }
26 27
27 namespace content { 28 namespace content {
28 class WebContents; 29 class WebContents;
29 } 30 }
30 31
31 namespace gfx { 32 namespace gfx {
32 class Size; 33 class Size;
33 } 34 }
34 35
35 namespace prerender { 36 namespace prerender {
36 37
37 class PrerenderHandle; 38 class PrerenderHandle;
38 class PrerenderManager; 39 class PrerenderManager;
39 40
40 // PrerenderLocalPredictor maintains local browsing history to make prerender 41 // PrerenderLocalPredictor maintains local browsing history to make prerender
41 // predictions. 42 // predictions.
42 // At this point, the class is not actually creating prerenders, but just 43 // At this point, the class is not actually creating prerenders, but just
43 // recording timing stats about the effect prerendering would have. 44 // recording timing stats about the effect prerendering would have.
44 class PrerenderLocalPredictor : public history::VisitDatabaseObserver, 45 class PrerenderLocalPredictor : public history::HistoryServiceObserver,
45 public net::URLFetcherDelegate { 46 public net::URLFetcherDelegate {
46 public: 47 public:
47 struct LocalPredictorURLInfo; 48 struct LocalPredictorURLInfo;
48 struct CandidatePrerenderInfo; 49 struct CandidatePrerenderInfo;
49 // A class simulating a set of URLs prefetched, for statistical purposes. 50 // A class simulating a set of URLs prefetched, for statistical purposes.
50 class PrefetchList; 51 class PrefetchList;
51 enum Event { 52 enum Event {
52 EVENT_CONSTRUCTED = 0, 53 EVENT_CONSTRUCTED = 0,
53 EVENT_INIT_SCHEDULED = 1, 54 EVENT_INIT_SCHEDULED = 1,
54 EVENT_INIT_STARTED = 2, 55 EVENT_INIT_STARTED = 2,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 }; 150 };
150 151
151 // A PrerenderLocalPredictor is owned by the PrerenderManager specified 152 // A PrerenderLocalPredictor is owned by the PrerenderManager specified
152 // in the constructor. It will be destoryed at the time its owning 153 // in the constructor. It will be destoryed at the time its owning
153 // PrerenderManager is destroyed. 154 // PrerenderManager is destroyed.
154 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); 155 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager);
155 virtual ~PrerenderLocalPredictor(); 156 virtual ~PrerenderLocalPredictor();
156 157
157 void Shutdown(); 158 void Shutdown();
158 159
159 // history::VisitDatabaseObserver implementation 160 // history::HistoryServiceObserver:
160 virtual void OnAddVisit(const history::BriefVisitInfo& info) override; 161 virtual void OnAddVisit(HistoryService* history_service,
162 const history::BriefVisitInfo& info) override;
161 163
162 void OnGetInitialVisitHistory( 164 void OnGetInitialVisitHistory(
163 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history); 165 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history);
164 166
165 void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time); 167 void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time);
166 168
167 void OnTabHelperURLSeen(const GURL& url, content::WebContents* web_contents); 169 void OnTabHelperURLSeen(const GURL& url, content::WebContents* web_contents);
168 170
169 // net::URLFetcherDelegate implementation: 171 // net::URLFetcherDelegate implementation:
170 void virtual OnURLFetchComplete(const net::URLFetcher* source) override; 172 void virtual OnURLFetchComplete(const net::URLFetcher* source) override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 OutstandingFetchers; 214 OutstandingFetchers;
213 OutstandingFetchers outstanding_prerender_service_requests_; 215 OutstandingFetchers outstanding_prerender_service_requests_;
214 PrerenderManager* prerender_manager_; 216 PrerenderManager* prerender_manager_;
215 base::OneShotTimer<PrerenderLocalPredictor> timer_; 217 base::OneShotTimer<PrerenderLocalPredictor> timer_;
216 218
217 // Delay after which to initialize, to avoid putting to much load on the 219 // Delay after which to initialize, to avoid putting to much load on the
218 // database thread early on when Chrome is starting up. 220 // database thread early on when Chrome is starting up.
219 static const int kInitDelayMs = 5 * 1000; 221 static const int kInitDelayMs = 5 * 1000;
220 222
221 // Whether we're registered with the history service as a 223 // Whether we're registered with the history service as a
222 // history::VisitDatabaseObserver. 224 // history::HistoryServiceObserver.
223 bool is_visit_database_observer_; 225 bool is_history_service_observer_;
224 226
225 base::CancelableTaskTracker history_db_tracker_; 227 base::CancelableTaskTracker history_db_tracker_;
226 228
227 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_; 229 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_;
228 230
229 scoped_ptr<PrerenderProperties> current_prerender_; 231 scoped_ptr<PrerenderProperties> current_prerender_;
230 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; 232 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_;
231 233
232 ScopedVector<PrerenderProperties> issued_prerenders_; 234 ScopedVector<PrerenderProperties> issued_prerenders_;
233 235
234 base::hash_set<int64> url_whitelist_; 236 base::hash_set<int64> url_whitelist_;
235 237
236 scoped_ptr<PrefetchList> prefetch_list_; 238 scoped_ptr<PrefetchList> prefetch_list_;
237 239
238 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; 240 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_;
239 241
240 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); 242 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor);
241 }; 243 };
242 244
243 } // namespace prerender 245 } // namespace prerender
244 246
245 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ 247 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698