| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COMMON_SQLITE_UTILS_H_ | 5 #ifndef CHROME_COMMON_SQLITE_UTILS_H_ |
| 6 #define CHROME_COMMON_SQLITE_UTILS_H_ | 6 #define CHROME_COMMON_SQLITE_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 private: | 345 private: |
| 346 DISALLOW_COPY_AND_ASSIGN(SQLStatement); | 346 DISALLOW_COPY_AND_ASSIGN(SQLStatement); |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 namespace sqlite_utils { | 349 namespace sqlite_utils { |
| 350 | 350 |
| 351 //------------------------------------------------------------------------------ | 351 //------------------------------------------------------------------------------ |
| 352 // A scoped sqlite database that closes when it goes out of scope. | 352 // A scoped sqlite database that closes when it goes out of scope. |
| 353 //------------------------------------------------------------------------------ | 353 //------------------------------------------------------------------------------ |
| 354 class DBClose { | 354 typedef scoped_ptr_malloc<sqlite3, FreeFnIgnoreReturn<sqlite3, sqlite3_close> > |
| 355 public: | 355 scoped_sqlite_db_ptr; |
| 356 inline void operator()(sqlite3* x) const { | |
| 357 sqlite3_close(x); | |
| 358 } | |
| 359 }; | |
| 360 | |
| 361 typedef scoped_ptr_malloc<sqlite3, DBClose> scoped_sqlite_db_ptr; | |
| 362 | 356 |
| 363 // Opens the DB in the file pointed to by |filepath|. This method forces the | 357 // Opens the DB in the file pointed to by |filepath|. This method forces the |
| 364 // database to be in UTF-8 mode on all platforms. See | 358 // database to be in UTF-8 mode on all platforms. See |
| 365 // http://www.sqlite.org/capi3ref.html#sqlite3_open for an explanation of the | 359 // http://www.sqlite.org/capi3ref.html#sqlite3_open for an explanation of the |
| 366 // return value. | 360 // return value. |
| 367 int OpenSqliteDb(const FilePath& filepath, sqlite3** database); | 361 int OpenSqliteDb(const FilePath& filepath, sqlite3** database); |
| 368 | 362 |
| 369 // Returns true if there is a table with the given name in the database. | 363 // Returns true if there is a table with the given name in the database. |
| 370 // For the version where a database name is specified, it may be NULL or the | 364 // For the version where a database name is specified, it may be NULL or the |
| 371 // empty string if no database name is necessary. | 365 // empty string if no database name is necessary. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 401 | 395 |
| 402 } // namespace sqlite_utils | 396 } // namespace sqlite_utils |
| 403 | 397 |
| 404 #if defined(USE_SYSTEM_SQLITE) | 398 #if defined(USE_SYSTEM_SQLITE) |
| 405 // This function is a local change to sqlite3 which doesn't exist when one is | 399 // This function is a local change to sqlite3 which doesn't exist when one is |
| 406 // using the system sqlite library. Thus, we stub it out here. | 400 // using the system sqlite library. Thus, we stub it out here. |
| 407 int sqlite3Preload(sqlite3* db); | 401 int sqlite3Preload(sqlite3* db); |
| 408 #endif | 402 #endif |
| 409 | 403 |
| 410 #endif // CHROME_COMMON_SQLITE_UTILS_H_ | 404 #endif // CHROME_COMMON_SQLITE_UTILS_H_ |
| OLD | NEW |