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 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/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 "components/history/core/browser/history_service_observer.h" | |
17 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 struct AutocompleteMatch; | 24 struct AutocompleteMatch; |
24 class AutocompleteResult; | 25 class AutocompleteResult; |
25 class HistoryService; | 26 class HistoryService; |
26 struct OmniboxLog; | 27 struct OmniboxLog; |
(...skipping 27 matching lines...) Expand all Loading... | |
54 // UI thread where it lives. For incognito profiles, there is no table; the | 55 // UI thread where it lives. For incognito profiles, there is no table; the |
55 // local caches are copied from the main profile at creation and from there on | 56 // local caches are copied from the main profile at creation and from there on |
56 // are the only thing used. | 57 // are the only thing used. |
57 // | 58 // |
58 // This class can be accessed as a weak pointer so that it can safely use | 59 // This class can be accessed as a weak pointer so that it can safely use |
59 // PostTaskAndReply without fear of crashes if it is destroyed before the reply | 60 // PostTaskAndReply without fear of crashes if it is destroyed before the reply |
60 // triggers. This is necessary during initialization. | 61 // triggers. This is necessary during initialization. |
61 class AutocompleteActionPredictor | 62 class AutocompleteActionPredictor |
62 : public KeyedService, | 63 : public KeyedService, |
63 public content::NotificationObserver, | 64 public content::NotificationObserver, |
65 public history::HistoryServiceObserver, | |
64 public base::SupportsWeakPtr<AutocompleteActionPredictor> { | 66 public base::SupportsWeakPtr<AutocompleteActionPredictor> { |
65 public: | 67 public: |
66 enum Action { | 68 enum Action { |
67 ACTION_PRERENDER = 0, | 69 ACTION_PRERENDER = 0, |
68 ACTION_PRECONNECT, | 70 ACTION_PRECONNECT, |
69 ACTION_NONE, | 71 ACTION_NONE, |
70 LAST_PREDICT_ACTION = ACTION_NONE | 72 LAST_PREDICT_ACTION = ACTION_NONE |
71 }; | 73 }; |
72 | 74 |
73 explicit AutocompleteActionPredictor(Profile* profile); | 75 explicit AutocompleteActionPredictor(Profile* profile); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 void CancelPrerender(); | 107 void CancelPrerender(); |
106 | 108 |
107 // Return true if the suggestion type warrants a TCP/IP preconnection. | 109 // Return true if the suggestion type warrants a TCP/IP preconnection. |
108 // i.e., it is now quite likely that the user will select the related domain. | 110 // i.e., it is now quite likely that the user will select the related domain. |
109 static bool IsPreconnectable(const AutocompleteMatch& match); | 111 static bool IsPreconnectable(const AutocompleteMatch& match); |
110 | 112 |
111 // Returns true if there is an active Omnibox prerender and it has been | 113 // Returns true if there is an active Omnibox prerender and it has been |
112 // abandoned. | 114 // abandoned. |
113 bool IsPrerenderAbandonedForTesting(); | 115 bool IsPrerenderAbandonedForTesting(); |
114 | 116 |
117 // Is called when |service| is loaded. | |
sdefresne
2014/10/20 13:15:42
// historyHistoryServiceObserver:
| |
118 virtual void HistoryServiceLoaded(HistoryService* service) OVERRIDE; | |
sdefresne
2014/10/20 13:15:42
OVERRIDE -> override
| |
119 | |
115 private: | 120 private: |
116 friend class AutocompleteActionPredictorTest; | 121 friend class AutocompleteActionPredictorTest; |
117 friend class ::PredictorsHandler; | 122 friend class ::PredictorsHandler; |
118 | 123 |
119 struct TransitionalMatch { | 124 struct TransitionalMatch { |
120 TransitionalMatch(); | 125 TransitionalMatch(); |
121 ~TransitionalMatch(); | 126 ~TransitionalMatch(); |
122 | 127 |
123 base::string16 user_text; | 128 base::string16 user_text; |
124 std::vector<GURL> urls; | 129 std::vector<GURL> urls; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 DBIdCacheMap db_id_cache_; | 250 DBIdCacheMap db_id_cache_; |
246 | 251 |
247 bool initialized_; | 252 bool initialized_; |
248 | 253 |
249 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); | 254 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); |
250 }; | 255 }; |
251 | 256 |
252 } // namespace predictors | 257 } // namespace predictors |
253 | 258 |
254 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ | 259 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ |
OLD | NEW |