| OLD | NEW | 
|---|
| 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  Loading... | 
| 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, | 
|  | 91     EVENT_PRERENDER_URL_LOOKUP_MULTIPLE_SOURCE_WEBCONTENTS_FOUND = 49, | 
| 87     EVENT_MAX_VALUE | 92     EVENT_MAX_VALUE | 
| 88   }; | 93   }; | 
| 89 | 94 | 
| 90   // A PrerenderLocalPredictor is owned by the PrerenderManager specified | 95   // A PrerenderLocalPredictor is owned by the PrerenderManager specified | 
| 91   // in the constructor.  It will be destoryed at the time its owning | 96   // in the constructor.  It will be destoryed at the time its owning | 
| 92   // PrerenderManager is destroyed. | 97   // PrerenderManager is destroyed. | 
| 93   explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); | 98   explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); | 
| 94   virtual ~PrerenderLocalPredictor(); | 99   virtual ~PrerenderLocalPredictor(); | 
| 95 | 100 | 
| 96   void Shutdown(); | 101   void Shutdown(); | 
| 97 | 102 | 
| 98   // history::VisitDatabaseObserver implementation | 103   // history::VisitDatabaseObserver implementation | 
| 99   virtual void OnAddVisit(const history::BriefVisitInfo& info) OVERRIDE; | 104   virtual void OnAddVisit(const history::BriefVisitInfo& info) OVERRIDE; | 
| 100 | 105 | 
| 101   void OnGetInitialVisitHistory( | 106   void OnGetInitialVisitHistory( | 
| 102       scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history); | 107       scoped_ptr<std::vector<history::BriefVisitInfo> > visit_history); | 
| 103 | 108 | 
| 104   void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time); | 109   void OnPLTEventForURL(const GURL& url, base::TimeDelta page_load_time); | 
| 105 | 110 | 
|  | 111   void OnTabHelperURLSeen(const GURL& url, content::WebContents* web_contents); | 
|  | 112 | 
| 106  private: | 113  private: | 
| 107   struct PrerenderProperties; | 114   struct PrerenderProperties; | 
| 108   HistoryService* GetHistoryIfExists() const; | 115   HistoryService* GetHistoryIfExists() const; | 
| 109   void Init(); | 116   void Init(); | 
| 110   bool IsPrerenderStillValid(PrerenderProperties* prerender) const; | 117   bool IsPrerenderStillValid(PrerenderProperties* prerender) const; | 
| 111   bool DoesPrerenderMatchPLTRecord(PrerenderProperties* prerender, | 118   bool DoesPrerenderMatchPLTRecord(PrerenderProperties* prerender, | 
| 112                                    const GURL& url, | 119                                    const GURL& url, | 
| 113                                    base::TimeDelta plt) const; | 120                                    base::TimeDelta plt) const; | 
| 114   void RecordEvent(Event event) const; | 121   void RecordEvent(Event event) const; | 
| 115 | 122 | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148   scoped_ptr<PrerenderProperties> current_prerender_; | 155   scoped_ptr<PrerenderProperties> current_prerender_; | 
| 149   scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; | 156   scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; | 
| 150 | 157 | 
| 151   scoped_ptr<PrerenderHandle> prerender_handle_; | 158   scoped_ptr<PrerenderHandle> prerender_handle_; | 
| 152   double current_prerender_priority_; | 159   double current_prerender_priority_; | 
| 153 | 160 | 
| 154   base::hash_set<int64> url_whitelist_; | 161   base::hash_set<int64> url_whitelist_; | 
| 155 | 162 | 
| 156   base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; | 163   base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; | 
| 157 | 164 | 
|  | 165   // Indicates whether the current prerender represented by prerender_handle_ | 
|  | 166   // matched a load in some tab contents, to shed light on how many prerenders | 
|  | 167   // that could have possibily been swapped in were not swapped in. For | 
|  | 168   // measurement purposes only. | 
|  | 169   bool current_prerender_would_have_matched_; | 
|  | 170 | 
| 158   DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); | 171   DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); | 
| 159 }; | 172 }; | 
| 160 | 173 | 
| 161 }  // namespace prerender | 174 }  // namespace prerender | 
| 162 | 175 | 
| 163 #endif  // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ | 176 #endif  // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ | 
| OLD | NEW | 
|---|