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

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

Issue 797443002: Remove prerender sessionStorage namespace merging (1/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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
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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
15 #include "base/task/cancelable_task_tracker.h" 15 #include "base/task/cancelable_task_tracker.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "components/history/core/browser/history_service_observer.h" 17 #include "components/history/core/browser/history_service_observer.h"
18 #include "components/history/core/browser/visit_database.h" 18 #include "components/history/core/browser/visit_database.h"
19 #include "content/public/browser/session_storage_namespace.h"
20 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
21 #include "url/gurl.h" 20 #include "url/gurl.h"
22 21
23 class HistoryService; 22 class HistoryService;
24 23
25 namespace base { 24 namespace base {
26 class DictionaryValue; 25 class DictionaryValue;
27 } 26 }
28 27
29 namespace content { 28 namespace content {
30 class WebContents; 29 class WebContents;
31 } 30 }
32 31
33 namespace gfx { 32 namespace gfx {
34 class Size; 33 class Size;
35 } 34 }
36 35
37 namespace prerender { 36 namespace prerender {
38 37
39 class PrerenderHandle; 38 class PrerenderHandle;
40 class PrerenderManager; 39 class PrerenderManager;
41 40
42 // PrerenderLocalPredictor maintains local browsing history to make prerender 41 // PrerenderLocalPredictor maintains local browsing history to make prerender
43 // predictions. 42 // predictions.
44 // At this point, the class is not actually creating prerenders, but just 43 // At this point, the class is not actually creating prerenders, but just
45 // recording timing stats about the effect prerendering would have. 44 // recording timing stats about the effect prerendering would have.
45 //
46 // TODO(davidben): Prune this class down to only what it's still being used for.
46 class PrerenderLocalPredictor : public history::HistoryServiceObserver, 47 class PrerenderLocalPredictor : public history::HistoryServiceObserver,
47 public net::URLFetcherDelegate { 48 public net::URLFetcherDelegate {
48 public: 49 public:
49 struct LocalPredictorURLInfo; 50 struct LocalPredictorURLInfo;
50 struct CandidatePrerenderInfo; 51 struct CandidatePrerenderInfo;
51 // A class simulating a set of URLs prefetched, for statistical purposes. 52 // A class simulating a set of URLs prefetched, for statistical purposes.
52 class PrefetchList; 53 class PrefetchList;
53 enum Event { 54 enum Event {
54 EVENT_CONSTRUCTED = 0, 55 EVENT_CONSTRUCTED = 0,
55 EVENT_INIT_SCHEDULED = 1, 56 EVENT_INIT_SCHEDULED = 1,
56 EVENT_INIT_STARTED = 2, 57 EVENT_INIT_STARTED = 2,
57 EVENT_INIT_FAILED_NO_HISTORY = 3, 58 EVENT_INIT_FAILED_NO_HISTORY = 3,
58 EVENT_INIT_SUCCEEDED = 4, 59 EVENT_INIT_SUCCEEDED = 4,
59 EVENT_ADD_VISIT = 5, 60 EVENT_ADD_VISIT = 5,
60 EVENT_ADD_VISIT_INITIALIZED = 6, 61 EVENT_ADD_VISIT_INITIALIZED = 6,
61 EVENT_ADD_VISIT_PRERENDER_IDENTIFIED = 7, 62 EVENT_ADD_VISIT_PRERENDER_IDENTIFIED = 7,
62 EVENT_ADD_VISIT_RELEVANT_TRANSITION = 8, 63 EVENT_ADD_VISIT_RELEVANT_TRANSITION = 8,
63 EVENT_ADD_VISIT_IDENTIFIED_PRERENDER_CANDIDATE = 9, 64 EVENT_ADD_VISIT_IDENTIFIED_PRERENDER_CANDIDATE = 9,
64 EVENT_ADD_VISIT_PRERENDERING = 10, 65 EVENT_ADD_VISIT_PRERENDERING = 10,
65 EVENT_GOT_PRERENDER_URL = 11, 66 // Obsolete: EVENT_GOT_PRERENDER_URL = 11,
66 EVENT_ERROR_NO_PRERENDER_URL_FOR_PLT = 12, 67 EVENT_ERROR_NO_PRERENDER_URL_FOR_PLT = 12,
67 EVENT_ADD_VISIT_PRERENDERING_EXTENDED = 13, 68 EVENT_ADD_VISIT_PRERENDERING_EXTENDED = 13,
68 EVENT_PRERENDER_URL_LOOKUP_RESULT = 14, 69 EVENT_PRERENDER_URL_LOOKUP_RESULT = 14,
69 EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE = 15, 70 EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE = 15,
70 EVENT_PRERENDER_URL_LOOKUP_RESULT_IS_HTTP = 16, 71 EVENT_PRERENDER_URL_LOOKUP_RESULT_IS_HTTP = 16,
71 EVENT_PRERENDER_URL_LOOKUP_RESULT_HAS_QUERY_STRING = 17, 72 EVENT_PRERENDER_URL_LOOKUP_RESULT_HAS_QUERY_STRING = 17,
72 EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGOUT = 18, 73 EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGOUT = 18,
73 EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGIN = 19, 74 EVENT_PRERENDER_URL_LOOKUP_RESULT_CONTAINS_LOGIN = 19,
74 EVENT_START_URL_LOOKUP = 20, 75 EVENT_START_URL_LOOKUP = 20,
75 EVENT_ADD_VISIT_NOT_ROOTPAGE = 21, 76 // Obsolete: EVENT_ADD_VISIT_NOT_ROOTPAGE = 21,
76 EVENT_URL_WHITELIST_ERROR = 22, 77 EVENT_URL_WHITELIST_ERROR = 22,
77 EVENT_URL_WHITELIST_OK = 23, 78 EVENT_URL_WHITELIST_OK = 23,
78 EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST = 24, 79 EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST = 24,
79 EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST_ROOT_PAGE = 25, 80 EVENT_PRERENDER_URL_LOOKUP_RESULT_ON_WHITELIST_ROOT_PAGE = 25,
80 EVENT_PRERENDER_URL_LOOKUP_RESULT_EXTENDED_ROOT_PAGE = 26, 81 EVENT_PRERENDER_URL_LOOKUP_RESULT_EXTENDED_ROOT_PAGE = 26,
81 EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE_HTTP = 27, 82 EVENT_PRERENDER_URL_LOOKUP_RESULT_ROOT_PAGE_HTTP = 27,
82 EVENT_PRERENDER_URL_LOOKUP_FAILED = 28, 83 EVENT_PRERENDER_URL_LOOKUP_FAILED = 28,
83 EVENT_PRERENDER_URL_LOOKUP_NO_SOURCE_WEBCONTENTS_FOUND = 29, 84 EVENT_PRERENDER_URL_LOOKUP_NO_SOURCE_WEBCONTENTS_FOUND = 29,
84 EVENT_PRERENDER_URL_LOOKUP_NO_LOGGED_IN_TABLE_FOUND = 30, 85 EVENT_PRERENDER_URL_LOOKUP_NO_LOGGED_IN_TABLE_FOUND = 30,
85 EVENT_PRERENDER_URL_LOOKUP_ISSUING_LOGGED_IN_LOOKUP = 31, 86 EVENT_PRERENDER_URL_LOOKUP_ISSUING_LOGGED_IN_LOOKUP = 31,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EVENT_PRERENDER_SERVICE_PARSE_ERROR = 63, 118 EVENT_PRERENDER_SERVICE_PARSE_ERROR = 63,
118 EVENT_PRERENDER_SERVICE_PARSE_ERROR_INCORRECT_JSON = 64, 119 EVENT_PRERENDER_SERVICE_PARSE_ERROR_INCORRECT_JSON = 64,
119 EVENT_PRERENDER_SERVICE_HINTING_TIMED_OUT = 65, 120 EVENT_PRERENDER_SERVICE_HINTING_TIMED_OUT = 65,
120 EVENT_PRERENDER_SERVICE_HINTING_URL_LOOKUP_TIMED_OUT = 66, 121 EVENT_PRERENDER_SERVICE_HINTING_URL_LOOKUP_TIMED_OUT = 66,
121 EVENT_PRERENDER_SERVICE_CANDIDATE_URL_LOOKUP_TIMED_OUT = 67, 122 EVENT_PRERENDER_SERVICE_CANDIDATE_URL_LOOKUP_TIMED_OUT = 67,
122 EVENT_CONTINUE_PRERENDER_CHECK_ON_SERVICE_WHITELIST = 68, 123 EVENT_CONTINUE_PRERENDER_CHECK_ON_SERVICE_WHITELIST = 68,
123 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_LOCAL = 69, 124 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_LOCAL = 69,
124 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_SERVICE = 70, 125 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_SERVICE = 70,
125 EVENT_ADD_VISIT_RELEVANT_TRANSITION_REPEAT_URL = 71, 126 EVENT_ADD_VISIT_RELEVANT_TRANSITION_REPEAT_URL = 71,
126 EVENT_ADD_VISIT_RELEVANT_TRANSITION_NEW_URL = 72, 127 EVENT_ADD_VISIT_RELEVANT_TRANSITION_NEW_URL = 72,
127 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MISMATCH_NO_NAMESPACE = 73, 128 // Obsolete: EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MISMATCH_NO_NAMESPACE = 73,
128 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MISMATCH_MERGE_ISSUED = 74, 129 // Obsolete: EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MISMATCH_MERGE_ISSUED = 74,
129 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_RECEIVED = 75, 130 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_RECEIVED = 75,
130 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_FOUND = 76, 131 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_FOUND = 76,
131 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_LOGGING = 77, 132 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_LOGGING = 77,
132 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NO_TRANSACTIONS = 78, 133 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NO_TRANSACTIONS = 78,
133 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_TOO_MANY_TRANSACTIONS = 79, 134 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_TOO_MANY_TRANSACTIONS = 7 9,
134 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_MERGEABLE = 80, 135 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NOT_MERGEABLE = 80,
135 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE = 81, 136 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_MERGEABLE = 81,
136 EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED = 82, 137 EVENT_INIT_FAILED_UNENCRYPTED_SYNC_NOT_ENABLED = 82,
137 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_NOT_SKIPPED = 83, 138 EVENT_CONTINUE_PRERENDER_CHECK_EXAMINE_NEXT_URL_NOT_SKIPPED = 83,
138 EVENT_PRERENDER_SERVICE_RETURNED_HINTING_CANDIDATES = 84, 139 EVENT_PRERENDER_SERVICE_RETURNED_HINTING_CANDIDATES = 84,
139 EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_ALIAS = 85, 140 // Obsolete: EVENT_NAMESPACE_MISMATCH_MERGE_RESULT_NAMESPACE_NOT_ALIAS = 85,
140 EVENT_TAB_HELPER_URL_SEEN_MATCH_ENTRY = 86, 141 EVENT_TAB_HELPER_URL_SEEN_MATCH_ENTRY = 86,
141 EVENT_TAB_HELPER_URL_SEEN_MATCH_BROWSER_NAVIGATE = 87, 142 EVENT_TAB_HELPER_URL_SEEN_MATCH_BROWSER_NAVIGATE = 87,
142 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_ENTRY = 88, 143 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_ENTRY = 88,
143 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_BROWSER_NAVIGATE = 89, 144 EVENT_TAB_HELPER_URL_SEEN_NAMESPACE_MATCH_BROWSER_NAVIGATE = 89,
144 EVENT_PREFETCH_LIST_ADDED = 90, 145 EVENT_PREFETCH_LIST_ADDED = 90,
145 EVENT_PREFETCH_LIST_SEEN_TABCONTENTS = 91, 146 EVENT_PREFETCH_LIST_SEEN_TABCONTENTS = 91,
146 EVENT_PREFETCH_LIST_SEEN_HISTORY = 92, 147 EVENT_PREFETCH_LIST_SEEN_HISTORY = 92,
147 EVENT_ISSUE_PRERENDER_CALLED = 93, 148 EVENT_ISSUE_PRERENDER_CALLED = 93,
148 EVENT_ISSUE_PRERENDER_PREFETCH_ENABLED = 94, 149 EVENT_ISSUE_PRERENDER_PREFETCH_ENABLED = 94,
149 EVENT_ISSUE_PRERENDER_PREFETCH_ISSUED = 95, 150 EVENT_ISSUE_PRERENDER_PREFETCH_ISSUED = 95,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 LocalPredictorURLInfo* url_info); 203 LocalPredictorURLInfo* url_info);
203 void MaybeCancelURLFetcher(net::URLFetcher* fetcher); 204 void MaybeCancelURLFetcher(net::URLFetcher* fetcher);
204 // Returns true if the parsed response is semantically correct and could 205 // Returns true if the parsed response is semantically correct and could
205 // be fully applied. 206 // be fully applied.
206 bool ApplyParsedPrerenderServiceResponse( 207 bool ApplyParsedPrerenderServiceResponse(
207 base::DictionaryValue* dict, 208 base::DictionaryValue* dict,
208 CandidatePrerenderInfo* info, 209 CandidatePrerenderInfo* info,
209 bool* hinting_timed_out, 210 bool* hinting_timed_out,
210 bool* hinting_url_lookup_timed_out, 211 bool* hinting_url_lookup_timed_out,
211 bool* candidate_url_lookup_timed_out); 212 bool* candidate_url_lookup_timed_out);
212 void ProcessNamespaceMergeResult(
213 content::SessionStorageNamespace::MergeResult result);
214 typedef std::map<net::URLFetcher*, CandidatePrerenderInfo*> 213 typedef std::map<net::URLFetcher*, CandidatePrerenderInfo*>
215 OutstandingFetchers; 214 OutstandingFetchers;
216 OutstandingFetchers outstanding_prerender_service_requests_; 215 OutstandingFetchers outstanding_prerender_service_requests_;
217 PrerenderManager* prerender_manager_; 216 PrerenderManager* prerender_manager_;
218 base::OneShotTimer<PrerenderLocalPredictor> timer_; 217 base::OneShotTimer<PrerenderLocalPredictor> timer_;
219 218
220 // Delay after which to initialize, to avoid putting to much load on the 219 // Delay after which to initialize, to avoid putting to much load on the
221 // database thread early on when Chrome is starting up. 220 // database thread early on when Chrome is starting up.
222 static const int kInitDelayMs = 5 * 1000; 221 static const int kInitDelayMs = 5 * 1000;
223 222
(...skipping 14 matching lines...) Expand all
238 history_service_observer_; 237 history_service_observer_;
239 238
240 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_; 239 base::WeakPtrFactory<PrerenderLocalPredictor> weak_factory_;
241 240
242 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor); 241 DISALLOW_COPY_AND_ASSIGN(PrerenderLocalPredictor);
243 }; 242 };
244 243
245 } // namespace prerender 244 } // namespace prerender
246 245
247 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_ 246 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_LOCAL_PREDICTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_histograms.cc ('k') | chrome/browser/prerender/prerender_local_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698