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

Side by Side Diff: chrome/browser/webdata/web_database_table.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_WEBDATA_WEB_DATABASE_TABLE_H_ 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
6 #define CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_ 6 #define CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace sql { 10 namespace sql {
11 class Connection; 11 class Connection;
12 class MetaTable; 12 class MetaTable;
13 } 13 }
14 14
15 // An abstract base class representing a table within a WebDatabase. 15 // An abstract base class representing a table within a WebDatabase.
16 // Each table should subclass this, adding type-specific methods as needed. 16 // Each table should subclass this, adding type-specific methods as needed.
17 class WebDatabaseTable { 17 class WebDatabaseTable {
18 public: 18 public:
19 WebDatabaseTable(sql::Connection* db, sql::MetaTable* meta_table); 19 // To look up a WebDatabaseTable of a certain type from WebDatabase,
20 // we use a void* key, so that we can simply use the address of one
21 // of the type's statics.
22 typedef void* TypeKey;
23
24 // The object is not ready for use until Init() has been called.
25 WebDatabaseTable();
20 virtual ~WebDatabaseTable(); 26 virtual ~WebDatabaseTable();
21 27
28 // Retrieves the TypeKey for the concrete subtype.
29 virtual TypeKey GetTypeKey() const = 0;
30
22 // Attempts to initialize the table and returns true if successful. 31 // Attempts to initialize the table and returns true if successful.
23 virtual bool Init() = 0; 32 //
33 // The base class stores the members passed and always return true;
34 // subclasses may perform other initialization as needed.
35 virtual bool Init(sql::Connection* db, sql::MetaTable* meta_table);
24 36
25 // In order to encourage developers to think about sync when adding or 37 // In order to encourage developers to think about sync when adding or
26 // or altering new tables, this method must be implemented. Please get in 38 // or altering new tables, this method must be implemented. Please get in
27 // contact with the sync team if you believe you're making a change that they 39 // contact with the sync team if you believe you're making a change that they
28 // should be aware of (or if you could break something). 40 // should be aware of (or if you could break something).
29 // TODO(andybons): Implement something more robust. 41 // TODO(andybons): Implement something more robust.
30 virtual bool IsSyncable() = 0; 42 virtual bool IsSyncable() = 0;
31 43
32 // Migrates this table to |version|. Returns false if there was 44 // Migrates this table to |version|. Returns false if there was
33 // migration work to do and it failed, true otherwise. 45 // migration work to do and it failed, true otherwise.
34 // 46 //
35 // |app_locale| is the locale of the app. Passed as a parameter as 47 // |app_locale| is the locale of the app. Passed as a parameter as
36 // |it can only be safely queried on the UI thread. 48 // |it can only be safely queried on the UI thread.
37 // 49 //
38 // Implementations may set |*update_compatible_version| to true if 50 // Implementations may set |*update_compatible_version| to true if
39 // the compatible version should be changed to |version|. 51 // the compatible version should be changed to |version|.
40 // Implementations should otherwise not modify this parameter. 52 // Implementations should otherwise not modify this parameter.
41 virtual bool MigrateToVersion(int version, 53 virtual bool MigrateToVersion(int version,
42 const std::string& app_locale, 54 const std::string& app_locale,
43 bool* update_compatible_version) = 0; 55 bool* update_compatible_version) = 0;
44 56
45 protected: 57 protected:
58 // Non-owning. These are owned by WebDatabase, valid as long as that
59 // class exists. Since lifetime of WebDatabaseTable objects slightly
60 // exceeds that of WebDatabase, they should not be used in
61 // ~WebDatabaseTable.
46 sql::Connection* db_; 62 sql::Connection* db_;
47 sql::MetaTable* meta_table_; 63 sql::MetaTable* meta_table_;
48 64
49 private: 65 private:
50 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable); 66 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable);
51 }; 67 };
52 68
53 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_ 69 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database_service.cc ('k') | chrome/browser/webdata/web_database_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698