Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/test/chromoting_host_info.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace remoting { | |
| 10 namespace test { | |
| 11 | |
| 12 ChromotingHostInfo::ChromotingHostInfo() { | |
| 13 } | |
| 14 | |
| 15 ChromotingHostInfo::~ChromotingHostInfo() { | |
| 16 } | |
| 17 | |
| 18 bool ChromotingHostInfo::ParseHostInfo(const base::DictionaryValue& host_info) { | |
| 19 const base::ListValue* list_value = nullptr; | |
| 20 | |
| 21 // 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.
| |
| 22 if (host_info.GetList("tokenUrlPatterns", &list_value)) { | |
| 23 int size = list_value->GetSize(); | |
| 24 if (size > 0) { | |
| 25 std::string token_url_pattern; | |
| 26 for (int i = 0; i < size; ++i) { | |
| 27 list_value->GetString(i, &token_url_pattern); | |
| 28 if (!token_url_pattern.empty()) { | |
| 29 token_url_patterns.push_back(token_url_pattern); | |
| 30 } | |
| 31 } | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 std::string response_status; | |
| 36 host_info.GetString("status", &response_status); | |
| 37 if (response_status == "ONLINE") { | |
| 38 status = kChromotingHostStatusOnline; | |
| 39 } else if (response_status == "OFFLINE") { | |
| 40 status = kChromotingHostStatusOffline; | |
| 41 } else { | |
| 42 LOG(ERROR) << "Response Status is " << response_status; | |
| 43 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.
| |
| 44 } | |
| 45 | |
| 46 if (!host_info.GetString("hostId", &host_id)) { | |
| 47 LOG(ERROR) << "hostId was not found in host_info"; | |
| 48 return false; | |
| 49 } | |
|
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.
| |
| 50 if (!host_info.GetString("hostName", &host_name)) { | |
| 51 LOG(ERROR) << "hostName was not found in host_info"; | |
| 52 return false; | |
| 53 } | |
| 54 if (!host_info.GetString("publicKey", &public_key)) { | |
| 55 LOG(ERROR) << "publicKey was not found for " << host_name; | |
| 56 return false; | |
| 57 } | |
| 58 // If the host entry was created but the host was never online, then the jid | |
| 59 // is never set. | |
| 60 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.
| |
| 61 LOG(INFO) << "jabberId was not found for " << host_name; | |
| 62 } | |
| 63 // If the host was never running or if it was started and it's still running, | |
| 64 // then the hostOfflineReason will not be set. It is only set after the host | |
| 65 // goes offline. | |
| 66 if (!host_info.GetString("hostOfflineReason", &offline_reason)) { | |
| 67 LOG(INFO) << "hostOfflineReason was not found for " << host_name; | |
| 68 } | |
| 69 | |
| 70 return true; | |
| 71 } | |
| 72 | |
| 73 } // namespace test | |
| 74 } // namespace remoting | |
| OLD | NEW |