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/database | |
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/database')
-rw-r--r-- | webkit/database/database_connections.cc | 12 | ||||
-rw-r--r-- | webkit/database/database_connections.h | 5 | ||||
-rw-r--r-- | webkit/database/database_tracker.cc | 11 | ||||
-rw-r--r-- | webkit/database/database_tracker.h | 6 |
4 files changed, 26 insertions, 8 deletions
diff --git a/webkit/database/database_connections.cc b/webkit/database/database_connections.cc index a6e6d3d..c6e9609 100644 --- a/webkit/database/database_connections.cc +++ b/webkit/database/database_connections.cc @@ -15,8 +15,13 @@ DatabaseConnections::~DatabaseConnections() { DCHECK(connections_.empty()); } -bool DatabaseConnections::IsDatabaseOpened(const string16& origin_identifier, - const string16& database_name) { +bool DatabaseConnections::IsEmpty() const { + return connections_.empty(); +} + +bool DatabaseConnections::IsDatabaseOpened( + const string16& origin_identifier, + const string16& database_name) const { OriginConnections::const_iterator origin_it = connections_.find(origin_identifier); if (origin_it == connections_.end()) @@ -25,7 +30,8 @@ bool DatabaseConnections::IsDatabaseOpened(const string16& origin_identifier, return (origin_connections.find(database_name) != origin_connections.end()); } -bool DatabaseConnections::IsOriginUsed(const string16& origin_identifier) { +bool DatabaseConnections::IsOriginUsed( + const string16& origin_identifier) const { return (connections_.find(origin_identifier) != connections_.end()); } diff --git a/webkit/database/database_connections.h b/webkit/database/database_connections.h index e036940..02941c8 100644 --- a/webkit/database/database_connections.h +++ b/webkit/database/database_connections.h @@ -16,9 +16,10 @@ class DatabaseConnections { DatabaseConnections(); ~DatabaseConnections(); + bool IsEmpty() const; bool IsDatabaseOpened(const string16& origin_identifier, - const string16& database_name); - bool IsOriginUsed(const string16& origin_identifier); + const string16& database_name) const; + bool IsOriginUsed(const string16& origin_identifier) const; void AddConnection(const string16& origin_identifier, const string16& database_name); void RemoveConnection(const string16& origin_identifier, diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc index 16766b4..01c3052 100644 --- a/webkit/database/database_tracker.cc +++ b/webkit/database/database_tracker.cc @@ -25,7 +25,6 @@ const FilePath::CharType kTrackerDatabaseFileName[] = FILE_PATH_LITERAL("Databases.db"); const int kCurrentVersion = 2; const int kCompatibleVersion = 1; -const int64 kDefaultQuota = 5 * 1024 * 1024; const int64 kDefaultExtensionQuota = 50 * 1024 * 1024; const char* kExtensionOriginIdentifierPrefix = "chrome-extension_"; @@ -34,13 +33,19 @@ DatabaseTracker::DatabaseTracker(const FilePath& profile_path) db_dir_(profile_path.Append(FilePath(kDatabaseDirectoryName))), db_(new sql::Connection()), databases_table_(NULL), - meta_table_(NULL) { + meta_table_(NULL), + default_quota_(5 * 1024 * 1024) { } DatabaseTracker::~DatabaseTracker() { DCHECK(observers_.size() == 0); } +void DatabaseTracker::SetDefaultQuota(int64 quota) { + default_quota_ = quota; + ClearAllCachedOriginInfo(); +} + void DatabaseTracker::DatabaseOpened(const string16& origin_identifier, const string16& database_name, const string16& database_description, @@ -291,7 +296,7 @@ DatabaseTracker::CachedOriginInfo* DatabaseTracker::GetCachedOriginInfo( true)) { origin_info.SetQuota(kDefaultExtensionQuota); } else { - origin_info.SetQuota(kDefaultQuota); + origin_info.SetQuota(default_quota_); } } diff --git a/webkit/database/database_tracker.h b/webkit/database/database_tracker.h index 24ea877..f3f6041 100644 --- a/webkit/database/database_tracker.h +++ b/webkit/database/database_tracker.h @@ -86,6 +86,9 @@ class DatabaseTracker explicit DatabaseTracker(const FilePath& profile_path); + // Sets the default quota for all origins. Should be used in tests only. + void SetDefaultQuota(int64 quota); + void DatabaseOpened(const string16& origin_identifier, const string16& database_name, const string16& database_details, @@ -160,6 +163,9 @@ class DatabaseTracker std::map<string16, CachedOriginInfo> origins_info_map_; DatabaseConnections database_connections_; + // Default quota for all origins; changed only by tests + int64 default_quota_; + FRIEND_TEST(DatabaseTrackerTest, TestIt); }; |