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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 // Executes a rollback statement, ignoring all transaction state. Used | 505 // Executes a rollback statement, ignoring all transaction state. Used |
506 // internally in the transaction management code. | 506 // internally in the transaction management code. |
507 void DoRollback(); | 507 void DoRollback(); |
508 | 508 |
509 // Called by a StatementRef when it's being created or destroyed. See | 509 // Called by a StatementRef when it's being created or destroyed. See |
510 // open_statements_ below. | 510 // open_statements_ below. |
511 void StatementRefCreated(StatementRef* ref); | 511 void StatementRefCreated(StatementRef* ref); |
512 void StatementRefDeleted(StatementRef* ref); | 512 void StatementRefDeleted(StatementRef* ref); |
513 | 513 |
514 // Called by Statement objects when an sqlite function returns an error. | 514 // Called when a sqlite function returns an error, which is passed |
515 // The return value is the error code reflected back to client code. | 515 // as |err|. The return value is the error code to be reflected |
516 int OnSqliteError(int err, Statement* stmt); | 516 // back to client code. |stmt| is non-NULL if the error relates to |
| 517 // an sql::Statement instance. |sql| is non-NULL if the error |
| 518 // relates to non-statement sql code (Execute, for instance). Both |
| 519 // can be NULL, but both should never be set. |
| 520 // NOTE(shess): Originally, the return value was intended to allow |
| 521 // error handlers to transparently convert errors into success. |
| 522 // Unfortunately, transactions are not generally restartable, so |
| 523 // this did not work out. |
| 524 int OnSqliteError(int err, Statement* stmt, const char* sql); |
517 | 525 |
518 // Like |Execute()|, but retries if the database is locked. | 526 // Like |Execute()|, but retries if the database is locked. |
519 bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout) | 527 bool ExecuteWithTimeout(const char* sql, base::TimeDelta ms_timeout) |
520 WARN_UNUSED_RESULT; | 528 WARN_UNUSED_RESULT; |
521 | 529 |
522 // Internal helper for const functions. Like GetUniqueStatement(), | 530 // Internal helper for const functions. Like GetUniqueStatement(), |
523 // except the statement is not entered into open_statements_, | 531 // except the statement is not entered into open_statements_, |
524 // allowing this function to be const. Open statements can block | 532 // allowing this function to be const. Open statements can block |
525 // closing the database, so only use in cases where the last ref is | 533 // closing the database, so only use in cases where the last ref is |
526 // released before close could be called (which should always be the | 534 // released before close could be called (which should always be the |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 580 |
573 // Tag for auxiliary histograms. | 581 // Tag for auxiliary histograms. |
574 std::string histogram_tag_; | 582 std::string histogram_tag_; |
575 | 583 |
576 DISALLOW_COPY_AND_ASSIGN(Connection); | 584 DISALLOW_COPY_AND_ASSIGN(Connection); |
577 }; | 585 }; |
578 | 586 |
579 } // namespace sql | 587 } // namespace sql |
580 | 588 |
581 #endif // SQL_CONNECTION_H_ | 589 #endif // SQL_CONNECTION_H_ |
OLD | NEW |