Index: remoting/host/setup/native_messaging_host.cc |
diff --git a/remoting/host/setup/native_messaging_host.cc b/remoting/host/setup/native_messaging_host.cc |
index e410f32edf3f6a23588e0b30540240f26150f773..8eca324d7d4270d06867f1ffafcf4af1061edbf7 100644 |
--- a/remoting/host/setup/native_messaging_host.cc |
+++ b/remoting/host/setup/native_messaging_host.cc |
@@ -61,8 +61,7 @@ NativeMessagingHost::NativeMessagingHost( |
weak_ptr_ = weak_factory_.GetWeakPtr(); |
} |
-NativeMessagingHost::~NativeMessagingHost() { |
-} |
+NativeMessagingHost::~NativeMessagingHost() {} |
void NativeMessagingHost::Start() { |
DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
@@ -80,12 +79,23 @@ void NativeMessagingHost::Shutdown() { |
} |
} |
+void NativeMessagingHost::SetDaemonControllerForTest( |
+ scoped_ptr<DaemonController> daemon_controller) { |
+ daemon_controller_ = daemon_controller.Pass(); |
+} |
+ |
void NativeMessagingHost::ProcessMessage(scoped_ptr<base::Value> message) { |
DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
+ |
+ // Don't process any more messages if Shutdown() has been called. |
+ if (quit_closure_.is_null()) |
+ return; |
+ |
const base::DictionaryValue* message_dict; |
if (!message->GetAsDictionary(&message_dict)) { |
LOG(ERROR) << "Expected DictionaryValue"; |
Shutdown(); |
+ return; |
} |
scoped_ptr<base::DictionaryValue> response_dict(new base::DictionaryValue()); |
@@ -198,18 +208,18 @@ bool NativeMessagingHost::ProcessUpdateDaemonConfig( |
bool NativeMessagingHost::ProcessGetDaemonConfig( |
const base::DictionaryValue& message, |
scoped_ptr<base::DictionaryValue> response) { |
- daemon_controller_->GetConfig(base::Bind( |
- &NativeMessagingHost::SendConfigResponse, |
- base::Unretained(this), base::Passed(&response))); |
+ daemon_controller_->GetConfig( |
+ base::Bind(&NativeMessagingHost::SendConfigResponse, |
+ base::Unretained(this), base::Passed(&response))); |
return true; |
} |
bool NativeMessagingHost::ProcessGetUsageStatsConsent( |
const base::DictionaryValue& message, |
scoped_ptr<base::DictionaryValue> response) { |
- daemon_controller_->GetUsageStatsConsent(base::Bind( |
- &NativeMessagingHost::SendUsageStatsConsentResponse, |
- base::Unretained(this), base::Passed(&response))); |
+ daemon_controller_->GetUsageStatsConsent( |
+ base::Bind(&NativeMessagingHost::SendUsageStatsConsentResponse, |
+ base::Unretained(this), base::Passed(&response))); |
return true; |
} |
@@ -237,9 +247,9 @@ bool NativeMessagingHost::ProcessStartDaemon( |
bool NativeMessagingHost::ProcessStopDaemon( |
const base::DictionaryValue& message, |
scoped_ptr<base::DictionaryValue> response) { |
- daemon_controller_->Stop(base::Bind( |
- &NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
- base::Passed(&response))); |
+ daemon_controller_->Stop( |
+ base::Bind(&NativeMessagingHost::SendAsyncResult, base::Unretained(this), |
+ base::Passed(&response))); |
return true; |
} |
@@ -257,9 +267,9 @@ bool NativeMessagingHost::ProcessGetDaemonState( |
void NativeMessagingHost::SendResponse( |
scoped_ptr<base::DictionaryValue> response) { |
if (!caller_task_runner_->BelongsToCurrentThread()) { |
- caller_task_runner_->PostTask(FROM_HERE, base::Bind( |
- &NativeMessagingHost::SendResponse, weak_ptr_, |
- base::Passed(&response))); |
+ caller_task_runner_->PostTask( |
+ FROM_HERE, base::Bind(&NativeMessagingHost::SendResponse, weak_ptr_, |
+ base::Passed(&response))); |
return; |
} |