| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/client/ios/facade/host_list_fetcher.h" | 5 #include "remoting/client/ios/facade/host_list_fetcher.h" |
| 6 | 6 |
| 7 #include <thread> | 7 #include <thread> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 const base::ListValue* hosts = nullptr; | 81 const base::ListValue* hosts = nullptr; |
| 82 if (!data->GetList("items", &hosts)) { | 82 if (!data->GetList("items", &hosts)) { |
| 83 LOG(ERROR) << "Failed to find hosts in Hostlist response data"; | 83 LOG(ERROR) << "Failed to find hosts in Hostlist response data"; |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Any host_info with malformed data will not be added to the hostlist. | 87 // Any host_info with malformed data will not be added to the hostlist. |
| 88 base::DictionaryValue* host_dict; | 88 const base::DictionaryValue* host_dict; |
| 89 for (const auto& host_info : *hosts) { | 89 for (const auto& host_info : *hosts) { |
| 90 remoting::HostInfo host; | 90 remoting::HostInfo host; |
| 91 if (host_info->GetAsDictionary(&host_dict) && | 91 if (host_info.GetAsDictionary(&host_dict) && |
| 92 host.ParseHostInfo(*host_dict)) { | 92 host.ParseHostInfo(*host_dict)) { |
| 93 hostlist->push_back(host); | 93 hostlist->push_back(host); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void HostListFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 99 void HostListFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
| 100 DCHECK(source); | 100 DCHECK(source); |
| 101 | 101 |
| 102 std::vector<HostInfo> hostlist; | 102 std::vector<HostInfo> hostlist; |
| 103 if (!ProcessResponse(&hostlist)) { | 103 if (!ProcessResponse(&hostlist)) { |
| 104 hostlist.clear(); | 104 hostlist.clear(); |
| 105 } | 105 } |
| 106 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); | 106 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace remoting | 109 } // namespace remoting |
| OLD | NEW |