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

Unified Diff: content/browser/in_process_webkit/indexed_db_key_utility_client.cc

Issue 9235052: Fix race condition in utility process clients (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to ToT Created 8 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: content/browser/in_process_webkit/indexed_db_key_utility_client.cc
diff --git a/content/browser/in_process_webkit/indexed_db_key_utility_client.cc b/content/browser/in_process_webkit/indexed_db_key_utility_client.cc
index 35bb59628dbae09d31050330b993102d52914070..4a7e8d4855f00bcff73e7ff3c2bb8f8621190cdf 100644
--- a/content/browser/in_process_webkit/indexed_db_key_utility_client.cc
+++ b/content/browser/in_process_webkit/indexed_db_key_utility_client.cc
@@ -100,7 +100,7 @@ class KeyUtilityClientImpl
content::SerializedScriptValue value_after_injection_;
// Used in the IO thread.
- UtilityProcessHost* utility_process_host_;
+ base::WeakPtr<UtilityProcessHost> utility_process_host_;
scoped_refptr<Client> client_;
DISALLOW_COPY_AND_ASSIGN(KeyUtilityClientImpl);
@@ -177,16 +177,17 @@ IndexedDBKeyUtilityClient::InjectIDBKeyIntoSerializedValue(
void KeyUtilityClientImpl::Shutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- utility_process_host_->EndBatchMode();
- utility_process_host_ = NULL;
+ if (utility_process_host_) {
+ utility_process_host_->EndBatchMode();
+ utility_process_host_.reset();
+ }
client_ = NULL;
state_ = STATE_SHUTDOWN;
}
KeyUtilityClientImpl::KeyUtilityClientImpl()
: waitable_event_(false, false),
- state_(STATE_UNINITIALIZED),
- utility_process_host_(NULL) {
+ state_(STATE_UNINITIALIZED) {
}
KeyUtilityClientImpl::~KeyUtilityClientImpl() {
@@ -274,8 +275,8 @@ void KeyUtilityClientImpl::StartUtilityProcessInternal() {
DCHECK(state_ == STATE_UNINITIALIZED);
client_ = new KeyUtilityClientImpl::Client(this);
- utility_process_host_ = new UtilityProcessHost(
- client_.get(), BrowserThread::IO);
+ utility_process_host_ = (new UtilityProcessHost(
+ client_.get(), BrowserThread::IO))->AsWeakPtr();
utility_process_host_->set_use_linux_zygote(true);
utility_process_host_->StartBatchMode();
state_ = STATE_INITIALIZED;
@@ -290,8 +291,10 @@ void KeyUtilityClientImpl::EndUtilityProcessInternal() {
return;
}
- utility_process_host_->EndBatchMode();
- utility_process_host_ = NULL;
+ if (utility_process_host_) {
+ utility_process_host_->EndBatchMode();
+ utility_process_host_.reset();
+ }
client_ = NULL;
state_ = STATE_SHUTDOWN;
waitable_event_.Signal();
@@ -310,8 +313,10 @@ void KeyUtilityClientImpl::CallStartIDBKeyFromValueAndKeyPathFromIOThread(
}
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- utility_process_host_->Send(new UtilityMsg_IDBKeysFromValuesAndKeyPath(
- 0, values, key_path));
+ if (utility_process_host_) {
+ utility_process_host_->Send(new UtilityMsg_IDBKeysFromValuesAndKeyPath(
+ 0, values, key_path));
+ }
}
void KeyUtilityClientImpl::CallStartInjectIDBKeyFromIOThread(
@@ -327,8 +332,9 @@ void KeyUtilityClientImpl::CallStartInjectIDBKeyFromIOThread(
}
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- utility_process_host_->Send(new UtilityMsg_InjectIDBKey(
- key, value, key_path));
+ if (utility_process_host_)
+ utility_process_host_->Send(new UtilityMsg_InjectIDBKey(
+ key, value, key_path));
}
void KeyUtilityClientImpl::SetKeys(const std::vector<IndexedDBKey>& keys) {
@@ -361,6 +367,7 @@ KeyUtilityClientImpl::Client::Client(KeyUtilityClientImpl* parent)
void KeyUtilityClientImpl::Client::OnProcessCrashed(int exit_code) {
if (parent_->state_ == STATE_CREATING_KEYS)
parent_->FinishCreatingKeys();
+ parent_->Shutdown();
}
bool KeyUtilityClientImpl::Client::OnMessageReceived(
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/indexed_db/idbbindingutilities_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698