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

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

Issue 16236008: Send enums as strings between Chromoting Native Messaging host and web-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 28a0b1063734e168633e529b3cc682fb8a39d211..3394cc3f090767f1c78330c0e2b452e2b21f1372 100644
--- a/remoting/host/setup/native_messaging_host.cc
+++ b/remoting/host/setup/native_messaging_host.cc
@@ -241,10 +241,33 @@ bool NativeMessagingHost::ProcessStopDaemon(
bool NativeMessagingHost::ProcessGetDaemonState(
const base::DictionaryValue& message,
scoped_ptr<base::DictionaryValue> response) {
- // TODO(lambroslambrou): Send the state as a string instead of an integer,
- // and update the web-app accordingly.
DaemonController::State state = daemon_controller_->GetState();
- response->SetInteger("state", state);
+ switch (state) {
+ case DaemonController::STATE_NOT_IMPLEMENTED:
Sergey Ulanov 2013/05/30 23:14:52 Take a look at "remoting/protocol/name_value_map.h
Lambros 2013/05/31 01:32:56 Not worth moving, I'm only using value->name direc
+ response->SetString("state", DaemonController::kStateNotImplemented);
+ break;
+ case DaemonController::STATE_NOT_INSTALLED:
+ response->SetString("state", DaemonController::kStateNotInstalled);
+ break;
+ case DaemonController::STATE_INSTALLING:
+ response->SetString("state", DaemonController::kStateInstalling);
+ break;
+ case DaemonController::STATE_STOPPED:
+ response->SetString("state", DaemonController::kStateStopped);
+ break;
+ case DaemonController::STATE_STARTING:
+ response->SetString("state", DaemonController::kStateStarting);
+ break;
+ case DaemonController::STATE_STARTED:
+ response->SetString("state", DaemonController::kStateStarted);
+ break;
+ case DaemonController::STATE_STOPPING:
+ response->SetString("state", DaemonController::kStateStopping);
+ break;
+ case DaemonController::STATE_UNKNOWN:
+ response->SetString("state", DaemonController::kStateUnknown);
+ break;
+ }
SendResponse(response.Pass());
return true;
}
@@ -283,9 +306,20 @@ void NativeMessagingHost::SendUsageStatsConsentResponse(
void NativeMessagingHost::SendAsyncResult(
scoped_ptr<base::DictionaryValue> response,
DaemonController::AsyncResult result) {
- // TODO(lambroslambrou): Send the result as a string instead of an integer,
- // and update the web-app accordingly. See http://crbug.com/232135.
- response->SetInteger("result", result);
+ switch (result) {
+ case DaemonController::RESULT_OK:
+ response->SetString("result", DaemonController::kResultOk);
+ break;
+ case DaemonController::RESULT_FAILED:
+ response->SetString("result", DaemonController::kResultFailed);
+ break;
+ case DaemonController::RESULT_CANCELLED:
+ response->SetString("result", DaemonController::kResultCancelled);
+ break;
+ case DaemonController::RESULT_FAILED_DIRECTORY:
+ response->SetString("result", DaemonController::kResultFailedDirectory);
+ break;
+ }
SendResponse(response.Pass());
}

Powered by Google App Engine
This is Rietveld 408576698