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 { | |
10 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.
| |
11 const char kOfflineStatusResponse[] = "OFFLINE"; | |
12 } | |
13 | |
14 namespace remoting { | |
15 namespace test { | |
16 | |
17 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.
| |
18 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.
| |
19 item.GetList("tokenUrlPatterns", &listValue); | |
20 | |
21 // Add TokenUrlPatterns to ChromotingHostInfo | |
22 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.
| |
23 int size = listValue->GetSize(); | |
24 if (size > 0) { | |
25 std::string tokenUrlPattern; | |
joedow
2015/07/06 22:19:12
token_url_pattern
tonychun
2015/07/08 03:12:13
Done.
| |
26 for (int i = 0; i < size; ++i) { | |
27 listValue->GetString(i, &tokenUrlPattern); | |
28 if (!tokenUrlPattern.empty()) { | |
29 tokenUrlPatterns.push_back(tokenUrlPattern); | |
30 } | |
31 } | |
32 } | |
33 } | |
34 | |
35 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.
| |
36 item.GetString("jabberId", &host_jid); | |
37 item.GetString("hostName", &host_name); | |
38 item.GetString("hostOfflineReason", &offline_reason); | |
39 item.GetString("publicKey", &public_key); | |
40 | |
41 std::string response_status; | |
42 item.GetString("status", &response_status); | |
43 if (response_status == kOnlineStatusResponse) { | |
44 status = kChromotingHostStatusOnline; | |
45 } else { | |
46 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.
| |
47 status = kChromotingHostStatusOffline; | |
48 } | |
49 } | |
50 | |
51 ChromotingHostInfo::~ChromotingHostInfo() { | |
52 } | |
53 | |
54 } // namespace test | |
55 } // namespace remoting | |
OLD | NEW |