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..ab2bcae8862d6e3d1d511145ae5d3740685fcbc2 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 |
@@ -6,32 +6,26 @@ |
#define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ |
#pragma once |
+#include <vector> |
+ |
#include "base/ref_counted.h" |
-#include "base/synchronization/waitable_event.h" |
-#include "chrome/browser/utility_process_host.h" |
+#include "base/singleton.h" |
+#include "base/string16.h" |
class IndexedDBKey; |
class SerializedScriptValue; |
+class KeyUtilityClientImpl; |
-// This class is responsible to obtain IndexedDBKeys from the |
-// SerializedScriptValues given an IDBKeyPath. It uses UtilityProcess to do this |
-// inside a sandbox (a V8 lock is required there). At this level, all methods |
-// are synchronous as required by the caller. The public API is used on |
-// WEBKIT thread, but internally it moves around to UI and IO as needed. |
-class IndexedDBKeyUtilityClient |
- : public base::RefCountedThreadSafe<IndexedDBKeyUtilityClient> { |
+// Class for obtaining IndexedDBKeys from the SerializedScriptValues given |
+// an IDBKeyPath. This class is a thin singleton wrapper around the |
+// KeyUtilityClientImpl, which does the real work. |
+class IndexedDBKeyUtilityClient { |
public: |
- IndexedDBKeyUtilityClient(); |
+ // Returns the singleton instance of the IndexedDBKeyUtilityClient. |
+ static IndexedDBKeyUtilityClient* GetInstance(); |
- // Starts the UtilityProcess. Must be called before any other method. |
- void StartUtilityProcess(); |
- |
- // 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 underlying implementation. |
bulach
2011/01/20 16:49:15
add a note about which thread this must be called?
hans
2011/01/20 17:24:59
Done.
|
+ void Shutdown(); |
// Synchronously obtain the |keys| from |values| for the given |key_path|. |
void CreateIDBKeysFromSerializedValuesAndKeyPath( |
@@ -40,53 +34,13 @@ class IndexedDBKeyUtilityClient |
std::vector<IndexedDBKey>* keys); |
private: |
- class Client : public UtilityProcessHost::Client { |
- public: |
- explicit Client(IndexedDBKeyUtilityClient* parent); |
- |
- // UtilityProcessHost::Client |
- virtual void OnProcessCrashed(int exit_code); |
- virtual void OnIDBKeysFromValuesAndKeyPathSucceeded( |
- int id, const std::vector<IndexedDBKey>& keys); |
- virtual void OnIDBKeysFromValuesAndKeyPathFailed(int id); |
- |
- private: |
- IndexedDBKeyUtilityClient* parent_; |
- |
- DISALLOW_COPY_AND_ASSIGN(Client); |
- }; |
- |
- friend class base::RefCountedThreadSafe<IndexedDBKeyUtilityClient>; |
+ friend struct DefaultSingletonTraits<IndexedDBKeyUtilityClient>; |
+ IndexedDBKeyUtilityClient(); |
~IndexedDBKeyUtilityClient(); |
- void GetRDHAndStartUtilityProcess(); |
- void StartUtilityProcessInternal(ResourceDispatcherHost* rdh); |
- void EndUtilityProcessInternal(); |
- void CallStartIDBKeyFromValueAndKeyPathFromIOThread( |
- const std::vector<SerializedScriptValue>& values, |
- const string16& key_path); |
- |
- void SetKeys(const std::vector<IndexedDBKey>& keys); |
- void FinishCreatingKeys(); |
- |
- base::WaitableEvent waitable_event_; |
- |
- // Used in both IO and WEBKIT threads, but guarded by WaitableEvent, i.e., |
- // these members are only set / read when the other thread is blocked. |
- enum State { |
- STATE_UNINITIALIZED, |
- STATE_INITIALIZED, |
- STATE_CREATING_KEYS, |
- STATE_SHUTDOWN, |
- }; |
- State state_; |
- std::vector<IndexedDBKey> keys_; |
- |
- // Used in the IO thread. |
- UtilityProcessHost* utility_process_host_; |
- scoped_refptr<Client> client_; |
- |
- DISALLOW_COPY_AND_ASSIGN(IndexedDBKeyUtilityClient); |
+ // The real client; laziliy instantiated. |
bulach
2011/01/20 16:49:15
move the comment one down
hans
2011/01/20 17:24:59
Whoops. Done.
|
+ bool is_shutdown_; |
+ scoped_refptr<KeyUtilityClientImpl> impl_; |
}; |
#endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_KEY_UTILITY_CLIENT_H_ |