diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 19:54:50 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 19:54:50 +0000 |
commit | 35f7e5399e616c4076a10d9f06d2e97e9880558f (patch) | |
tree | c793b0cd91bf5161877ecde1bef1a5fe7ba874c4 /sql/connection.h | |
parent | c41e051dd15512eb3040d56f9aeea758d505de1d (diff) | |
download | chromium_src-35f7e5399e616c4076a10d9f06d2e97e9880558f.zip chromium_src-35f7e5399e616c4076a10d9f06d2e97e9880558f.tar.gz chromium_src-35f7e5399e616c4076a10d9f06d2e97e9880558f.tar.bz2 |
Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access.
Also expanded scope of ScopedAllowIO in
SQLiteServerBoundCertStore::Backend::Load() to cover SQLite functions.
And added ScopedAllowIO to PasswordStoreFactory::BuildServiceInstanceFor() --
it calls LoginDatabase::Init() which should be executed on DB thread.
This is a reland of
https://src.chromium.org/viewvc/chrome?view=rev&revision=147309
which was reverted because of missing ScopedAllowIO in PasswordStoreFactory.
Patch from Pavel Ivanov <paivanof@gmail.com>
BUG=75232, 52909, 137961, 138903
TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!"
Review URL: https://chromiumcodereview.appspot.com/10824008
Patch from Pavel Ivanov <paivanof@gmail.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148788 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.h')
-rw-r--r-- | sql/connection.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/connection.h b/sql/connection.h index e5c9469..65020a0 100644 --- a/sql/connection.h +++ b/sql/connection.h @@ -12,6 +12,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "base/threading/thread_restrictions.h" #include "base/time.h" #include "sql/sql_export.h" @@ -320,6 +321,14 @@ class SQL_EXPORT Connection { // sqlite3_open. The string can also be sqlite's special ":memory:" string. bool OpenInternal(const std::string& file_name); + // 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. + void AssertIOAllowed() { + if (!in_memory_) + base::ThreadRestrictions::AssertIOAllowed(); + } + // Internal helper for DoesTableExist and DoesIndexExist. bool DoesTableOrIndexExist(const char* name, const char* type) const; @@ -356,6 +365,10 @@ class SQL_EXPORT Connection { // no longer be active. void Close(); + // Check whether the current thread is allowed to make IO calls, but only + // if database wasn't open in memory. + void AssertIOAllowed() { if (connection_) connection_->AssertIOAllowed(); } + private: friend class base::RefCounted<StatementRef>; @@ -426,6 +439,10 @@ class SQL_EXPORT Connection { // a rollback instead of a commit. bool needs_rollback_; + // True if database is open with OpenInMemory(), False if database is open + // with Open(). + bool in_memory_; + // This object handles errors resulting from all forms of executing sqlite // commands or statements. It can be null which means default handling. scoped_refptr<ErrorDelegate> error_delegate_; |