Chromium Code Reviews| Index: sql/connection.h |
| diff --git a/sql/connection.h b/sql/connection.h |
| index 2722ffdc7f9d51557090b2300d1514135b9737bd..5ab7067b9ec3d213170f2792efa6627baaa48a68 100644 |
| --- a/sql/connection.h |
| +++ b/sql/connection.h |
| @@ -218,6 +218,16 @@ class SQL_EXPORT Connection { |
| bool Raze(); |
| bool RazeWithTimout(base::TimeDelta timeout); |
| + // Breaks all outstanding transactions (as initiated by |
| + // BeginTransaction()), calls Raze() to destroy the database, then |
| + // closes the database. After this is called, any operations |
|
pkotwicz
2013/01/31 19:22:00
Nit: 1 space instead of 2. You seem to have two sp
Scott Hess - ex-Googler
2013/02/05 01:20:25
I bet I have tens of thousands of instances of thi
|
| + // against the connections (or statements prepared by the |
| + // connection) should fail safely. |
| + // |
| + // The value from Raze() is returned, with Close() called in all |
| + // cases. |
| + bool RazeAndClose(); |
| + |
| // Transactions -------------------------------------------------------------- |
| // Transaction management. We maintain a virtual transaction stack to emulate |
| @@ -338,6 +348,10 @@ class SQL_EXPORT Connection { |
| // sqlite3_open. The string can also be sqlite's special ":memory:" string. |
| bool OpenInternal(const std::string& file_name); |
| + // Internal close function used by Close() and RazeAndClose(). |
| + // |forced| indicates that orderly-shutdown checks should not apply. |
| + void CloseInternal(bool forced); |
| + |
| // Check whether the current thread is allowed to make IO calls, but only |
| // if database wasn't open in memory. Function is inlined to be a no-op in |
| // official build. |
| @@ -370,6 +384,11 @@ class SQL_EXPORT Connection { |
| // When true, the statement can be used. |
| bool is_valid() const { return !!stmt_; } |
| + // When true, the statement is either currently valid, or was |
| + // previously valid but the connection was forcibly closed. Used |
| + // for diagnostic checks. |
| + bool was_valid() const { return was_valid_; } |
| + |
| // If we've not been linked to a connection, this will be NULL. |
| // TODO(shess): connection_ can be NULL in case of GetUntrackedStatement(), |
| // which prevents Statement::OnError() from forwarding errors. |
| @@ -380,8 +399,9 @@ class SQL_EXPORT Connection { |
| sqlite3_stmt* stmt() const { return stmt_; } |
| // Destroys the compiled statement and marks it NULL. The statement will |
| - // no longer be active. |
| - void Close(); |
| + // no longer be active. |forced| is used to indicate if orderly-shutdown |
| + // checks should apply (see Connection::RazeAndClose()). |
| + void Close(bool forced); |
| // Check whether the current thread is allowed to make IO calls, but only |
| // if database wasn't open in memory. |
| @@ -394,6 +414,7 @@ class SQL_EXPORT Connection { |
| Connection* connection_; |
| sqlite3_stmt* stmt_; |
| + bool was_valid_; |
| DISALLOW_COPY_AND_ASSIGN(StatementRef); |
| }; |
| @@ -408,9 +429,6 @@ class SQL_EXPORT Connection { |
| void StatementRefCreated(StatementRef* ref); |
| void StatementRefDeleted(StatementRef* ref); |
| - // Frees all cached statements from statement_cache_. |
| - void ClearCache(); |
| - |
| // Called by Statement objects when an sqlite function returns an error. |
| // The return value is the error code reflected back to client code. |
| int OnSqliteError(int err, Statement* stmt); |
| @@ -461,6 +479,12 @@ class SQL_EXPORT Connection { |
| // with Open(). |
| bool in_memory_; |
| + // |true| if the connection was closed using RazeAndClose(). Used |
| + // to enable diagnostics to distinguish calls to never-opened |
| + // databases (incorrect use of the API) from calls to once-valid |
| + // databases. |
| + bool poisoned_; |
| + |
| // This object handles errors resulting from all forms of executing sqlite |
| // commands or statements. It can be null which means default handling. |
| scoped_ptr<ErrorDelegate> error_delegate_; |