OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/test/host_list_fetcher.h" | 5 #include "remoting/test/host_list_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 std::string response_string; | 56 std::string response_string; |
57 if (!request_->GetResponseAsString(&response_string)) { | 57 if (!request_->GetResponseAsString(&response_string)) { |
58 LOG(ERROR) << "Failed to retrieve Hostlist response data"; | 58 LOG(ERROR) << "Failed to retrieve Hostlist response data"; |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 std::unique_ptr<base::Value> response_value( | 62 std::unique_ptr<base::Value> response_value( |
63 base::JSONReader::Read(response_string)); | 63 base::JSONReader::Read(response_string)); |
64 if (!response_value || | 64 if (!response_value || |
65 !response_value->IsType(base::Value::TYPE_DICTIONARY)) { | 65 !response_value->IsType(base::Value::Type::DICTIONARY)) { |
66 LOG(ERROR) << "Failed to parse response string to JSON"; | 66 LOG(ERROR) << "Failed to parse response string to JSON"; |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 const base::DictionaryValue* response; | 70 const base::DictionaryValue* response; |
71 if (!response_value->GetAsDictionary(&response)) { | 71 if (!response_value->GetAsDictionary(&response)) { |
72 LOG(ERROR) << "Failed to convert parsed JSON to a dictionary object"; | 72 LOG(ERROR) << "Failed to convert parsed JSON to a dictionary object"; |
73 return false; | 73 return false; |
74 } | 74 } |
75 | 75 |
(...skipping 29 matching lines...) Expand all Loading... |
105 std::vector<HostInfo> hostlist; | 105 std::vector<HostInfo> hostlist; |
106 | 106 |
107 if (!ProcessResponse(&hostlist)) { | 107 if (!ProcessResponse(&hostlist)) { |
108 hostlist.clear(); | 108 hostlist.clear(); |
109 } | 109 } |
110 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); | 110 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); |
111 } | 111 } |
112 | 112 |
113 } // namespace test | 113 } // namespace test |
114 } // namespace remoting | 114 } // namespace remoting |
OLD | NEW |