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_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" |
21 | 22 |
22 struct AutocompleteLog; | 23 struct AutocompleteLog; |
23 struct AutocompleteMatch; | 24 struct AutocompleteMatch; |
24 class AutocompleteResult; | 25 class AutocompleteResult; |
25 class HistoryService; | 26 class HistoryService; |
26 class PredictorsHandler; | 27 class PredictorsHandler; |
27 class Profile; | 28 class Profile; |
28 | 29 |
| 30 namespace content { |
| 31 class SessionStorageNamespace; |
| 32 } |
| 33 |
29 namespace history { | 34 namespace history { |
30 class URLDatabase; | 35 class URLDatabase; |
31 } | 36 } |
32 | 37 |
33 namespace predictors { | 38 namespace predictors { |
34 | 39 |
35 // This class is responsible for determining the correct predictive network | 40 // This class is responsible for determining the correct predictive network |
36 // action to take given for a given AutocompleteMatch and entered text. It can | 41 // 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, | 42 // be instantiated for both normal and incognito profiles. For normal profiles, |
38 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB | 43 // it uses an AutocompleteActionPredictorTable accessed asynchronously on the DB |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 77 |
73 // Return the recommended action given |user_text|, the text the user has | 78 // Return the recommended action given |user_text|, the text the user has |
74 // entered in the Omnibox, and |match|, the suggestion from Autocomplete. | 79 // entered in the Omnibox, and |match|, the suggestion from Autocomplete. |
75 // This method uses information from the ShortcutsBackend including how much | 80 // 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 | 81 // 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 | 82 // visited the matching URL, to calculate a score between 0 and 1. This score |
78 // is then mapped to an Action. | 83 // is then mapped to an Action. |
79 Action RecommendAction(const string16& user_text, | 84 Action RecommendAction(const string16& user_text, |
80 const AutocompleteMatch& match) const; | 85 const AutocompleteMatch& match) const; |
81 | 86 |
| 87 prerender::PrerenderHandle StartPrerendering( |
| 88 const GURL& url, |
| 89 content::SessionStorageNamespace* session_storage_namespace); |
| 90 |
82 // Return true if the suggestion type warrants a TCP/IP preconnection. | 91 // 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. | 92 // i.e., it is now quite likely that the user will select the related domain. |
84 static bool IsPreconnectable(const AutocompleteMatch& match); | 93 static bool IsPreconnectable(const AutocompleteMatch& match); |
85 | 94 |
86 private: | 95 private: |
87 friend class AutocompleteActionPredictorTest; | 96 friend class AutocompleteActionPredictorTest; |
88 friend class ::PredictorsHandler; | 97 friend class ::PredictorsHandler; |
89 | 98 |
90 struct TransitionalMatch { | 99 struct TransitionalMatch { |
91 TransitionalMatch(); | 100 TransitionalMatch(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 AutocompleteActionPredictor* incognito_predictor_; | 201 AutocompleteActionPredictor* incognito_predictor_; |
193 | 202 |
194 // The backing data store. This is NULL for incognito-owned predictors. | 203 // The backing data store. This is NULL for incognito-owned predictors. |
195 scoped_refptr<AutocompleteActionPredictorTable> table_; | 204 scoped_refptr<AutocompleteActionPredictorTable> table_; |
196 | 205 |
197 content::NotificationRegistrar notification_registrar_; | 206 content::NotificationRegistrar notification_registrar_; |
198 | 207 |
199 // This is cleared after every Omnibox navigation. | 208 // This is cleared after every Omnibox navigation. |
200 std::vector<TransitionalMatch> transitional_matches_; | 209 std::vector<TransitionalMatch> transitional_matches_; |
201 | 210 |
| 211 prerender::PrerenderHandle prerender_; |
| 212 |
202 // This allows us to predict the effect of confidence threshold changes on | 213 // This allows us to predict the effect of confidence threshold changes on |
203 // accuracy. This is cleared after every omnibox navigation. | 214 // accuracy. This is cleared after every omnibox navigation. |
204 mutable std::vector<std::pair<GURL, double> > tracked_urls_; | 215 mutable std::vector<std::pair<GURL, double> > tracked_urls_; |
205 | 216 |
206 // Local caches of the data store. For incognito-owned predictors this is the | 217 // Local caches of the data store. For incognito-owned predictors this is the |
207 // only copy of the data. | 218 // only copy of the data. |
208 DBCacheMap db_cache_; | 219 DBCacheMap db_cache_; |
209 DBIdCacheMap db_id_cache_; | 220 DBIdCacheMap db_id_cache_; |
210 | 221 |
211 bool initialized_; | 222 bool initialized_; |
212 | 223 |
213 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); | 224 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); |
214 }; | 225 }; |
215 | 226 |
216 } // namespace predictors | 227 } // namespace predictors |
217 | 228 |
218 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ | 229 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ |
OLD | NEW |