OLD | NEW |
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 COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ |
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "components/webdata/common/webdata_export.h" | 9 #include "components/webdata/common/webdata_export.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 // of the type's statics. | 22 // of the type's statics. |
23 typedef void* TypeKey; | 23 typedef void* TypeKey; |
24 | 24 |
25 // The object is not ready for use until Init() has been called. | 25 // The object is not ready for use until Init() has been called. |
26 WebDatabaseTable(); | 26 WebDatabaseTable(); |
27 virtual ~WebDatabaseTable(); | 27 virtual ~WebDatabaseTable(); |
28 | 28 |
29 // Retrieves the TypeKey for the concrete subtype. | 29 // Retrieves the TypeKey for the concrete subtype. |
30 virtual TypeKey GetTypeKey() const = 0; | 30 virtual TypeKey GetTypeKey() const = 0; |
31 | 31 |
32 // Attempts to initialize the table and returns true if successful. | 32 // Stores the passed members as instance variables. |
33 // | 33 void Init(sql::Connection* db, sql::MetaTable* meta_table); |
34 // The base class stores the members passed and always return true; | 34 |
35 // subclasses may perform other initialization as needed. | 35 // Create all of the expected SQL tables if they do not already exist. |
36 virtual bool Init(sql::Connection* db, sql::MetaTable* meta_table); | 36 // Returns true on success, false on failure. |
| 37 virtual bool CreateTablesIfNecessary() = 0; |
37 | 38 |
38 // In order to encourage developers to think about sync when adding or | 39 // In order to encourage developers to think about sync when adding or |
39 // or altering new tables, this method must be implemented. Please get in | 40 // or altering new tables, this method must be implemented. Please get in |
40 // contact with the sync team if you believe you're making a change that they | 41 // contact with the sync team if you believe you're making a change that they |
41 // should be aware of (or if you could break something). | 42 // should be aware of (or if you could break something). |
42 // TODO(andybons): Implement something more robust. | 43 // TODO(andybons): Implement something more robust. |
43 virtual bool IsSyncable() = 0; | 44 virtual bool IsSyncable() = 0; |
44 | 45 |
45 // Migrates this table to |version|. Returns false if there was | 46 // Migrates this table to |version|. Returns false if there was |
46 // migration work to do and it failed, true otherwise. | 47 // migration work to do and it failed, true otherwise. |
(...skipping 10 matching lines...) Expand all Loading... |
57 // exceeds that of WebDatabase, they should not be used in | 58 // exceeds that of WebDatabase, they should not be used in |
58 // ~WebDatabaseTable. | 59 // ~WebDatabaseTable. |
59 sql::Connection* db_; | 60 sql::Connection* db_; |
60 sql::MetaTable* meta_table_; | 61 sql::MetaTable* meta_table_; |
61 | 62 |
62 private: | 63 private: |
63 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable); | 64 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable); |
64 }; | 65 }; |
65 | 66 |
66 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ | 67 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATABASE_TABLE_H_ |
OLD | NEW |