| Index: sql/connection.cc
|
| ===================================================================
|
| --- sql/connection.cc (revision 147715)
|
| +++ sql/connection.cc (working copy)
|
| @@ -76,6 +76,14 @@
|
|
|
| void Connection::StatementRef::Close() {
|
| if (stmt_) {
|
| + // Call to AssertIOAllowed() cannot go at the beginning of the function
|
| + // because Close() is called unconditionally from destructor to clean
|
| + // connection_. And if this is inactive statement this won't cause any
|
| + // disk access and destructor most probably will be called on thread
|
| + // not allowing disk access.
|
| + // TODO(paivanof@gmail.com): This should move to the beginning
|
| + // of the function. http://crbug.com/136655.
|
| + AssertIOAllowed();
|
| sqlite3_finalize(stmt_);
|
| stmt_ = NULL;
|
| }
|
| @@ -88,7 +96,8 @@
|
| cache_size_(0),
|
| exclusive_locking_(false),
|
| transaction_nesting_(0),
|
| - needs_rollback_(false) {
|
| + needs_rollback_(false),
|
| + in_memory_(false) {
|
| }
|
|
|
| Connection::~Connection() {
|
| @@ -104,6 +113,7 @@
|
| }
|
|
|
| bool Connection::OpenInMemory() {
|
| + in_memory_ = true;
|
| return OpenInternal(":memory:");
|
| }
|
|
|
| @@ -125,6 +135,13 @@
|
| ClearCache();
|
|
|
| if (db_) {
|
| + // Call to AssertIOAllowed() cannot go at the beginning of the function
|
| + // because Close() must be called from destructor to clean
|
| + // statement_cache_, it won't cause any disk access and it most probably
|
| + // will happen on thread not allowing disk access.
|
| + // TODO(paivanof@gmail.com): This should move to the beginning
|
| + // of the function. http://crbug.com/136655.
|
| + AssertIOAllowed();
|
| // TODO(shess): Histogram for failure.
|
| sqlite3_close(db_);
|
| db_ = NULL;
|
| @@ -132,6 +149,8 @@
|
| }
|
|
|
| void Connection::Preload() {
|
| + AssertIOAllowed();
|
| +
|
| if (!db_) {
|
| DLOG(FATAL) << "Cannot preload null db";
|
| return;
|
| @@ -156,6 +175,8 @@
|
| // Create an in-memory database with the existing database's page
|
| // size, then backup that database over the existing database.
|
| bool Connection::Raze() {
|
| + AssertIOAllowed();
|
| +
|
| if (!db_) {
|
| DLOG(FATAL) << "Cannot raze null db";
|
| return false;
|
| @@ -292,6 +313,7 @@
|
| }
|
|
|
| int Connection::ExecuteAndReturnErrorCode(const char* sql) {
|
| + AssertIOAllowed();
|
| if (!db_)
|
| return false;
|
| return sqlite3_exec(db_, sql, NULL, NULL, NULL);
|
| @@ -342,6 +364,8 @@
|
|
|
| scoped_refptr<Connection::StatementRef> Connection::GetUniqueStatement(
|
| const char* sql) {
|
| + AssertIOAllowed();
|
| +
|
| if (!db_)
|
| return new StatementRef(this, NULL); // Return inactive statement.
|
|
|
| @@ -355,6 +379,7 @@
|
| }
|
|
|
| bool Connection::IsSQLValid(const char* sql) {
|
| + AssertIOAllowed();
|
| sqlite3_stmt* stmt = NULL;
|
| if (sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL) != SQLITE_OK)
|
| return false;
|
| @@ -441,6 +466,8 @@
|
| }
|
|
|
| bool Connection::OpenInternal(const std::string& file_name) {
|
| + AssertIOAllowed();
|
| +
|
| if (db_) {
|
| DLOG(FATAL) << "sql::Connection is already open.";
|
| return false;
|
|
|