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/host_info.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace remoting { | |
10 namespace test { | |
11 | |
12 HostInfo::HostInfo() { | |
13 } | |
14 | |
15 HostInfo::~HostInfo() { | |
16 } | |
17 | |
18 bool HostInfo::ParseHostInfo(const base::DictionaryValue& host_info) { | |
19 const base::ListValue* list_value = nullptr; | |
20 | |
21 // Add TokenUrlPatterns to HostInfo. | |
22 if (host_info.GetList("tokenUrlPatterns", &list_value)) { | |
23 int size = list_value->GetSize(); | |
24 if (size > 0) { | |
Sergey Ulanov
2015/07/09 01:25:29
if (!list_value->empty())
tonychun
2015/07/09 03:02:46
Done.
| |
25 std::string token_url_pattern; | |
26 for (int i = 0; i < size; ++i) { | |
Sergey Ulanov
2015/07/09 01:25:29
iterate the list using iterator:
for (net::Value
tonychun
2015/07/09 03:02:46
Done.
| |
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 = kHostStatusOnline; | |
39 } else if (response_status == "OFFLINE") { | |
40 status = kHostStatusOffline; | |
41 } else { | |
42 LOG(ERROR) << "Response Status is " << response_status; | |
43 return false; | |
44 } | |
45 | |
46 if (!host_info.GetString("hostId", &host_id)) { | |
47 LOG(ERROR) << "hostId was not found in host_info"; | |
48 return false; | |
49 } | |
50 | |
51 if (!host_info.GetString("hostName", &host_name)) { | |
52 LOG(ERROR) << "hostName was not found in host_info"; | |
53 return false; | |
54 } | |
55 | |
56 if (!host_info.GetString("publicKey", &public_key)) { | |
57 LOG(ERROR) << "publicKey was not found for " << host_name; | |
58 return false; | |
59 } | |
60 | |
61 // If the host entry was created but the host was never online, then the jid | |
62 // is never set. | |
63 if (!host_info.GetString("jabberId", &host_jid)) { | |
64 LOG(INFO) << "jabberId was not found for " << host_name; | |
Sergey Ulanov
2015/07/09 20:15:14
Don't really need this message. JID is useless if
tonychun
2015/07/09 20:32:34
Done.
| |
65 if (status == kHostStatusOnline) { | |
66 LOG(ERROR) << host_name << " is online but is missing a jabberId"; | |
67 return false; | |
68 } | |
69 } | |
70 | |
71 // If the host was never running or if it was started and it's still running, | |
72 // then the hostOfflineReason will not be set. It is only set after the host | |
73 // goes offline. | |
74 if (!host_info.GetString("hostOfflineReason", &offline_reason)) { | |
75 LOG(INFO) << "hostOfflineReason was not found for " << host_name; | |
Sergey Ulanov
2015/07/09 20:15:14
I don't think you really need this - there will be
tonychun
2015/07/09 20:32:34
Done.
| |
76 } | |
77 | |
78 return true; | |
79 } | |
80 | |
81 } // namespace test | |
82 } // namespace remoting | |
OLD | NEW |