diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 23:04:30 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-22 23:04:30 +0000 |
commit | 373a46081a94ad850299876328b279e25f12e59f (patch) | |
tree | 103b2519dc9c376e555a483cb4a70f105792f0ea /webkit/tools/test_shell/simple_database_system.cc | |
parent | 1c1619682ce5dd4fbfc3caa8c76bdce0b13d09ca (diff) | |
download | chromium_src-373a46081a94ad850299876328b279e25f12e59f.zip chromium_src-373a46081a94ad850299876328b279e25f12e59f.tar.gz chromium_src-373a46081a94ad850299876328b279e25f12e59f.tar.bz2 |
Adds support for SetDatabaseQuota(). Also, should remove a lot of
flakiness from the database layout tests: when a DB test calls
ClearAllDatabases(), we force test_shell to wait for all DBs opened in
previous tests to close before running the test.
TEST=none
BUG=32016,32396,32206,32157,30081
Review URL: http://codereview.chromium.org/549095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/simple_database_system.cc')
-rw-r--r-- | webkit/tools/test_shell/simple_database_system.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/webkit/tools/test_shell/simple_database_system.cc b/webkit/tools/test_shell/simple_database_system.cc index 2b9afe3..a2cd8e3 100644 --- a/webkit/tools/test_shell/simple_database_system.cc +++ b/webkit/tools/test_shell/simple_database_system.cc @@ -10,7 +10,9 @@ #include "third_party/sqlite/preprocessed/sqlite3.h" #endif +#include "base/auto_reset.h" #include "base/file_util.h" +#include "base/message_loop.h" #include "base/platform_thread.h" #include "base/process_util.h" #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" @@ -29,14 +31,17 @@ SimpleDatabaseSystem* SimpleDatabaseSystem::GetInstance() { return instance_; } -SimpleDatabaseSystem::SimpleDatabaseSystem() { +SimpleDatabaseSystem::SimpleDatabaseSystem() + : waiting_for_dbs_to_close_(false) { temp_dir_.CreateUniqueTempDir(); db_tracker_ = new DatabaseTracker(temp_dir_.path()); + db_tracker_->AddObserver(this); DCHECK(!instance_); instance_ = this; } SimpleDatabaseSystem::~SimpleDatabaseSystem() { + db_tracker_->RemoveObserver(this); instance_ = NULL; } @@ -113,6 +118,9 @@ void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier, origin_identifier, database_name)); db_tracker_->DatabaseClosed(origin_identifier, database_name); database_connections_.RemoveConnection(origin_identifier, database_name); + + if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty()) + MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); } void SimpleDatabaseSystem::OnDatabaseSizeChanged( @@ -144,13 +152,22 @@ void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { } void SimpleDatabaseSystem::ClearAllDatabases() { - db_tracker_->CloseDatabases(database_connections_); - database_connections_.RemoveAllConnections(); + // Wait for all databases to be closed. + if (!database_connections_.IsEmpty()) { + AutoReset waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true); + MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current()); + MessageLoop::current()->Run(); + } + db_tracker_->CloseTrackerDatabaseAndClearCaches(); file_util::Delete(db_tracker_->DatabaseDirectory(), true); file_names_.clear(); } +void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) { + db_tracker_->SetDefaultQuota(quota); +} + void SimpleDatabaseSystem::SetFullFilePathsForVfsFile( const string16& origin_identifier, const string16& database_name) { |