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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor.h

Issue 10553029: Handle interface to prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediated, and cleaned up in prep for uploading for review Created 8 years, 5 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 | Annotate | Revision Log
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_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
6 #define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 6 #define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/history/history_types.h" 15 #include "chrome/browser/history/history_types.h"
16 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" 16 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h"
17 #include "chrome/browser/prerender/prerender_handle.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h" 18 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
22 #include "ui/gfx/size.h"
21 23
22 struct AutocompleteLog; 24 struct AutocompleteLog;
23 struct AutocompleteMatch; 25 struct AutocompleteMatch;
24 class AutocompleteResult; 26 class AutocompleteResult;
25 class HistoryService; 27 class HistoryService;
26 class PredictorsHandler; 28 class PredictorsHandler;
27 class Profile; 29 class Profile;
28 30
31 namespace content {
32 class SessionStorageNamespace;
33 }
34
29 namespace history { 35 namespace history {
30 class URLDatabase; 36 class URLDatabase;
31 } 37 }
32 38
33 namespace predictors { 39 namespace predictors {
34 40
35 // This class is responsible for determining the correct predictive network 41 // This class is responsible for determining the correct predictive network
36 // action to take given for a given AutocompleteMatch and entered text. It can 42 // action to take given for a given AutocompleteMatch and entered text. It can
37 // be instantiated for both normal and incognito profiles. For normal profiles, 43 // be instantiated for both normal and incognito profiles. For normal profiles,
38 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB 44 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 78
73 // Return the recommended action given |user_text|, the text the user has 79 // Return the recommended action given |user_text|, the text the user has
74 // entered in the Omnibox, and |match|, the suggestion from Autocomplete. 80 // entered in the Omnibox, and |match|, the suggestion from Autocomplete.
75 // This method uses information from the ShortcutsBackend including how much 81 // This method uses information from the ShortcutsBackend including how much
76 // of the matching entry the user typed, and how long it's been since the user 82 // of the matching entry the user typed, and how long it's been since the user
77 // visited the matching URL, to calculate a score between 0 and 1. This score 83 // visited the matching URL, to calculate a score between 0 and 1. This score
78 // is then mapped to an Action. 84 // is then mapped to an Action.
79 Action RecommendAction(const string16& user_text, 85 Action RecommendAction(const string16& user_text,
80 const AutocompleteMatch& match) const; 86 const AutocompleteMatch& match) const;
81 87
88 void StartPrerendering(
dominich 2012/06/28 00:34:32 this'll need a comment.
89 const GURL& url,
90 content::SessionStorageNamespace* session_storage_namespace,
91 gfx::Size size);
92
82 // Return true if the suggestion type warrants a TCP/IP preconnection. 93 // Return true if the suggestion type warrants a TCP/IP preconnection.
83 // i.e., it is now quite likely that the user will select the related domain. 94 // i.e., it is now quite likely that the user will select the related domain.
84 static bool IsPreconnectable(const AutocompleteMatch& match); 95 static bool IsPreconnectable(const AutocompleteMatch& match);
85 96
86 private: 97 private:
87 friend class AutocompleteActionPredictorTest; 98 friend class AutocompleteActionPredictorTest;
88 friend class ::PredictorsHandler; 99 friend class ::PredictorsHandler;
89 100
90 struct TransitionalMatch { 101 struct TransitionalMatch {
91 TransitionalMatch(); 102 TransitionalMatch();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 AutocompleteActionPredictor* incognito_predictor_; 203 AutocompleteActionPredictor* incognito_predictor_;
193 204
194 // The backing data store. This is NULL for incognito-owned predictors. 205 // The backing data store. This is NULL for incognito-owned predictors.
195 scoped_refptr<AutocompleteActionPredictorTable> table_; 206 scoped_refptr<AutocompleteActionPredictorTable> table_;
196 207
197 content::NotificationRegistrar notification_registrar_; 208 content::NotificationRegistrar notification_registrar_;
198 209
199 // This is cleared after every Omnibox navigation. 210 // This is cleared after every Omnibox navigation.
200 std::vector<TransitionalMatch> transitional_matches_; 211 std::vector<TransitionalMatch> transitional_matches_;
201 212
213 prerender::PrerenderHandle prerender_handle_;
214
202 // This allows us to predict the effect of confidence threshold changes on 215 // This allows us to predict the effect of confidence threshold changes on
203 // accuracy. This is cleared after every omnibox navigation. 216 // accuracy. This is cleared after every omnibox navigation.
204 mutable std::vector<std::pair<GURL, double> > tracked_urls_; 217 mutable std::vector<std::pair<GURL, double> > tracked_urls_;
205 218
206 // Local caches of the data store. For incognito-owned predictors this is the 219 // Local caches of the data store. For incognito-owned predictors this is the
207 // only copy of the data. 220 // only copy of the data.
208 DBCacheMap db_cache_; 221 DBCacheMap db_cache_;
209 DBIdCacheMap db_id_cache_; 222 DBIdCacheMap db_id_cache_;
210 223
211 bool initialized_; 224 bool initialized_;
212 225
213 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); 226 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor);
214 }; 227 };
215 228
216 } // namespace predictors 229 } // namespace predictors
217 230
218 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 231 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698