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

Side by Side Diff: chrome/browser/meta_table_helper.h

Issue 1700017: Get rid of MetaTableHelper class and make use of the app/sql API in the LoginDatabase. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: fix rebase that removed the chrome_tests.gypi Created 10 years, 7 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
« no previous file with comments | « chrome/browser/history/thumbnail_database.h ('k') | chrome/browser/meta_table_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_META_TABLE_HELPER_H__
6 #define CHROME_BROWSER_META_TABLE_HELPER_H__
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 struct sqlite3;
13 class SQLStatement;
14
15 // MetaTableHelper maintains arbitrary key/value pairs in a table, as well
16 // as version information. MetaTableHelper is used by both WebDatabase and
17 // HistoryDatabase to maintain version information.
18 //
19 // To use a MetalTableHelper you must invoke the init method specifying the
20 // database to use.
21 class MetaTableHelper {
22 public:
23 // Creates a new MetaTableHelper. After construction you must invoke
24 // Init with the appropriate database.
25 MetaTableHelper();
26 ~MetaTableHelper();
27
28 // Initializes the MetaTableHelper, creating the meta table if necessary. For
29 // new tables, it will initialize the version number to |version| and the
30 // compatible version number to |compatible_version|.
31 //
32 // The name of the database in the sqlite connection (for tables named with
33 // the "db_name.table_name" scheme is given in |db_name|. If empty, it is
34 // assumed there is no database name.
35 bool Init(const std::string& db_name,
36 int version,
37 int compatible_version,
38 sqlite3* db);
39
40 // Version number. This should be the version number of the creator of the
41 // file. GetVersionNumber will return 0 if there is no version number.
42 // See also *CompatibleVersionNumber.
43 void SetVersionNumber(int version);
44 int GetVersionNumber();
45
46 // The compatible version number is the lowest version that this file format
47 // is readable by. If an addition or other non-critical change is made to the
48 // file in such a way that it could be read or written non-catastrophically
49 // by an older version, this number tells us which version that is.
50 //
51 // Any version newer than this should be able to interpret the file. Any
52 // version older than this should not touch the file or else it might
53 // corrupt it.
54 //
55 // GetCompatibleVersionNumber will return 0 if there is none.
56 void SetCompatibleVersionNumber(int version);
57 int GetCompatibleVersionNumber();
58
59 // Arbitrary key/value pair with a wstring value.
60 bool SetValue(const std::string& key, const std::wstring& value);
61 bool GetValue(const std::string& key, std::wstring* value);
62
63 // Arbitrary key/value pair with an int value.
64 bool SetValue(const std::string& key, int value);
65 bool GetValue(const std::string& key, int* value);
66
67 // Arbitrary key/value pair with an int64 value.
68 bool SetValue(const std::string& key, int64 value);
69 bool GetValue(const std::string& key, int64* value);
70
71 private:
72 friend class MetaTableHelperTest;
73
74 // Appends the meta table name to the SQL statement.
75 static void appendMetaTableName(const std::string& db_name, std::string* sql);
76
77 // Conveniences to prepare the two types of statements used by
78 // MetaTableHelper.
79 bool PrepareSetStatement(SQLStatement* statement, const std::string& key);
80 bool PrepareGetStatement(SQLStatement* statement, const std::string& key);
81
82 sqlite3* db_;
83
84 // Name of the database within the connection, if there is one. When empty,
85 // there is no special database name.
86 std::string db_name_;
87
88 DISALLOW_EVIL_CONSTRUCTORS(MetaTableHelper);
89 };
90
91 #endif // CHROME_BROWSER_META_TABLE_HELPER_H__
OLDNEW
« no previous file with comments | « chrome/browser/history/thumbnail_database.h ('k') | chrome/browser/meta_table_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698