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

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: Move constants and fix loops 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..60adfc3fd6d362f8e63562350a5fd2d86546f51c 100644
--- a/remoting/host/setup/native_messaging_host.cc
+++ b/remoting/host/setup/native_messaging_host.cc
@@ -36,6 +36,20 @@ scoped_ptr<base::DictionaryValue> ConfigDictionaryFromMessage(
namespace remoting {
+const char NativeMessagingHost::kStateNotImplemented[] = "NOT_IMPLEMENTED";
Sergey Ulanov 2013/05/31 23:01:43 As I mentioned before you don't really need to def
Lambros 2013/06/03 21:28:44 Done.
+const char NativeMessagingHost::kStateNotInstalled[] = "NOT_INSTALLED";
+const char NativeMessagingHost::kStateInstalling[] = "INSTALLING";
+const char NativeMessagingHost::kStateStopped[] = "STOPPED";
+const char NativeMessagingHost::kStateStarting[] = "STARTING";
+const char NativeMessagingHost::kStateStarted[] = "STARTED";
+const char NativeMessagingHost::kStateStopping[] = "STOPPING";
+const char NativeMessagingHost::kStateUnknown[] = "UNKNOWN";
+
+const char NativeMessagingHost::kResultOk[] = "OK";
+const char NativeMessagingHost::kResultFailed[] = "FAILED";
+const char NativeMessagingHost::kResultCancelled[] = "CANCELLED";
+const char NativeMessagingHost::kResultFailedDirectory[] = "FAILED_DIRECTORY";
+
NativeMessagingHost::NativeMessagingHost(
scoped_ptr<DaemonController> daemon_controller,
base::PlatformFile input,
@@ -241,10 +255,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:
+ response->SetString("state", kStateNotImplemented);
+ break;
+ case DaemonController::STATE_NOT_INSTALLED:
+ response->SetString("state", kStateNotInstalled);
+ break;
+ case DaemonController::STATE_INSTALLING:
+ response->SetString("state", kStateInstalling);
+ break;
+ case DaemonController::STATE_STOPPED:
+ response->SetString("state", kStateStopped);
+ break;
+ case DaemonController::STATE_STARTING:
+ response->SetString("state", kStateStarting);
+ break;
+ case DaemonController::STATE_STARTED:
+ response->SetString("state", kStateStarted);
+ break;
+ case DaemonController::STATE_STOPPING:
+ response->SetString("state", kStateStopping);
+ break;
+ case DaemonController::STATE_UNKNOWN:
+ response->SetString("state", kStateUnknown);
+ break;
+ }
SendResponse(response.Pass());
return true;
}
@@ -283,9 +320,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", kResultOk);
+ break;
+ case DaemonController::RESULT_FAILED:
+ response->SetString("result", kResultFailed);
+ break;
+ case DaemonController::RESULT_CANCELLED:
+ response->SetString("result", kResultCancelled);
+ break;
+ case DaemonController::RESULT_FAILED_DIRECTORY:
+ response->SetString("result", kResultFailedDirectory);
+ break;
+ }
SendResponse(response.Pass());
}

Powered by Google App Engine
This is Rietveld 408576698