Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: remoting/ios/facade/host_list_fetcher.cc

Issue 2957943002: [CRD iOS] Add the host setup instruction page (Closed)
Patch Set: Resolve Feedback Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/ios/app/remoting_view_controller.mm ('k') | remoting/ios/facade/remoting_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ios/facade/host_list_fetcher.h" 5 #include "remoting/ios/facade/host_list_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <thread> 8 #include <thread>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 const base::DictionaryValue* data = nullptr; 99 const base::DictionaryValue* data = nullptr;
100 if (!response->GetDictionary("data", &data)) { 100 if (!response->GetDictionary("data", &data)) {
101 LOG(ERROR) << "Hostlist response data is empty"; 101 LOG(ERROR) << "Hostlist response data is empty";
102 return false; 102 return false;
103 } 103 }
104 104
105 const base::ListValue* hosts = nullptr; 105 const base::ListValue* hosts = nullptr;
106 if (!data->GetList("items", &hosts)) { 106 if (!data->GetList("items", &hosts)) {
107 LOG(ERROR) << "Failed to find hosts in Hostlist response data"; 107 // This will happen if the user has no host.
108 return false; 108 return true;
109 } 109 }
110 110
111 // Any host_info with malformed data will not be added to the hostlist. 111 // Any host_info with malformed data will not be added to the hostlist.
112 const base::DictionaryValue* host_dict; 112 const base::DictionaryValue* host_dict;
113 for (const auto& host_info : *hosts) { 113 for (const auto& host_info : *hosts) {
114 remoting::HostInfo host; 114 remoting::HostInfo host;
115 if (host_info.GetAsDictionary(&host_dict) && 115 if (host_info.GetAsDictionary(&host_dict) &&
116 host.ParseHostInfo(*host_dict)) { 116 host.ParseHostInfo(*host_dict)) {
117 hostlist->push_back(host); 117 hostlist->push_back(host);
118 } 118 }
119 } 119 }
120 return true; 120 return true;
121 } 121 }
122 122
123 void HostListFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 123 void HostListFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
124 DCHECK(source); 124 DCHECK(source);
125 125
126 std::vector<HostInfo> hostlist; 126 std::vector<HostInfo> hostlist;
127 if (!ProcessResponse(&hostlist)) { 127 if (!ProcessResponse(&hostlist)) {
128 hostlist.clear(); 128 hostlist.clear();
129 } 129 }
130 std::sort(hostlist.begin(), hostlist.end(), &compareHost); 130 std::sort(hostlist.begin(), hostlist.end(), &compareHost);
131 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); 131 base::ResetAndReturn(&hostlist_callback_).Run(hostlist);
132 } 132 }
133 133
134 } // namespace remoting 134 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/ios/app/remoting_view_controller.mm ('k') | remoting/ios/facade/remoting_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698