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

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

Issue 14949012: Add instrumentation to see how often a local predictor prerender could be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "chrome/browser/common/cancelable_request.h" 13 #include "chrome/browser/common/cancelable_request.h"
14 #include "chrome/browser/history/visit_database.h" 14 #include "chrome/browser/history/visit_database.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 16
17 class HistoryService; 17 class HistoryService;
18 18
19 namespace content { 19 namespace content {
20 class SessionStorageNamespace; 20 class SessionStorageNamespace;
21 class WebContents;
21 } 22 }
22 23
23 namespace gfx { 24 namespace gfx {
24 class Size; 25 class Size;
25 } 26 }
26 27
27 namespace prerender { 28 namespace prerender {
28 29
29 class PrerenderHandle; 30 class PrerenderHandle;
30 class PrerenderManager; 31 class PrerenderManager;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 EVENT_CONTINUE_PRERENDER_CHECK_HTTPS = 36, 78 EVENT_CONTINUE_PRERENDER_CHECK_HTTPS = 36,
78 EVENT_CONTINUE_PRERENDER_CHECK_ROOT_PAGE = 37, 79 EVENT_CONTINUE_PRERENDER_CHECK_ROOT_PAGE = 37,
79 EVENT_CONTINUE_PRERENDER_CHECK_LOGOUT_URL = 38, 80 EVENT_CONTINUE_PRERENDER_CHECK_LOGOUT_URL = 38,
80 EVENT_CONTINUE_PRERENDER_CHECK_LOGIN_URL = 39, 81 EVENT_CONTINUE_PRERENDER_CHECK_LOGIN_URL = 39,
81 EVENT_CONTINUE_PRERENDER_CHECK_NOT_LOGGED_IN = 40, 82 EVENT_CONTINUE_PRERENDER_CHECK_NOT_LOGGED_IN = 40,
82 EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_NOT_PRERENDERING = 41, 83 EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_NOT_PRERENDERING = 41,
83 EVENT_CONTINUE_PRERENDER_CHECK_ISSUING_PRERENDER = 42, 84 EVENT_CONTINUE_PRERENDER_CHECK_ISSUING_PRERENDER = 42,
84 EVENT_ISSUING_PRERENDER = 43, 85 EVENT_ISSUING_PRERENDER = 43,
85 EVENT_NO_PRERENDER_CANDIDATES = 44, 86 EVENT_NO_PRERENDER_CANDIDATES = 44,
86 EVENT_GOT_HISTORY_ISSUING_LOOKUP = 45, 87 EVENT_GOT_HISTORY_ISSUING_LOOKUP = 45,
88 EVENT_TAB_HELPER_URL_SEEN = 46,
89 EVENT_TAB_HELPER_URL_SEEN_MATCH = 47,
90 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH = 48,
87 EVENT_MAX_VALUE 91 EVENT_MAX_VALUE
88 }; 92 };
89 93
90 // A PrerenderLocalPredictor is owned by the PrerenderManager specified 94 // A PrerenderLocalPredictor is owned by the PrerenderManager specified
91 // in the constructor. It will be destoryed at the time its owning 95 // in the constructor. It will be destoryed at the time its owning
92 // PrerenderManager is destroyed. 96 // PrerenderManager is destroyed.
93 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); 97 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager);
94 virtual ~PrerenderLocalPredictor(); 98 virtual ~PrerenderLocalPredictor();
95 99
96 void Shutdown(); 100 void Shutdown();
97 101
98 // history::VisitDatabaseObserver implementation 102 // history::VisitDatabaseObserver implementation
99 virtual void OnAddVisit(const history::BriefVisitInfo& info) OVERRIDE; 103 virtual void OnAddVisit(const history::BriefVisitInfo& info) OVERRIDE;
100 104
101 void OnGetInitialVisitHistory( 105 void OnGetInitialVisitHistory(
102 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history); 106 scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history);
103 107
104 void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time); 108 void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time);
105 109
110 void OnTabHelperURLSeen(const GURL& url, content::WebContents* web_contents);
111
106 private: 112 private:
107 struct PrerenderProperties; 113 struct PrerenderProperties;
108 HistoryService* GetHistoryIfExists() const; 114 HistoryService* GetHistoryIfExists() const;
109 void Init(); 115 void Init();
110 bool IsPrerenderStillValid(PrerenderProperties* prerender) const; 116 bool IsPrerenderStillValid(PrerenderProperties* prerender) const;
111 bool DoesPrerenderMatchPLTRecord(PrerenderProperties* prerender, 117 bool DoesPrerenderMatchPLTRecord(PrerenderProperties* prerender,
112 const GURL& url, 118 const GURL& url,
113 base::TimeDelta plt) const; 119 base::TimeDelta plt) const;
114 void RecordEvent(Event event) const; 120 void RecordEvent(Event event) const;
115 121
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 scoped_ptr<PrerenderProperties> current_prerender_; 154 scoped_ptr<PrerenderProperties> current_prerender_;
149 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; 155 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_;
150 156
151 scoped_ptr<PrerenderHandle> prerender_handle_; 157 scoped_ptr<PrerenderHandle> prerender_handle_;
152 double current_prerender_priority_; 158 double current_prerender_priority_;
153 159
154 base::hash_set<int64> url_whitelist_; 160 base::hash_set<int64> url_whitelist_;
155 161
156 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; 162 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_;
157 163
164 bool current_prerender_would_have_matched_;
Shishir 2013/05/14 18:19:34 Comment on var - and the fact that it is only used
tburkard 2013/05/14 19:28:06 Done.
165
158 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); 166 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor);
159 }; 167 };
160 168
161 } // namespace prerender 169 } // namespace prerender
162 170
163 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ 171 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698