diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 21:15:55 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 21:15:55 +0000 |
commit | 3ccfe535658c8852c1cc1df01372ecc602f376cd (patch) | |
tree | 47582af5ba2a4f0658126d564d618c18a93173cf /chrome/browser/renderer_host | |
parent | 6d8e2a64b6961331816689850192a8ee864f9a97 (diff) | |
download | chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.zip chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.tar.gz chromium_src-3ccfe535658c8852c1cc1df01372ecc602f376cd.tar.bz2 |
Adding methods that will be used by the quota management UI.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/507014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/database_dispatcher_host.cc | 29 | ||||
-rw-r--r-- | chrome/browser/renderer_host/database_dispatcher_host.h | 7 |
2 files changed, 16 insertions, 20 deletions
diff --git a/chrome/browser/renderer_host/database_dispatcher_host.cc b/chrome/browser/renderer_host/database_dispatcher_host.cc index 41b8331..c79796a 100644 --- a/chrome/browser/renderer_host/database_dispatcher_host.cc +++ b/chrome/browser/renderer_host/database_dispatcher_host.cc @@ -67,6 +67,12 @@ void DatabaseDispatcherHost::AddObserver() { void DatabaseDispatcherHost::RemoveObserver() { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); + + // If the renderer process died without closing all databases, + // then we need to manually close those connections + db_tracker_->CloseDatabases(database_connections_); + database_connections_.RemoveAllConnections(); + db_tracker_->RemoveObserver(this); } @@ -305,7 +311,7 @@ void DatabaseDispatcherHost::DatabaseOpened(const string16& origin_identifier, DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); int64 database_size = 0; int64 space_available = 0; - AddAccessedOrigin(origin_identifier); + database_connections_.AddConnection(origin_identifier, database_name); db_tracker_->DatabaseOpened(origin_identifier, database_name, description, estimated_size, &database_size, &space_available); ChromeThread::PostTask( @@ -331,7 +337,8 @@ void DatabaseDispatcherHost::OnDatabaseModified( void DatabaseDispatcherHost::DatabaseModified(const string16& origin_identifier, const string16& database_name) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - if (!HasAccessedOrigin(origin_identifier)) { + if (!database_connections_.IsDatabaseOpened( + origin_identifier, database_name)) { ReceivedBadMessage(ViewHostMsg_DatabaseModified::ID); return; } @@ -352,12 +359,14 @@ void DatabaseDispatcherHost::OnDatabaseClosed(const string16& origin_identifier, void DatabaseDispatcherHost::DatabaseClosed(const string16& origin_identifier, const string16& database_name) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - if (!HasAccessedOrigin(origin_identifier)) { + if (!database_connections_.IsDatabaseOpened( + origin_identifier, database_name)) { ReceivedBadMessage(ViewHostMsg_DatabaseClosed::ID); return; } db_tracker_->DatabaseClosed(origin_identifier, database_name); + database_connections_.RemoveConnection(origin_identifier, database_name); } void DatabaseDispatcherHost::OnDatabaseSizeChanged( @@ -366,7 +375,7 @@ void DatabaseDispatcherHost::OnDatabaseSizeChanged( int64 database_size, int64 space_available) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - if (HasAccessedOrigin(origin_identifier)) { + if (database_connections_.IsOriginUsed(origin_identifier)) { ChromeThread::PostTask( ChromeThread::IO, FROM_HERE, NewRunnableMethod(this, @@ -376,15 +385,3 @@ void DatabaseDispatcherHost::OnDatabaseSizeChanged( database_size, space_available))); } } - -void DatabaseDispatcherHost::AddAccessedOrigin( - const string16& origin_identifier) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - accessed_origins_.insert(origin_identifier); -} - -bool DatabaseDispatcherHost::HasAccessedOrigin( - const string16& origin_identifier) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); - return (accessed_origins_.find(origin_identifier) != accessed_origins_.end()); -} diff --git a/chrome/browser/renderer_host/database_dispatcher_host.h b/chrome/browser/renderer_host/database_dispatcher_host.h index eb0f8f1..301c261 100644 --- a/chrome/browser/renderer_host/database_dispatcher_host.h +++ b/chrome/browser/renderer_host/database_dispatcher_host.h @@ -10,6 +10,7 @@ #include "base/ref_counted.h" #include "base/string16.h" #include "ipc/ipc_message.h" +#include "webkit/database/database_connections.h" #include "webkit/database/database_tracker.h" class DatabaseDispatcherHost @@ -81,9 +82,6 @@ class DatabaseDispatcherHost void DatabaseClosed(const string16& origin_identifier, const string16& database_name); - void AddAccessedOrigin(const string16& origin_identifier); - bool HasAccessedOrigin(const string16& origin_identifier); - // The database tracker for the current profile. scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; @@ -102,7 +100,8 @@ class DatabaseDispatcherHost // only when the corresponding renderer process is about to go away. bool shutdown_; - base::hash_set<string16> accessed_origins_; + // Keeps track of all DB connections opened by this renderer + webkit_database::DatabaseConnections database_connections_; }; #endif // CHROME_BROWSER_RENDERER_HOST_DATABASE_DISPATCHER_HOST_H_ |