| Index: chrome/browser/predictors/predictor_database.h
|
| diff --git a/chrome/browser/predictors/predictor_database.h b/chrome/browser/predictors/predictor_database.h
|
| index 1692e3390dbf4049ddaf3b643bb50f832ac4ca4b..9cb13b5487c9b1feb48eac654812761079cc38aa 100644
|
| --- a/chrome/browser/predictors/predictor_database.h
|
| +++ b/chrome/browser/predictors/predictor_database.h
|
| @@ -5,11 +5,11 @@
|
| #ifndef CHROME_BROWSER_PREDICTORS_PREDICTOR_DATABASE_H_
|
| #define CHROME_BROWSER_PREDICTORS_PREDICTOR_DATABASE_H_
|
|
|
| +#include "base/file_path.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "chrome/browser/profiles/profile_keyed_service.h"
|
|
|
| -class Profile;
|
| -
|
| namespace sql {
|
| class Connection;
|
| }
|
| @@ -20,22 +20,41 @@ class AutocompleteActionPredictorTable;
|
| class PredictorDatabaseInternal;
|
| class ResourcePrefetchPredictorTables;
|
|
|
| -class PredictorDatabase : public ProfileKeyedService {
|
| +// Refcounted as it is created, initialized and destroyed on a different thread
|
| +// to the DB thread that is required for all methods performing database access.
|
| +class PredictorDatabase
|
| + : public base::RefCountedThreadSafe<PredictorDatabase> {
|
| public:
|
| - explicit PredictorDatabase(Profile* profile);
|
| + explicit PredictorDatabase(const FilePath& path,
|
| + bool is_resource_prefetch_predictor_enabled);
|
| virtual ~PredictorDatabase();
|
|
|
| scoped_refptr<AutocompleteActionPredictorTable> autocomplete_table();
|
| scoped_refptr<ResourcePrefetchPredictorTables> resource_prefetch_tables();
|
|
|
| + // Cancels pending DB transactions. Should only be called on the UI thread.
|
| + void SetCancelled();
|
| +
|
| // Used for testing.
|
| sql::Connection* GetDatabase();
|
|
|
| private:
|
| - // ProfileKeyedService
|
| - virtual void Shutdown() OVERRIDE;
|
| + friend class base::RefCountedThreadSafe<PredictorDatabase>;
|
| +
|
| + // Opens the database file. Separated from the constructor to ease
|
| + // construction/destruction of this object on one thread but database access
|
| + // on the DB thread.
|
| + void Initialize();
|
| + void LogDatabaseStats(); // DB Thread.
|
| +
|
| + FilePath db_path_;
|
| + bool is_resource_prefetch_predictor_enabled_;
|
| + scoped_ptr<sql::Connection> db_;
|
|
|
| - scoped_refptr<PredictorDatabaseInternal> db_;
|
| + // TODO(shishir): These tables may not need to be refcounted. Maybe move them
|
| + // to using a WeakPtr instead.
|
| + scoped_refptr<AutocompleteActionPredictorTable> autocomplete_table_;
|
| + scoped_refptr<ResourcePrefetchPredictorTables> resource_prefetch_tables_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(PredictorDatabase);
|
| };
|
|
|