Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2961)

Unified Diff: chrome/browser/in_process_webkit/webkit_context.cc

Issue 6209005: Fix IndexedDB race condition during shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/in_process_webkit/indexed_db_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/in_process_webkit/webkit_context.cc
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index 0c72346822a10cccc5ea96eb1efdef5b7f3011e7..36a8d7e906e7f589c72044152d91f0cdf71c78cc 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -5,9 +5,45 @@
#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "base/command_line.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/task.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/profiles/profile.h"
+namespace {
+
+template<typename T>
+class DeletionTask : public Task {
+ public:
+ DeletionTask(T* object, base::WaitableEvent& event)
+ : object_(object),
+ event_(event) {}
+
+ // From Task.
+ virtual void Run() {
+ delete object_;
+ event_.Signal();
+ };
+
+ private:
+ T* object_;
+ base::WaitableEvent& event_;
jorlow 2011/01/12 17:08:21 Why not a pointer? That seems more typical.
+};
+
+template <typename T>
+void DeleteOnThread(BrowserThread::ID thread_id, T* object) {
jorlow 2011/01/12 17:08:21 This is doing more than deleting on a particular t
+ base::WaitableEvent event(true, false);
+ Task* delete_task = new DeletionTask<T>(object, event);
+
+ if (BrowserThread::PostTask(thread_id, FROM_HERE, delete_task)) {
jorlow 2011/01/12 17:08:21 no {}'s
+ event.Wait();
+ } else {
+ delete object;
+ }
+}
+
+} // namespace
+
WebKitContext::WebKitContext(Profile* profile, bool clear_local_state_on_exit)
: data_path_(profile->IsOffTheRecord() ? FilePath() : profile->GetPath()),
is_incognito_(profile->IsOffTheRecord()),
@@ -34,11 +70,7 @@ WebKitContext::~WebKitContext() {
indexed_db_context_->set_clear_local_state_on_exit(
clear_local_state_on_exit_);
- IndexedDBContext* indexed_db_context = indexed_db_context_.release();
- if (!BrowserThread::DeleteSoon(
- BrowserThread::WEBKIT, FROM_HERE, indexed_db_context)) {
- delete indexed_db_context;
- }
+ DeleteOnThread(BrowserThread::WEBKIT, indexed_db_context_.release());
jorlow 2011/01/12 17:08:21 Hm...so we're going to block the io thread on the
}
void WebKitContext::PurgeMemory() {
« no previous file with comments | « chrome/browser/in_process_webkit/indexed_db_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698