| Index: chrome/browser/predictors/autocomplete_action_predictor.h
|
| diff --git a/chrome/browser/autocomplete/network_action_predictor.h b/chrome/browser/predictors/autocomplete_action_predictor.h
|
| similarity index 84%
|
| rename from chrome/browser/autocomplete/network_action_predictor.h
|
| rename to chrome/browser/predictors/autocomplete_action_predictor.h
|
| index a8351e41adbc75359db727789fb61919dba779db..463f94021529012337553917cee81bd3008e9c16 100644
|
| --- a/chrome/browser/autocomplete/network_action_predictor.h
|
| +++ b/chrome/browser/predictors/autocomplete_action_predictor.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_AUTOCOMPLETE_NETWORK_ACTION_PREDICTOR_H_
|
| -#define CHROME_BROWSER_AUTOCOMPLETE_NETWORK_ACTION_PREDICTOR_H_
|
| +#ifndef CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
|
| +#define CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
|
| #pragma once
|
|
|
| #include <map>
|
| @@ -12,7 +12,7 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/string16.h"
|
| -#include "chrome/browser/autocomplete/network_action_predictor_database.h"
|
| +#include "chrome/browser/predictors/predictor_database.h"
|
| #include "chrome/browser/profiles/profile_keyed_service.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| @@ -22,24 +22,27 @@ struct AutocompleteLog;
|
| struct AutocompleteMatch;
|
| class AutocompleteResult;
|
| class HistoryService;
|
| +class PredictorsDOMHandler;
|
| class Profile;
|
|
|
| namespace history {
|
| class URLDatabase;
|
| }
|
|
|
| +namespace predictors {
|
| +
|
| // This class is responsible for determining the correct predictive network
|
| // action to take given for a given AutocompleteMatch and entered text. it uses
|
| -// a NetworkActionPredictorDatabase accessed asynchronously on the DB thread to
|
| +// a PredictorDatabase accessed asynchronously on the DB thread to
|
| // permanently store the data used to make predictions, and keeps local caches
|
| // of that data to be able to make predictions synchronously on the UI thread
|
| // where it lives. It can be accessed as a weak pointer so that it can safely
|
| // use PostTaskAndReply without fear of crashes if it is destroyed before the
|
| // reply triggers. This is necessary during initialization.
|
| -class NetworkActionPredictor
|
| +class AutocompleteActionPredictor
|
| : public ProfileKeyedService,
|
| public content::NotificationObserver,
|
| - public base::SupportsWeakPtr<NetworkActionPredictor> {
|
| + public base::SupportsWeakPtr<AutocompleteActionPredictor> {
|
| public:
|
| enum Action {
|
| ACTION_PRERENDER = 0,
|
| @@ -48,8 +51,8 @@ class NetworkActionPredictor
|
| LAST_PREDICT_ACTION = ACTION_NONE
|
| };
|
|
|
| - explicit NetworkActionPredictor(Profile* profile);
|
| - virtual ~NetworkActionPredictor();
|
| + explicit AutocompleteActionPredictor(Profile* profile);
|
| + virtual ~AutocompleteActionPredictor();
|
|
|
| static void set_hit_weight(double weight) { hit_weight_ = weight; }
|
| static double get_hit_weight() { return hit_weight_; }
|
| @@ -78,8 +81,8 @@ class NetworkActionPredictor
|
| static bool IsPreconnectable(const AutocompleteMatch& match);
|
|
|
| private:
|
| - friend class NetworkActionPredictorTest;
|
| - friend class NetworkActionPredictorDOMHandler;
|
| + friend class AutocompleteActionPredictorTest;
|
| + friend class ::PredictorsDOMHandler;
|
|
|
| struct TransitionalMatch {
|
| TransitionalMatch();
|
| @@ -113,7 +116,7 @@ class NetworkActionPredictor
|
| };
|
|
|
| typedef std::map<DBCacheKey, DBCacheValue> DBCacheMap;
|
| - typedef std::map<DBCacheKey, NetworkActionPredictorDatabase::Row::Id>
|
| + typedef std::map<DBCacheKey, AutocompleteActionPredictorTable::Row::Id>
|
| DBIdCacheMap;
|
|
|
| static const int kMaximumDaysToKeepEntry;
|
| @@ -138,7 +141,7 @@ class NetworkActionPredictor
|
| // |id_list| must not be NULL. Every row id deleted will be added to id_list.
|
| void DeleteOldIdsFromCaches(
|
| history::URLDatabase* url_db,
|
| - std::vector<NetworkActionPredictorDatabase::Row::Id>* id_list);
|
| + std::vector<AutocompleteActionPredictorTable::Row::Id>* id_list);
|
|
|
| // Called to delete any old or invalid entries from the database. Called after
|
| // the local caches are created once the history service is available.
|
| @@ -148,7 +151,7 @@ class NetworkActionPredictor
|
| // if the history service is available, or registers for the notification of
|
| // it becoming available.
|
| void CreateCaches(
|
| - std::vector<NetworkActionPredictorDatabase::Row>* row_buffer);
|
| + std::vector<AutocompleteActionPredictorTable::Row>* row_buffer);
|
|
|
| // Attempts to call DeleteOldEntries if the in-memory database has been loaded
|
| // by |service|. Returns success as a boolean.
|
| @@ -167,11 +170,11 @@ class NetworkActionPredictor
|
|
|
| // Adds a row to the database and caches.
|
| void AddRow(const DBCacheKey& key,
|
| - const NetworkActionPredictorDatabase::Row& row);
|
| + const AutocompleteActionPredictorTable::Row& row);
|
|
|
| // Updates a row in the database and the caches.
|
| void UpdateRow(DBCacheMap::iterator it,
|
| - const NetworkActionPredictorDatabase::Row& row);
|
| + const AutocompleteActionPredictorTable::Row& row);
|
|
|
| // Removes all rows from the database and caches.
|
| void DeleteAllRows();
|
| @@ -179,12 +182,8 @@ class NetworkActionPredictor
|
| // Removes rows from the database and caches that contain a URL in |urls|.
|
| void DeleteRowsWithURLs(const std::set<GURL>& urls);
|
|
|
| - // Used to batch operations on the database.
|
| - void BeginTransaction();
|
| - void CommitTransaction();
|
| -
|
| Profile* profile_;
|
| - scoped_refptr<NetworkActionPredictorDatabase> db_;
|
| + scoped_refptr<PredictorDatabase> db_;
|
| content::NotificationRegistrar notification_registrar_;
|
|
|
| // This is cleared after every Omnibox navigation.
|
| @@ -199,7 +198,9 @@ class NetworkActionPredictor
|
|
|
| bool initialized_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(NetworkActionPredictor);
|
| + DISALLOW_COPY_AND_ASSIGN(AutocompleteActionPredictor);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_AUTOCOMPLETE_NETWORK_ACTION_PREDICTOR_H_
|
| +} // namespace predictors
|
| +
|
| +#endif // CHROME_BROWSER_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_H_
|
|
|