Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4877)

Unified Diff: chrome/browser/webdata/web_database.h

Issue 12543034: Move creation of the various WebDatabaseTable types out of WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows release builds (COMDAT folding combined static functions being used for keys. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webdata/web_data_service_win.cc ('k') | chrome/browser/webdata/web_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database.h
diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h
index 6a24985bfbe88f484c4da3b9cee8f7a8a894f626..e186f34558ab329b69ec9a40359df391db4b76d8 100644
--- a/chrome/browser/webdata/web_database.h
+++ b/chrome/browser/webdata/web_database.h
@@ -5,20 +5,14 @@
#ifndef CHROME_BROWSER_WEBDATA_WEB_DATABASE_H_
#define CHROME_BROWSER_WEBDATA_WEB_DATABASE_H_
+#include <map>
+
#include "base/memory/scoped_ptr.h"
-#include "base/memory/scoped_vector.h"
+#include "chrome/browser/webdata/web_database_table.h"
#include "sql/connection.h"
#include "sql/init_status.h"
#include "sql/meta_table.h"
-class AutofillTable;
-class KeywordTable;
-class LoginsTable;
-class TokenServiceTable;
-class WebAppsTable;
-class WebDatabaseTable;
-class WebIntentsTable;
-
namespace base {
class FilePath;
}
@@ -40,10 +34,22 @@ class WebDatabase {
WebDatabase();
virtual ~WebDatabase();
+ // Adds a database table. Ownership remains with the caller, which
+ // must ensure that the lifetime of |table| exceeds this object's
+ // lifetime. Must only be called before Init.
+ void AddTable(WebDatabaseTable* table);
+
+ // Retrieves a table based on its |key|.
+ WebDatabaseTable* GetTable(WebDatabaseTable::TypeKey key);
+
// Initialize the database given a name. The name defines where the SQLite
// file is. If this returns an error code, no other method should be called.
// Requires the |app_locale| to be passed as a parameter as the locale can
// only safely be queried on the UI thread.
+ //
+ // Before calling this method, you must call AddTable for any
+ // WebDatabaseTable objects that are supposed to participate in
+ // managing the database.
sql::InitStatus Init(
const base::FilePath& db_name, const std::string& app_locale);
@@ -51,12 +57,6 @@ class WebDatabase {
void BeginTransaction();
void CommitTransaction();
- virtual AutofillTable* GetAutofillTable();
- virtual KeywordTable* GetKeywordTable();
- virtual LoginsTable* GetLoginsTable();
- virtual TokenServiceTable* GetTokenServiceTable();
- virtual WebAppsTable* GetWebAppsTable();
-
// Exposed for testing only.
sql::Connection* GetSQLConnection();
@@ -69,20 +69,10 @@ class WebDatabase {
sql::Connection db_;
sql::MetaTable meta_table_;
- // TODO(joi): All of the typed pointers are going in a future
- // change, as we remove knowledge of the specific types from this
- // class.
- AutofillTable* autofill_table_;
- KeywordTable* keyword_table_;
- LoginsTable* logins_table_;
- TokenServiceTable* token_service_table_;
- WebAppsTable* web_apps_table_;
- // TODO(thakis): Add a migration to delete this table, then remove this.
- WebIntentsTable* web_intents_table_;
-
- // Owns all the different database tables that have been added to
- // this object.
- ScopedVector<WebDatabaseTable> tables_;
+ // Map of all the different tables that have been added to this
+ // object. Non-owning.
+ typedef std::map<WebDatabaseTable::TypeKey, WebDatabaseTable*> TableMap;
+ TableMap tables_;
scoped_ptr<content::NotificationService> notification_service_;
« no previous file with comments | « chrome/browser/webdata/web_data_service_win.cc ('k') | chrome/browser/webdata/web_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698