| 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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // PrerenderLocalPredictor maintains local browsing history to make prerender | 40 // PrerenderLocalPredictor maintains local browsing history to make prerender |
| 41 // predictions. | 41 // predictions. |
| 42 // At this point, the class is not actually creating prerenders, but just | 42 // At this point, the class is not actually creating prerenders, but just |
| 43 // recording timing stats about the effect prerendering would have. | 43 // recording timing stats about the effect prerendering would have. |
| 44 class PrerenderLocalPredictor : public history::VisitDatabaseObserver, | 44 class PrerenderLocalPredictor : public history::VisitDatabaseObserver, |
| 45 public net::URLFetcherDelegate { | 45 public net::URLFetcherDelegate { |
| 46 public: | 46 public: |
| 47 struct LocalPredictorURLInfo; | 47 struct LocalPredictorURLInfo; |
| 48 struct CandidatePrerenderInfo; | 48 struct CandidatePrerenderInfo; |
| 49 // A class simulating a set of URLs prefetched, for statistical purposes. |
| 50 class PrefetchList; |
| 49 enum Event { | 51 enum Event { |
| 50 EVENT_CONSTRUCTED = 0, | 52 EVENT_CONSTRUCTED = 0, |
| 51 EVENT_INIT_SCHEDULED = 1, | 53 EVENT_INIT_SCHEDULED = 1, |
| 52 EVENT_INIT_STARTED = 2, | 54 EVENT_INIT_STARTED = 2, |
| 53 EVENT_INIT_FAILED_NO_HISTORY = 3, | 55 EVENT_INIT_FAILED_NO_HISTORY = 3, |
| 54 EVENT_INIT_SUCCEEDED = 4, | 56 EVENT_INIT_SUCCEEDED = 4, |
| 55 EVENT_ADD_VISIT = 5, | 57 EVENT_ADD_VISIT = 5, |
| 56 EVENT_ADD_VISIT_INITIALIZED = 6, | 58 EVENT_ADD_VISIT_INITIALIZED = 6, |
| 57 EVENT_ADD_VISIT_PRERENDER_IDENTIFIED = 7, | 59 EVENT_ADD_VISIT_PRERENDER_IDENTIFIED = 7, |
| 58 EVENT_ADD_VISIT_RELEVANT_TRANSITION = 8, | 60 EVENT_ADD_VISIT_RELEVANT_TRANSITION = 8, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_MERGEABLE = 80, | 132 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_MERGEABLE = 80, |
| 131 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE = 81, | 133 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE = 81, |
| 132 EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED = 82, | 134 EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED = 82, |
| 133 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_NOT_SKIPPED = 83, | 135 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_NOT_SKIPPED = 83, |
| 134 EVENT_PRERENDER_SERIVCE_RETURNED_HINTING_CANDIDATES = 84, | 136 EVENT_PRERENDER_SERIVCE_RETURNED_HINTING_CANDIDATES = 84, |
| 135 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_ALIAS = 85, | 137 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_ALIAS = 85, |
| 136 EVENT_TAB_HELPER_URL_SEEN_MATCH_ENTRY = 86, | 138 EVENT_TAB_HELPER_URL_SEEN_MATCH_ENTRY = 86, |
| 137 EVENT_TAB_HELPER_URL_SEEN_MATCH_BROWSER_NAVIGATE = 87, | 139 EVENT_TAB_HELPER_URL_SEEN_MATCH_BROWSER_NAVIGATE = 87, |
| 138 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_ENTRY = 88, | 140 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_ENTRY = 88, |
| 139 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_BROWSER_NAVIGATE = 89, | 141 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_BROWSER_NAVIGATE = 89, |
| 142 EVENT_PREFETCH_LIST_ADDED = 90, |
| 143 EVENT_PREFETCH_LIST_SEEN_TABCONTENTS = 91, |
| 144 EVENT_PREFETCH_LIST_SEEN_HISTORY = 92, |
| 140 EVENT_MAX_VALUE | 145 EVENT_MAX_VALUE |
| 141 }; | 146 }; |
| 142 | 147 |
| 143 // A PrerenderLocalPredictor is owned by the PrerenderManager specified | 148 // A PrerenderLocalPredictor is owned by the PrerenderManager specified |
| 144 // in the constructor. It will be destoryed at the time its owning | 149 // in the constructor. It will be destoryed at the time its owning |
| 145 // PrerenderManager is destroyed. | 150 // PrerenderManager is destroyed. |
| 146 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); | 151 explicit PrerenderLocalPredictor(PrerenderManager* prerender_manager); |
| 147 virtual ~PrerenderLocalPredictor(); | 152 virtual ~PrerenderLocalPredictor(); |
| 148 | 153 |
| 149 void Shutdown(); | 154 void Shutdown(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 186 |
| 182 // Returns an element of issued_prerenders_, which should be replaced | 187 // Returns an element of issued_prerenders_, which should be replaced |
| 183 // by a new prerender of the priority indicated, or NULL, if the priority | 188 // by a new prerender of the priority indicated, or NULL, if the priority |
| 184 // is too low (or if the URL requested is already prerendering). | 189 // is too low (or if the URL requested is already prerendering). |
| 185 PrerenderProperties* GetIssuedPrerenderSlotForPriority(const GURL& url, | 190 PrerenderProperties* GetIssuedPrerenderSlotForPriority(const GURL& url, |
| 186 double priority); | 191 double priority); |
| 187 | 192 |
| 188 void ContinuePrerenderCheck(scoped_ptr<CandidatePrerenderInfo> info); | 193 void ContinuePrerenderCheck(scoped_ptr<CandidatePrerenderInfo> info); |
| 189 void LogCandidateURLStats(const GURL& url) const; | 194 void LogCandidateURLStats(const GURL& url) const; |
| 190 void IssuePrerender(CandidatePrerenderInfo* info, | 195 void IssuePrerender(CandidatePrerenderInfo* info, |
| 191 LocalPredictorURLInfo* url_info, | 196 LocalPredictorURLInfo* url_info); |
| 192 PrerenderProperties* prerender_properties); | |
| 193 void MaybeCancelURLFetcher(net::URLFetcher* fetcher); | 197 void MaybeCancelURLFetcher(net::URLFetcher* fetcher); |
| 194 // Returns true if the parsed response is semantically correct and could | 198 // Returns true if the parsed response is semantically correct and could |
| 195 // be fully applied. | 199 // be fully applied. |
| 196 bool ApplyParsedPrerenderServiceResponse( | 200 bool ApplyParsedPrerenderServiceResponse( |
| 197 base::DictionaryValue* dict, | 201 base::DictionaryValue* dict, |
| 198 CandidatePrerenderInfo* info, | 202 CandidatePrerenderInfo* info, |
| 199 bool* hinting_timed_out, | 203 bool* hinting_timed_out, |
| 200 bool* hinting_url_lookup_timed_out, | 204 bool* hinting_url_lookup_timed_out, |
| 201 bool* candidate_url_lookup_timed_out); | 205 bool* candidate_url_lookup_timed_out); |
| 202 void ProcessNamespaceMergeResult( | 206 void ProcessNamespaceMergeResult( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 221 | 225 |
| 222 scoped_ptr<PrerenderProperties> current_prerender_; | 226 scoped_ptr<PrerenderProperties> current_prerender_; |
| 223 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; | 227 scoped_ptr<PrerenderProperties> last_swapped_in_prerender_; |
| 224 | 228 |
| 225 ScopedVector<PrerenderProperties> issued_prerenders_; | 229 ScopedVector<PrerenderProperties> issued_prerenders_; |
| 226 | 230 |
| 227 base::hash_set<int64> url_whitelist_; | 231 base::hash_set<int64> url_whitelist_; |
| 228 | 232 |
| 229 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; | 233 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; |
| 230 | 234 |
| 235 scoped_ptr<PrefetchList> prefetch_list_; |
| 236 |
| 231 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); | 237 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); |
| 232 }; | 238 }; |
| 233 | 239 |
| 234 } // namespace prerender | 240 } // namespace prerender |
| 235 | 241 |
| 236 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ | 242 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ |
| OLD | NEW |