| Index: chrome/browser/prerender/prerender_local_predictor.h
|
| ===================================================================
|
| --- chrome/browser/prerender/prerender_local_predictor.h (revision 198752)
|
| +++ chrome/browser/prerender/prerender_local_predictor.h (working copy)
|
| @@ -8,6 +8,7 @@
|
| #include <vector>
|
|
|
| #include "base/hash_tables.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "base/timer.h"
|
| #include "chrome/browser/common/cancelable_request.h"
|
| #include "chrome/browser/history/visit_database.h"
|
| @@ -15,8 +16,17 @@
|
|
|
| class HistoryService;
|
|
|
| +namespace content {
|
| +class SessionStorageNamespace;
|
| +}
|
| +
|
| +namespace gfx {
|
| +class Size;
|
| +}
|
| +
|
| namespace prerender {
|
|
|
| +class PrerenderHandle;
|
| class PrerenderManager;
|
|
|
| // PrerenderLocalPredictor maintains local browsing history to make prerender
|
| @@ -25,6 +35,8 @@
|
| // recording timing stats about the effect prerendering would have.
|
| class PrerenderLocalPredictor : public history::VisitDatabaseObserver {
|
| public:
|
| + struct LocalPredictorURLInfo;
|
| + struct LocalPredictorURLLookupInfo;
|
| enum Event {
|
| EVENT_CONSTRUCTED = 0,
|
| EVENT_INIT_SCHEDULED = 1,
|
| @@ -54,6 +66,24 @@
|
| EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST_ROOT_PAGE = 25,
|
| EVENT_PRERENDER_URL_LOOKUP_RESULT_EXTENDED_ROOT_PAGE = 26,
|
| EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE_HTTP = 27,
|
| + EVENT_PRERENDER_URL_LOOKUP_FAILED = 28,
|
| + EVENT_PRERENDER_URL_LOOKUP_NO_SOURCE_WEBCONTENTS_FOUND = 29,
|
| + EVENT_PRERENDER_URL_LOOKUP_NO_LOGGED_IN_TABLE_FOUND = 30,
|
| + EVENT_PRERENDER_URL_LOOKUP_ISSUING_LOGGED_IN_LOOKUP = 31,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_STARTED = 32,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_NO_URL = 33,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_PRIORITY_TOO_LOW = 34,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_URLS_IDENTICAL_BUT_FRAGMENT = 35,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_HTTPS = 36,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_ROOT_PAGE = 37,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_LOGOUT_URL = 38,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_LOGIN_URL = 39,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_NOT_LOGGED_IN = 40,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_NOT_PRERENDERING = 41,
|
| + EVENT_CONTINUE_PRERENDER_CHECK_ISSUING_PRERENDER = 42,
|
| + EVENT_ISSUING_PRERENDER = 43,
|
| + EVENT_NO_PRERENDER_CANDIDATES = 44,
|
| + EVENT_GOT_HISTORY_ISSUING_LOOKUP = 45,
|
| EVENT_MAX_VALUE
|
| };
|
|
|
| @@ -68,7 +98,7 @@
|
| // history::VisitDatabaseObserver implementation
|
| virtual void OnAddVisit(const history::BriefVisitInfo& info) OVERRIDE;
|
|
|
| - void OnLookupURL(history::URLID url_id, double priority, const GURL& url);
|
| + void OnLookupURL(scoped_ptr<LocalPredictorURLLookupInfo> info);
|
|
|
| void OnGetInitialVisitHistory(
|
| scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history);
|
| @@ -76,11 +106,11 @@
|
| void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time);
|
|
|
| private:
|
| - struct PrerenderData;
|
| + struct PrerenderProperties;
|
| HistoryService* GetHistoryIfExists() const;
|
| void Init();
|
| - bool IsPrerenderStillValid(PrerenderData* prerender) const;
|
| - bool DoesPrerenderMatchPLTRecord(PrerenderData* prerender,
|
| + bool IsPrerenderStillValid(PrerenderProperties* prerender) const;
|
| + bool DoesPrerenderMatchPLTRecord(PrerenderProperties* prerender,
|
| const GURL& url,
|
| base::TimeDelta plt) const;
|
| void RecordEvent(Event event) const;
|
| @@ -90,6 +120,16 @@
|
| // and based on what its priority is).
|
| bool ShouldReplaceCurrentPrerender(double priority) const;
|
|
|
| + void ContinuePrerenderCheck(
|
| + scoped_refptr<content::SessionStorageNamespace> session_storage_namespace,
|
| + scoped_ptr<gfx::Size> size,
|
| + scoped_ptr<LocalPredictorURLLookupInfo> info);
|
| + void LogCandidateURLStats(const GURL& url) const;
|
| + void IssuePrerender(scoped_refptr<content::SessionStorageNamespace>
|
| + session_storage_namespace,
|
| + scoped_ptr<gfx::Size> size,
|
| + scoped_ptr<LocalPredictorURLInfo> info);
|
| +
|
| PrerenderManager* prerender_manager_;
|
| base::OneShotTimer<PrerenderLocalPredictor> timer_;
|
|
|
| @@ -105,11 +145,16 @@
|
|
|
| scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history_;
|
|
|
| - scoped_ptr<PrerenderData> current_prerender_;
|
| - scoped_ptr<PrerenderData> last_swapped_in_prerender_;
|
| + scoped_ptr<PrerenderProperties> current_prerender_;
|
| + scoped_ptr<PrerenderProperties> last_swapped_in_prerender_;
|
|
|
| + scoped_ptr<PrerenderHandle> prerender_handle_;
|
| + double current_prerender_priority_;
|
| +
|
| base::hash_set<int64> url_whitelist_;
|
|
|
| + base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor);
|
| };
|
|
|
|
|