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

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: Added unittests and cleaned up format of C++ code. 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..d9098242fb3dd52003df57bc752aa1e4b5a5acd3
--- /dev/null
+++ b/remoting/test/chromoting_host_info.cc
@@ -0,0 +1,55 @@
+// 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 {
+const char kOnlineStatusResponse[] = "ONLINE";
Sergey Ulanov 2015/07/07 00:01:45 In general it's not useful to declare consts for s
tonychun 2015/07/08 03:12:12 Done.
tonychun 2015/07/08 03:12:13 Done.
+const char kOfflineStatusResponse[] = "OFFLINE";
+}
+
+namespace remoting {
+namespace test {
+
+ChromotingHostInfo::ChromotingHostInfo(const base::DictionaryValue& item) {
joedow 2015/07/06 22:19:12 instead of item, can you call it host_info or some
tonychun 2015/07/08 03:12:13 Done.
+ const base::ListValue* listValue = nullptr;
joedow 2015/07/06 22:19:12 listValue should be list_value. This codebase doe
tonychun 2015/07/08 03:12:13 Done.
+ item.GetList("tokenUrlPatterns", &listValue);
+
+ // Add TokenUrlPatterns to ChromotingHostInfo
+ if (listValue != nullptr) {
joedow 2015/07/06 22:19:12 This is cleaner as 'if (listValue) {'
Sergey Ulanov 2015/07/07 00:01:45 DictionaryValue::GetList() returns bool, so this c
tonychun 2015/07/08 03:12:12 Done.
tonychun 2015/07/08 03:12:12 Done.
+ int size = listValue->GetSize();
+ if (size > 0) {
+ std::string tokenUrlPattern;
joedow 2015/07/06 22:19:12 token_url_pattern
tonychun 2015/07/08 03:12:13 Done.
+ for (int i = 0; i < size; ++i) {
+ listValue->GetString(i, &tokenUrlPattern);
+ if (!tokenUrlPattern.empty()) {
+ tokenUrlPatterns.push_back(tokenUrlPattern);
+ }
+ }
+ }
+ }
+
+ item.GetString("hostId", &host_id);
Sergey Ulanov 2015/07/07 00:01:45 Need to handle the case when any of the fields is
tonychun 2015/07/08 03:12:13 Done.
+ item.GetString("jabberId", &host_jid);
+ item.GetString("hostName", &host_name);
+ item.GetString("hostOfflineReason", &offline_reason);
+ item.GetString("publicKey", &public_key);
+
+ std::string response_status;
+ item.GetString("status", &response_status);
+ if (response_status == kOnlineStatusResponse) {
+ status = kChromotingHostStatusOnline;
+ } else {
+ DCHECK(response_status == kOfflineStatusResponse);
joedow 2015/07/06 22:19:12 A switch might be cleaner here (with a default cas
Sergey Ulanov 2015/07/07 00:01:45 You shouldn't DCHECK on server response (or on any
tonychun 2015/07/08 03:12:13 I put in NOTREACHED().
tonychun 2015/07/08 03:12:13 Done.
+ status = kChromotingHostStatusOffline;
+ }
+}
+
+ChromotingHostInfo::~ChromotingHostInfo() {
+}
+
+} // namespace test
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698