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

Unified Diff: remoting/host/setup/native_messaging_host.cc

Issue 14979008: unittests for Chromoting native messaging host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some clang-format fixes Created 7 years, 7 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: 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;
}

Powered by Google App Engine
This is Rietveld 408576698