| Index: chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
|
| diff --git a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
|
| index f708b43dbf0a670e034299b422838af32ac75437..e8717186ace03ab4cbb437d08221212c49297b68 100644
|
| --- a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
|
| +++ b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
|
| @@ -10,6 +10,32 @@
|
| #include "chrome/common/indexed_db_key.h"
|
| #include "chrome/common/serialized_script_value.h"
|
|
|
| +IndexedDBKeyUtilityClient* IndexedDBKeyUtilityClient::Get() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
|
| + AutoLock auto_lock(instantiation_lock_);
|
| +
|
| + if (!instance_.get()) {
|
| + instance_ = new IndexedDBKeyUtilityClient();
|
| + instance_->StartUtilityProcess();
|
| + }
|
| +
|
| + return instance_.get();
|
| +}
|
| +
|
| +void IndexedDBKeyUtilityClient::Shutdown() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + AutoLock autolock(instantiation_lock_);
|
| +
|
| + if (!instance_.get())
|
| + return;
|
| +
|
| + instance_->utility_process_host_->EndBatchMode();
|
| + instance_->utility_process_host_ = NULL;
|
| + instance_->client_ = NULL;
|
| + instance_->state_ = STATE_SHUTDOWN;
|
| + instance_ = NULL;
|
| +}
|
| +
|
| IndexedDBKeyUtilityClient::IndexedDBKeyUtilityClient()
|
| : waitable_event_(false, false),
|
| state_(STATE_UNINITIALIZED),
|
| @@ -32,21 +58,16 @@ void IndexedDBKeyUtilityClient::StartUtilityProcess() {
|
| DCHECK(ret && state_ == STATE_INITIALIZED);
|
| }
|
|
|
| -void IndexedDBKeyUtilityClient::EndUtilityProcess() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
|
| - DCHECK(state_ == STATE_INITIALIZED);
|
| -
|
| - EndUtilityProcessInternal();
|
| - bool ret = waitable_event_.Wait();
|
| -
|
| - DCHECK(ret && state_ == STATE_SHUTDOWN);
|
| -}
|
| -
|
| void IndexedDBKeyUtilityClient::CreateIDBKeysFromSerializedValuesAndKeyPath(
|
| const std::vector<SerializedScriptValue>& values,
|
| const string16& key_path,
|
| std::vector<IndexedDBKey>* keys) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
|
| + if (state_ == STATE_SHUTDOWN) {
|
| + keys->clear();
|
| + return;
|
| + }
|
| +
|
| DCHECK(state_ == STATE_INITIALIZED);
|
|
|
| state_ = STATE_CREATING_KEYS;
|
| @@ -164,3 +185,6 @@ void IndexedDBKeyUtilityClient::Client::OnIDBKeysFromValuesAndKeyPathFailed(
|
| int id) {
|
| parent_->FinishCreatingKeys();
|
| }
|
| +
|
| +scoped_refptr<IndexedDBKeyUtilityClient> IndexedDBKeyUtilityClient::instance_;
|
| +base::Lock IndexedDBKeyUtilityClient::instantiation_lock_;
|
|
|