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

Unified Diff: chrome/browser/extensions/api/messaging/native_message_process_host.cc

Issue 642163002: Fix crash in NativeMessageProcessHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/messaging/native_message_process_host.cc
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
index bc3808a28c848b27bc6f74ae18a0bd968840bba6..6b61ff18c41cb632c406f218a192518d89fe9e83 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
@@ -42,7 +42,8 @@ NativeMessageProcessHost::NativeMessageProcessHost(
const std::string& source_extension_id,
const std::string& native_host_name,
scoped_ptr<NativeProcessLauncher> launcher)
- : source_extension_id_(source_extension_id),
+ : client_(NULL),
+ source_extension_id_(source_extension_id),
native_host_name_(native_host_name),
launcher_(launcher.Pass()),
closed_(false),
@@ -56,12 +57,6 @@ NativeMessageProcessHost::NativeMessageProcessHost(
task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO);
- // It's safe to use base::Unretained() here because NativeMessagePort always
- // deletes us on the IO thread.
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&NativeMessageProcessHost::LaunchHostProcess,
- base::Unretained(this)));
}
NativeMessageProcessHost::~NativeMessageProcessHost() {
@@ -174,7 +169,14 @@ void NativeMessageProcessHost::OnMessage(const std::string& json) {
void NativeMessageProcessHost::Start(Client* client) {
DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(!client_);
client_ = client;
+ // It's safe to use base::Unretained() here because NativeMessagePort always
+ // deletes us on the IO thread.
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&NativeMessageProcessHost::LaunchHostProcess,
+ base::Unretained(this)));
}
scoped_refptr<base::SingleThreadTaskRunner>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698