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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> { | 363 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> { |
364 public: | 364 public: |
365 // Default constructor initializes to an invalid statement. | 365 // Default constructor initializes to an invalid statement. |
366 StatementRef(); | 366 StatementRef(); |
367 explicit StatementRef(sqlite3_stmt* stmt); | 367 explicit StatementRef(sqlite3_stmt* stmt); |
368 StatementRef(Connection* connection, sqlite3_stmt* stmt); | 368 StatementRef(Connection* connection, sqlite3_stmt* stmt); |
369 | 369 |
370 // When true, the statement can be used. | 370 // When true, the statement can be used. |
371 bool is_valid() const { return !!stmt_; } | 371 bool is_valid() const { return !!stmt_; } |
372 | 372 |
373 // If we've not been linked to a connection, this will be NULL. Guaranteed | 373 // If we've not been linked to a connection, this will be NULL. |
374 // non-NULL when is_valid(). | 374 // TODO(shess): connection_ can be NULL in case of GetUntrackedStatement(), |
| 375 // which prevents Statement::OnError() from forwarding errors. |
375 Connection* connection() const { return connection_; } | 376 Connection* connection() const { return connection_; } |
376 | 377 |
377 // Returns the sqlite statement if any. If the statement is not active, | 378 // Returns the sqlite statement if any. If the statement is not active, |
378 // this will return NULL. | 379 // this will return NULL. |
379 sqlite3_stmt* stmt() const { return stmt_; } | 380 sqlite3_stmt* stmt() const { return stmt_; } |
380 | 381 |
381 // Destroys the compiled statement and marks it NULL. The statement will | 382 // Destroys the compiled statement and marks it NULL. The statement will |
382 // no longer be active. | 383 // no longer be active. |
383 void Close(); | 384 void Close(); |
384 | 385 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 467 |
467 // Auxiliary error-code histogram. | 468 // Auxiliary error-code histogram. |
468 std::string error_histogram_name_; | 469 std::string error_histogram_name_; |
469 | 470 |
470 DISALLOW_COPY_AND_ASSIGN(Connection); | 471 DISALLOW_COPY_AND_ASSIGN(Connection); |
471 }; | 472 }; |
472 | 473 |
473 } // namespace sql | 474 } // namespace sql |
474 | 475 |
475 #endif // SQL_CONNECTION_H_ | 476 #endif // SQL_CONNECTION_H_ |
OLD | NEW |