| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 SQL_CONNECTION_H_ | 5 #ifndef SQL_CONNECTION_H_ |
| 6 #define SQL_CONNECTION_H_ | 6 #define SQL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // Breaks all outstanding transactions (as initiated by | 258 // Breaks all outstanding transactions (as initiated by |
| 259 // BeginTransaction()), calls Raze() to destroy the database, then | 259 // BeginTransaction()), calls Raze() to destroy the database, then |
| 260 // closes the database. After this is called, any operations | 260 // closes the database. After this is called, any operations |
| 261 // against the connections (or statements prepared by the | 261 // against the connections (or statements prepared by the |
| 262 // connection) should fail safely. | 262 // connection) should fail safely. |
| 263 // | 263 // |
| 264 // The value from Raze() is returned, with Close() called in all | 264 // The value from Raze() is returned, with Close() called in all |
| 265 // cases. | 265 // cases. |
| 266 bool RazeAndClose(); | 266 bool RazeAndClose(); |
| 267 | 267 |
| 268 // Delete the underlying database files associated with |path|. |
| 269 // This should be used on a database which has no existing |
| 270 // connections. If any other connections are open to the same |
| 271 // database, this could cause odd results or corruption (for |
| 272 // instance if a hot journal is deleted but the associated database |
| 273 // is not). |
| 274 // |
| 275 // Returns true if the database file and associated journals no |
| 276 // longer exist, false otherwise. If the database has never |
| 277 // existed, this will return true. |
| 278 static bool Delete(const base::FilePath& path); |
| 279 |
| 268 // Transactions -------------------------------------------------------------- | 280 // Transactions -------------------------------------------------------------- |
| 269 | 281 |
| 270 // Transaction management. We maintain a virtual transaction stack to emulate | 282 // Transaction management. We maintain a virtual transaction stack to emulate |
| 271 // nested transactions since sqlite can't do nested transactions. The | 283 // nested transactions since sqlite can't do nested transactions. The |
| 272 // limitation is you can't roll back a sub transaction: if any transaction | 284 // limitation is you can't roll back a sub transaction: if any transaction |
| 273 // fails, all transactions open will also be rolled back. Any nested | 285 // fails, all transactions open will also be rolled back. Any nested |
| 274 // transactions after one has rolled back will return fail for Begin(). If | 286 // transactions after one has rolled back will return fail for Begin(). If |
| 275 // Begin() fails, you must not call Commit or Rollback(). | 287 // Begin() fails, you must not call Commit or Rollback(). |
| 276 // | 288 // |
| 277 // Normally you should use sql::Transaction to manage a transaction, which | 289 // Normally you should use sql::Transaction to manage a transaction, which |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 547 |
| 536 // Tag for auxiliary histograms. | 548 // Tag for auxiliary histograms. |
| 537 std::string histogram_tag_; | 549 std::string histogram_tag_; |
| 538 | 550 |
| 539 DISALLOW_COPY_AND_ASSIGN(Connection); | 551 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 540 }; | 552 }; |
| 541 | 553 |
| 542 } // namespace sql | 554 } // namespace sql |
| 543 | 555 |
| 544 #endif // SQL_CONNECTION_H_ | 556 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |