Chromium Code Reviews| Index: chrome/browser/prerender/prerender_local_predictor.h |
| =================================================================== |
| --- chrome/browser/prerender/prerender_local_predictor.h (revision 220426) |
| +++ chrome/browser/prerender/prerender_local_predictor.h (working copy) |
| @@ -5,6 +5,7 @@ |
| #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
| #define CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
| +#include <map> |
| #include <vector> |
| #include "base/containers/hash_tables.h" |
| @@ -13,6 +14,7 @@ |
| #include "base/timer/timer.h" |
| #include "chrome/browser/common/cancelable_request.h" |
| #include "chrome/browser/history/visit_database.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| #include "url/gurl.h" |
| class HistoryService; |
| @@ -35,10 +37,11 @@ |
| // predictions. |
| // At this point, the class is not actually creating prerenders, but just |
| // recording timing stats about the effect prerendering would have. |
| -class PrerenderLocalPredictor : public history::VisitDatabaseObserver { |
| +class PrerenderLocalPredictor : public history::VisitDatabaseObserver, |
| + public net::URLFetcherDelegate { |
| public: |
| struct LocalPredictorURLInfo; |
| - struct LocalPredictorURLLookupInfo; |
| + struct CandidatePrerenderInfo; |
| enum Event { |
| EVENT_CONSTRUCTED = 0, |
| EVENT_INIT_SCHEDULED = 1, |
| @@ -96,6 +99,19 @@ |
| EVENT_ISSUE_PRERENDER_NEW_PRERENDER = 53, |
| EVENT_ISSUE_PRERENDER_CANCELLED_OLD_PRERENDER = 54, |
| EVENT_CONTINUE_PRERENDER_CHECK_FALLTHROUGH_PRERENDERING = 55, |
| + EVENT_PRERENDER_URL_LOOKUP_SUCCESS = 56, |
| + EVENT_PRERENDER_SERVICE_DISABLED = 57, |
| + EVENT_PRERENDER_SERVICE_ISSUED_LOOKUP = 58, |
| + EVENT_PRERENDER_SERVICE_LOOKUP_TIMED_OUT = 59, |
| + EVENT_PRERENDER_SERVICE_RECEIVED_RESULT = 60, |
| + EVENT_PRERENDER_SERVICE_NO_RECORD_FOR_RESULT = 61, |
| + EVENT_PRERENDER_SERVICE_PARSED_CORRECTLY = 62, |
| + EVENT_PRERENDER_SERVICE_PARSE_ERROR = 63, |
| + EVENT_PRERENDER_SERVICE_PARSE_ERROR_INCORRECT_JSON = 64, |
| + EVENT_PRERENDER_SERVICE_HINTING_TIMED_OUT = 65, |
| + EVENT_PRERENDER_SERVICE_HINTING_URL_LOOKUP_TIMED_OUT = 66, |
| + EVENT_PRERENDER_SERVICE_CANDIDATE_URL_LOOKUP_TIMED_OUT = 67, |
| + EVENT_CONTINUE_PRERENDER_CHECK_ON_SERVICE_WHITELIST = 68, |
| EVENT_MAX_VALUE |
| }; |
| @@ -117,6 +133,8 @@ |
| void OnTabHelperURLSeen(const GURL& url, content::WebContents* web_contents); |
| + void virtual OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
|
jam
2013/08/30 20:34:30
usually we write
// net::URLFetcherDelegate imple
tburkard
2013/08/30 20:59:01
Done.
|
| + |
| private: |
| struct PrerenderProperties; |
| HistoryService* GetHistoryIfExists() const; |
| @@ -127,23 +145,28 @@ |
| base::TimeDelta plt) const; |
| void RecordEvent(Event event) const; |
| - void OnLookupURL(scoped_ptr<LocalPredictorURLLookupInfo> info); |
| + void OnLookupURL(scoped_ptr<CandidatePrerenderInfo> info); |
| + // Lookup the prerender candidate in the Prerender Service (if applicable). |
| + void DoPrerenderServiceCheck(scoped_ptr<CandidatePrerenderInfo> info); |
| + |
| + // Lookup the prerender candidate in the LoggedIn Predictor. |
| + void DoLoggedInLookup(scoped_ptr<CandidatePrerenderInfo> info); |
| + |
| // Returns an element of issued_prerenders_, which should be replaced |
| // by a new prerender of the priority indicated, or NULL, if the priority |
| // is too low. |
| PrerenderProperties* GetIssuedPrerenderSlotForPriority(double priority); |
| - void ContinuePrerenderCheck( |
| - scoped_refptr<content::SessionStorageNamespace> session_storage_namespace, |
| - scoped_ptr<gfx::Size> size, |
| - scoped_ptr<LocalPredictorURLLookupInfo> info); |
| + void ContinuePrerenderCheck(scoped_ptr<CandidatePrerenderInfo> 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, |
| + void IssuePrerender(scoped_ptr<CandidatePrerenderInfo> info, |
| + scoped_ptr<LocalPredictorURLInfo> url_info, |
| PrerenderProperties* prerender_properties); |
| + void MaybeCancelURLFetcher(net::URLFetcher* fetcher); |
| + typedef std::map<net::URLFetcher*, CandidatePrerenderInfo*> |
| + OutstandingFetchers; |
|
jam
2013/08/30 20:34:30
indent
tburkard
2013/08/30 20:59:01
Done.
|
| + OutstandingFetchers outstanding_prerender_service_requests_; |
| PrerenderManager* prerender_manager_; |
| base::OneShotTimer<PrerenderLocalPredictor> timer_; |