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

Unified Diff: chrome/browser/in_process_webkit/indexed_db_key_utility_client.h

Issue 6209005: Fix IndexedDB race condition during shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First stab at new approach 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
Index: chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
diff --git a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
index 3a79c282be520b8bfa973c23b68d6a2eb96b9e04..20887ead277dc12d6346ba7ef22965988a7bc037 100644
--- a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
+++ b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/ref_counted.h"
+#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/utility_process_host.h"
@@ -21,17 +22,12 @@ class SerializedScriptValue;
class IndexedDBKeyUtilityClient
: public base::RefCountedThreadSafe<IndexedDBKeyUtilityClient> {
public:
- IndexedDBKeyUtilityClient();
- // Starts the UtilityProcess. Must be called before any other method.
- void StartUtilityProcess();
+ // Get a pointer to the IndexedDBKeyUtilityClient instance.
+ static IndexedDBKeyUtilityClient* Get();
- // Ends the UtilityProcess. Must be called after StartUtilityProcess() and
- // before destruction.
- // TODO(bulach): figure out an appropriate hook so that we can keep the
- // UtilityProcess running for a longer period of time and avoid spinning it
- // on every IDBObjectStore::Put call.
- void EndUtilityProcess();
+ // Shut down the IndexedDBKeyUtilityClient if it was ever started.
+ static void Shutdown();
// Synchronously obtain the |keys| from |values| for the given |key_path|.
void CreateIDBKeysFromSerializedValuesAndKeyPath(
@@ -57,8 +53,16 @@ class IndexedDBKeyUtilityClient
};
friend class base::RefCountedThreadSafe<IndexedDBKeyUtilityClient>;
+ IndexedDBKeyUtilityClient();
~IndexedDBKeyUtilityClient();
+ // Lock to protect the instance_ member.
+ static base::Lock instantiation_lock_;
+ static scoped_refptr<IndexedDBKeyUtilityClient> instance_;
bulach 2011/01/14 17:55:08 iirc, it's not safe / advisable to have non-POD st
+
+ // Starts the UtilityProcess. Must be called before any other method.
+ void StartUtilityProcess();
+
void GetRDHAndStartUtilityProcess();
void StartUtilityProcessInternal(ResourceDispatcherHost* rdh);
void EndUtilityProcessInternal();

Powered by Google App Engine
This is Rietveld 408576698