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 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 protected: | 18 public: |
19 WebDatabaseTable(sql::Connection* db, sql::MetaTable* meta_table); | 19 WebDatabaseTable(sql::Connection* db, sql::MetaTable* meta_table); |
20 virtual ~WebDatabaseTable(); | 20 virtual ~WebDatabaseTable(); |
21 | 21 |
22 // Attempts to initialize the table and returns true if successful. | 22 // Attempts to initialize the table and returns true if successful. |
23 virtual bool Init() = 0; | 23 virtual bool Init() = 0; |
24 | 24 |
25 // In order to encourage developers to think about sync when adding or | 25 // 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 | 26 // 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 | 27 // 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). | 28 // should be aware of (or if you could break something). |
29 // TODO(andybons): Implement something more robust. | 29 // TODO(andybons): Implement something more robust. |
30 virtual bool IsSyncable() = 0; | 30 virtual bool IsSyncable() = 0; |
31 | 31 |
32 // Migrates this table to |version|. Returns false if there was | |
33 // migration work to do and it failed, true otherwise. | |
34 // | |
35 // |app_locale| is the locale of the app. Passed as a parameter as | |
36 // |it can only be safely queried on the UI thread. | |
37 // | |
38 // Implementations may set |*update_compatible_version| to true if | |
39 // the compatible version should be changed to | |
dhollowa
2013/03/12 01:38:16
nit: This line wraps too early.
Jói
2013/03/12 02:00:44
Done.
| |
40 // |version|. Implementations should otherwise not modify this | |
41 // parameter. | |
42 virtual bool MigrateToVersion(int version, | |
43 const std::string& app_locale, | |
44 bool* update_compatible_version) = 0; | |
45 | |
46 protected: | |
32 sql::Connection* db_; | 47 sql::Connection* db_; |
33 sql::MetaTable* meta_table_; | 48 sql::MetaTable* meta_table_; |
34 | 49 |
35 private: | 50 private: |
36 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable); | 51 DISALLOW_COPY_AND_ASSIGN(WebDatabaseTable); |
37 }; | 52 }; |
38 | 53 |
39 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_ | 54 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_TABLE_H_ |
OLD | NEW |