summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:04:25 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 01:04:25 +0000
commit12cbfda3f72e24147789eed981e68c373ba1c14f (patch)
tree9cf47e58dc21c8bf9ba61cd56ab08cecca80c601
parent63b06e38ffea00111f7efdd20e34ed68b6c4eab9 (diff)
downloadchromium_src-12cbfda3f72e24147789eed981e68c373ba1c14f.zip
chromium_src-12cbfda3f72e24147789eed981e68c373ba1c14f.tar.gz
chromium_src-12cbfda3f72e24147789eed981e68c373ba1c14f.tar.bz2
Wait for the DB thread to finish posting tasks to the main thread
before setting the WebKit client to NULL. TEST=none BUG=32228,32226 Review URL: http://codereview.chromium.org/545178 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37594 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/render_thread.cc5
-rw-r--r--chrome/renderer/renderer_web_database_observer.cc26
-rw-r--r--chrome/renderer/renderer_web_database_observer.h11
3 files changed, 36 insertions, 6 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 1b4cd96..2d47a43 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -210,10 +210,15 @@ void RenderThread::Init() {
}
RenderThread::~RenderThread() {
+ // Wait for all databases to be closed.
+ if (renderer_web_database_observer_.get())
+ renderer_web_database_observer_->WaitForAllDatabasesToClose();
+
// Shutdown in reverse of the initialization order.
RemoveFilter(devtools_agent_filter_.get());
RemoveFilter(db_message_filter_.get());
db_message_filter_ = NULL;
+
if (webkit_client_.get())
WebKit::shutdown();
diff --git a/chrome/renderer/renderer_web_database_observer.cc b/chrome/renderer/renderer_web_database_observer.cc
index 15a5d17..2ded3cb 100644
--- a/chrome/renderer/renderer_web_database_observer.cc
+++ b/chrome/renderer/renderer_web_database_observer.cc
@@ -4,19 +4,26 @@
#include "chrome/renderer/renderer_web_database_observer.h"
+#include "base/auto_reset.h"
+#include "base/message_loop.h"
+#include "base/string16.h"
#include "chrome/common/render_messages.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
RendererWebDatabaseObserver::RendererWebDatabaseObserver(
IPC::Message::Sender* sender)
- : sender_(sender) {
+ : sender_(sender),
+ waiting_for_dbs_to_close_(false) {
}
void RendererWebDatabaseObserver::databaseOpened(
const WebKit::WebDatabase& database) {
+ string16 origin_identifier = database.securityOrigin().databaseIdentifier();
+ string16 database_name = database.name();
sender_->Send(new ViewHostMsg_DatabaseOpened(
- database.securityOrigin().databaseIdentifier(), database.name(),
+ origin_identifier, database_name,
database.displayName(), database.estimatedSize()));
+ database_connections_.AddConnection(origin_identifier, database_name);
}
void RendererWebDatabaseObserver::databaseModified(
@@ -27,6 +34,19 @@ void RendererWebDatabaseObserver::databaseModified(
void RendererWebDatabaseObserver::databaseClosed(
const WebKit::WebDatabase& database) {
+ string16 origin_identifier = database.securityOrigin().databaseIdentifier();
+ string16 database_name = database.name();
sender_->Send(new ViewHostMsg_DatabaseClosed(
- database.securityOrigin().databaseIdentifier(), database.name()));
+ origin_identifier, database_name));
+ database_connections_.RemoveConnection(origin_identifier, database_name);
+ if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty())
+ MessageLoop::current()->Quit();
+}
+
+void RendererWebDatabaseObserver::WaitForAllDatabasesToClose() {
+ if (!database_connections_.IsEmpty()) {
+ AutoReset waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true);
+ MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
+ MessageLoop::current()->Run();
+ }
}
diff --git a/chrome/renderer/renderer_web_database_observer.h b/chrome/renderer/renderer_web_database_observer.h
index 8d7ce56..120b277 100644
--- a/chrome/renderer/renderer_web_database_observer.h
+++ b/chrome/renderer/renderer_web_database_observer.h
@@ -1,12 +1,13 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef CHROME_RENDERER_RENDERER_WEB_DATABASE_OBSERVER_H_
#define CHROME_RENDERER_RENDERER_WEB_DATABASE_OBSERVER_H_
#include "ipc/ipc_message.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabaseObserver.h"
+#include "webkit/database/database_connections.h"
class RendererWebDatabaseObserver : public WebKit::WebDatabaseObserver {
public:
@@ -15,8 +16,12 @@ class RendererWebDatabaseObserver : public WebKit::WebDatabaseObserver {
virtual void databaseModified(const WebKit::WebDatabase& database);
virtual void databaseClosed(const WebKit::WebDatabase& database);
+ void WaitForAllDatabasesToClose();
+
private:
IPC::Message::Sender* sender_;
+ bool waiting_for_dbs_to_close_;
+ webkit_database::DatabaseConnections database_connections_;
};
#endif // CHROME_RENDERER_RENDERER_WEB_DATABASE_OBSERVER_H_