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_SYNC_UTIL_SQLITE_UTILS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_SQLITE_UTILS_H_ |
6 #define CHROME_BROWSER_SYNC_UTIL_SQLITE_UTILS_H_ | 6 #define CHROME_BROWSER_SYNC_UTIL_SQLITE_UTILS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/string16.h" | 15 #include "base/string16.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "third_party/sqlite/sqlite3.h" | 17 #include "third_party/sqlite/sqlite3.h" |
17 | 18 |
18 class FilePath; | 19 class FilePath; |
19 | 20 |
20 namespace sqlite_utils { | 21 namespace sqlite_utils { |
21 | 22 |
22 class SQLTransaction; | 23 class SQLTransaction; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // And vice versa. | 148 // And vice versa. |
148 // | 149 // |
149 // TODO(michaeln): demonstrate usage here | 150 // TODO(michaeln): demonstrate usage here |
150 // TODO(michaeln): safegaurds to prevent mis-use | 151 // TODO(michaeln): safegaurds to prevent mis-use |
151 class SQLNestedTransaction : public SQLTransaction { | 152 class SQLNestedTransaction : public SQLTransaction { |
152 public: | 153 public: |
153 explicit SQLNestedTransaction(SQLNestedTransactionSite* site); | 154 explicit SQLNestedTransaction(SQLNestedTransactionSite* site); |
154 virtual ~SQLNestedTransaction(); | 155 virtual ~SQLNestedTransaction(); |
155 | 156 |
156 protected: | 157 protected: |
157 virtual int BeginCommand(const char* command); | 158 virtual int BeginCommand(const char* command) OVERRIDE; |
158 virtual int EndCommand(const char* command); | 159 virtual int EndCommand(const char* command) OVERRIDE; |
159 | 160 |
160 private: | 161 private: |
161 bool needs_rollback_; | 162 bool needs_rollback_; |
162 SQLNestedTransactionSite* site_; | 163 SQLNestedTransactionSite* site_; |
163 DISALLOW_COPY_AND_ASSIGN(SQLNestedTransaction); | 164 DISALLOW_COPY_AND_ASSIGN(SQLNestedTransaction); |
164 }; | 165 }; |
165 | 166 |
166 // A scoped sqlite statement that finalizes when it goes out of scope. | 167 // A scoped sqlite statement that finalizes when it goes out of scope. |
167 class scoped_sqlite3_stmt_ptr { | 168 class scoped_sqlite3_stmt_ptr { |
168 public: | 169 public: |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return DoesSqliteColumnExist(db, NULL, table_name, column_name, column_type); | 374 return DoesSqliteColumnExist(db, NULL, table_name, column_name, column_type); |
374 } | 375 } |
375 | 376 |
376 // Test whether a table has one or more rows. Returns true if the table | 377 // Test whether a table has one or more rows. Returns true if the table |
377 // has one or more rows and false if the table is empty or doesn't exist. | 378 // has one or more rows and false if the table is empty or doesn't exist. |
378 bool DoesSqliteTableHaveRow(sqlite3* db, const char* table_name); | 379 bool DoesSqliteTableHaveRow(sqlite3* db, const char* table_name); |
379 | 380 |
380 } // namespace sqlite_utils | 381 } // namespace sqlite_utils |
381 | 382 |
382 #endif // CHROME_BROWSER_SYNC_UTIL_SQLITE_UTILS_H_ | 383 #endif // CHROME_BROWSER_SYNC_UTIL_SQLITE_UTILS_H_ |
OLD | NEW |