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

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: remediation to reviews, and unit test improvements. 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/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/string16.h" 15 #include "base/string16.h"
15 #include "chrome/browser/history/history_types.h" 16 #include "chrome/browser/history/history_types.h"
16 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" 17 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h"
18 #include "chrome/browser/prerender/prerender_handle.h"
17 #include "chrome/browser/profiles/profile_keyed_service.h" 19 #include "chrome/browser/profiles/profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
20 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
23 #include "ui/gfx/size.h"
21 24
22 struct AutocompleteLog; 25 struct AutocompleteLog;
23 struct AutocompleteMatch; 26 struct AutocompleteMatch;
24 class AutocompleteResult; 27 class AutocompleteResult;
25 class HistoryService; 28 class HistoryService;
26 class PredictorsHandler; 29 class PredictorsHandler;
27 class Profile; 30 class Profile;
28 31
32 namespace content {
33 class SessionStorageNamespace;
34 }
35
29 namespace history { 36 namespace history {
30 class URLDatabase; 37 class URLDatabase;
31 } 38 }
32 39
33 namespace predictors { 40 namespace predictors {
34 41
35 // This class is responsible for determining the correct predictive network 42 // This class is responsible for determining the correct predictive network
36 // action to take given for a given AutocompleteMatch and entered text. It can 43 // 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, 44 // be instantiated for both normal and incognito profiles. For normal profiles,
38 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB 45 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 79
73 // Return the recommended action given |user_text|, the text the user has 80 // Return the recommended action given |user_text|, the text the user has
74 // entered in the Omnibox, and |match|, the suggestion from Autocomplete. 81 // entered in the Omnibox, and |match|, the suggestion from Autocomplete.
75 // This method uses information from the ShortcutsBackend including how much 82 // 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 83 // 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 84 // visited the matching URL, to calculate a score between 0 and 1. This score
78 // is then mapped to an Action. 85 // is then mapped to an Action.
79 Action RecommendAction(const string16& user_text, 86 Action RecommendAction(const string16& user_text,
80 const AutocompleteMatch& match) const; 87 const AutocompleteMatch& match) const;
81 88
89 // Begin prerendering |url| with |session_storage_namespace|. The |size| gives
90 // the initial size for the target prerender. The predictor will run at most
91 // one prerender at a time, so launching a prerender will cancel our previous
92 // prerenders (if any).
93 void StartPrerendering(
94 const GURL& url,
95 content::SessionStorageNamespace* session_storage_namespace,
96 gfx::Size size);
97
82 // Return true if the suggestion type warrants a TCP/IP preconnection. 98 // 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. 99 // i.e., it is now quite likely that the user will select the related domain.
84 static bool IsPreconnectable(const AutocompleteMatch& match); 100 static bool IsPreconnectable(const AutocompleteMatch& match);
85 101
86 private: 102 private:
87 friend class AutocompleteActionPredictorTest; 103 friend class AutocompleteActionPredictorTest;
88 friend class ::PredictorsHandler; 104 friend class ::PredictorsHandler;
89 105
90 struct TransitionalMatch { 106 struct TransitionalMatch {
91 TransitionalMatch(); 107 TransitionalMatch();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 AutocompleteActionPredictor* incognito_predictor_; 208 AutocompleteActionPredictor* incognito_predictor_;
193 209
194 // The backing data store. This is NULL for incognito-owned predictors. 210 // The backing data store. This is NULL for incognito-owned predictors.
195 scoped_refptr<AutocompleteActionPredictorTable> table_; 211 scoped_refptr<AutocompleteActionPredictorTable> table_;
196 212
197 content::NotificationRegistrar notification_registrar_; 213 content::NotificationRegistrar notification_registrar_;
198 214
199 // This is cleared after every Omnibox navigation. 215 // This is cleared after every Omnibox navigation.
200 std::vector<TransitionalMatch> transitional_matches_; 216 std::vector<TransitionalMatch> transitional_matches_;
201 217
218 scoped_ptr<prerender::PrerenderHandle> prerender_handle_;
219
202 // This allows us to predict the effect of confidence threshold changes on 220 // This allows us to predict the effect of confidence threshold changes on
203 // accuracy. This is cleared after every omnibox navigation. 221 // accuracy. This is cleared after every omnibox navigation.
204 mutable std::vector<std::pair<GURL, double> > tracked_urls_; 222 mutable std::vector<std::pair<GURL, double> > tracked_urls_;
205 223
206 // Local caches of the data store. For incognito-owned predictors this is the 224 // Local caches of the data store. For incognito-owned predictors this is the
207 // only copy of the data. 225 // only copy of the data.
208 DBCacheMap db_cache_; 226 DBCacheMap db_cache_;
209 DBIdCacheMap db_id_cache_; 227 DBIdCacheMap db_id_cache_;
210 228
211 bool initialized_; 229 bool initialized_;
212 230
213 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); 231 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor);
214 }; 232 };
215 233
216 } // namespace predictors 234 } // namespace predictors
217 235
218 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ 236 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698