Chromium Code Reviews| 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/scoped_observer.h" | |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #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" | |
| 16 #include "components/history/core/browser/history_types.h" | 18 #include "components/history/core/browser/history_types.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 20 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 21 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 22 | 24 |
| 23 struct AutocompleteMatch; | 25 struct AutocompleteMatch; |
| 24 class AutocompleteResult; | 26 class AutocompleteResult; |
| 25 class HistoryService; | 27 class HistoryService; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 54 // UI thread where it lives. For incognito profiles, there is no table; the | 56 // 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 | 57 // local caches are copied from the main profile at creation and from there on |
| 56 // are the only thing used. | 58 // are the only thing used. |
| 57 // | 59 // |
| 58 // This class can be accessed as a weak pointer so that it can safely use | 60 // 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 | 61 // PostTaskAndReply without fear of crashes if it is destroyed before the reply |
| 60 // triggers. This is necessary during initialization. | 62 // triggers. This is necessary during initialization. |
| 61 class AutocompleteActionPredictor | 63 class AutocompleteActionPredictor |
| 62 : public KeyedService, | 64 : public KeyedService, |
| 63 public content::NotificationObserver, | 65 public content::NotificationObserver, |
| 66 public history::HistoryServiceObserver, | |
| 64 public base::SupportsWeakPtr<AutocompleteActionPredictor> { | 67 public base::SupportsWeakPtr<AutocompleteActionPredictor> { |
| 65 public: | 68 public: |
| 66 enum Action { | 69 enum Action { |
| 67 ACTION_PRERENDER = 0, | 70 ACTION_PRERENDER = 0, |
| 68 ACTION_PRECONNECT, | 71 ACTION_PRECONNECT, |
| 69 ACTION_NONE, | 72 ACTION_NONE, |
| 70 LAST_PREDICT_ACTION = ACTION_NONE | 73 LAST_PREDICT_ACTION = ACTION_NONE |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 explicit AutocompleteActionPredictor(Profile* profile); | 76 explicit AutocompleteActionPredictor(Profile* profile); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 void CancelPrerender(); | 108 void CancelPrerender(); |
| 106 | 109 |
| 107 // Return true if the suggestion type warrants a TCP/IP preconnection. | 110 // 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. | 111 // i.e., it is now quite likely that the user will select the related domain. |
| 109 static bool IsPreconnectable(const AutocompleteMatch& match); | 112 static bool IsPreconnectable(const AutocompleteMatch& match); |
| 110 | 113 |
| 111 // Returns true if there is an active Omnibox prerender and it has been | 114 // Returns true if there is an active Omnibox prerender and it has been |
| 112 // abandoned. | 115 // abandoned. |
| 113 bool IsPrerenderAbandonedForTesting(); | 116 bool IsPrerenderAbandonedForTesting(); |
| 114 | 117 |
| 118 // KeyedService: | |
| 119 virtual void Shutdown() override; | |
|
sdefresne
2014/10/30 17:37:04
style: remove "virtual"
nshaik
2014/10/30 21:48:35
Done.
| |
| 120 | |
| 121 // history::HistoryServiceObserver: | |
| 122 virtual void OnHistoryServiceLoaded(HistoryService* history_service) override; | |
|
sdefresne
2014/10/30 17:37:04
style: remove "virtual"
nshaik
2014/10/30 21:48:35
Done.
| |
| 123 | |
| 115 private: | 124 private: |
| 116 friend class AutocompleteActionPredictorTest; | 125 friend class AutocompleteActionPredictorTest; |
| 117 friend class ::PredictorsHandler; | 126 friend class ::PredictorsHandler; |
| 118 | 127 |
| 119 struct TransitionalMatch { | 128 struct TransitionalMatch { |
| 120 TransitionalMatch(); | 129 TransitionalMatch(); |
| 121 ~TransitionalMatch(); | 130 ~TransitionalMatch(); |
| 122 | 131 |
| 123 base::string16 user_text; | 132 base::string16 user_text; |
| 124 std::vector<GURL> urls; | 133 std::vector<GURL> urls; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 // accuracy. This is cleared after every omnibox navigation. | 248 // accuracy. This is cleared after every omnibox navigation. |
| 240 mutable std::vector<std::pair<GURL, double> > tracked_urls_; | 249 mutable std::vector<std::pair<GURL, double> > tracked_urls_; |
| 241 | 250 |
| 242 // Local caches of the data store. For incognito-owned predictors this is the | 251 // Local caches of the data store. For incognito-owned predictors this is the |
| 243 // only copy of the data. | 252 // only copy of the data. |
| 244 DBCacheMap db_cache_; | 253 DBCacheMap db_cache_; |
| 245 DBIdCacheMap db_id_cache_; | 254 DBIdCacheMap db_id_cache_; |
| 246 | 255 |
| 247 bool initialized_; | 256 bool initialized_; |
| 248 | 257 |
| 258 ScopedObserver<HistoryService, HistoryServiceObserver> | |
| 259 history_service_observer_; | |
| 260 | |
| 249 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); | 261 DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor); |
| 250 }; | 262 }; |
| 251 | 263 |
| 252 } // namespace predictors | 264 } // namespace predictors |
| 253 | 265 |
| 254 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ | 266 #endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_ |
| OLD | NEW |