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

Unified Diff: remoting/test/chromoting_host_info.cc

Issue 1212333011: Retrieved Hostlist information from Directory service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up fetcher code and added more unit test coverage. Created 5 years, 5 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/test/chromoting_host_info.cc
diff --git a/remoting/test/chromoting_host_info.cc b/remoting/test/chromoting_host_info.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f981c495a3d29e4353f063badbde4d2cfa936de
--- /dev/null
+++ b/remoting/test/chromoting_host_info.cc
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/test/chromoting_host_info.h"
+
+#include "base/logging.h"
+
+namespace remoting {
+namespace test {
+
+ChromotingHostInfo::ChromotingHostInfo() {
+}
+
+ChromotingHostInfo::~ChromotingHostInfo() {
+}
+
+bool ChromotingHostInfo::ParseHostInfo(const base::DictionaryValue& host_info) {
+ const base::ListValue* list_value = nullptr;
+
+ // Add TokenUrlPatterns to ChromotingHostInfo
joedow 2015/07/08 17:19:07 comments need to end in periods, please add one he
tonychun 2015/07/08 22:38:15 Done.
+ if (host_info.GetList("tokenUrlPatterns", &list_value)) {
+ int size = list_value->GetSize();
+ if (size > 0) {
+ std::string token_url_pattern;
+ for (int i = 0; i < size; ++i) {
+ list_value->GetString(i, &token_url_pattern);
+ if (!token_url_pattern.empty()) {
+ token_url_patterns.push_back(token_url_pattern);
+ }
+ }
+ }
+ }
+
+ std::string response_status;
+ host_info.GetString("status", &response_status);
+ if (response_status == "ONLINE") {
+ status = kChromotingHostStatusOnline;
+ } else if (response_status == "OFFLINE") {
+ status = kChromotingHostStatusOffline;
+ } else {
+ LOG(ERROR) << "Response Status is " << response_status;
+ NOTREACHED();
Sergey Ulanov 2015/07/08 19:57:33 return false? NOTREACHED is equivalent to DCHECK(f
tonychun 2015/07/08 22:38:15 Done.
+ }
+
+ if (!host_info.GetString("hostId", &host_id)) {
+ LOG(ERROR) << "hostId was not found in host_info";
+ return false;
+ }
joedow 2015/07/08 17:19:07 nit: I'd prefer to see newlines in between each ch
tonychun 2015/07/08 22:38:15 Done.
+ if (!host_info.GetString("hostName", &host_name)) {
+ LOG(ERROR) << "hostName was not found in host_info";
+ return false;
+ }
+ if (!host_info.GetString("publicKey", &public_key)) {
+ LOG(ERROR) << "publicKey was not found for " << host_name;
+ return false;
+ }
+ // If the host entry was created but the host was never online, then the jid
+ // is never set.
+ if (!host_info.GetString("jabberId", &host_jid)) {
joedow 2015/07/08 17:19:07 Should you check to see if online is set here? It
tonychun 2015/07/08 22:38:15 Done.
+ LOG(INFO) << "jabberId was not found for " << host_name;
+ }
+ // If the host was never running or if it was started and it's still running,
+ // then the hostOfflineReason will not be set. It is only set after the host
+ // goes offline.
+ if (!host_info.GetString("hostOfflineReason", &offline_reason)) {
+ LOG(INFO) << "hostOfflineReason was not found for " << host_name;
+ }
+
+ return true;
+}
+
+} // namespace test
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698