| Index: remoting/ios/facade/host_list_fetcher.cc
|
| diff --git a/remoting/ios/facade/host_list_fetcher.cc b/remoting/ios/facade/host_list_fetcher.cc
|
| index 9342399a8890682c74cbd7c59b9512b8c0f9832e..469cbf31b88d113ed85c61042a48d1507644ceca 100644
|
| --- a/remoting/ios/facade/host_list_fetcher.cc
|
| +++ b/remoting/ios/facade/host_list_fetcher.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "remoting/ios/facade/host_list_fetcher.h"
|
|
|
| +#include <algorithm>
|
| #include <thread>
|
|
|
| #include "base/bind.h"
|
| @@ -18,6 +19,27 @@
|
|
|
| namespace remoting {
|
|
|
| +namespace {
|
| +
|
| +// Returns true if |h1| should sort before |h2|.
|
| +bool compareHost(const HostInfo& h1, const HostInfo& h2) {
|
| + // Online hosts always sort before offline hosts.
|
| + if (h1.status != h2.status) {
|
| + return h1.status == HostStatus::kHostStatusOnline;
|
| + }
|
| +
|
| + // Sort by host name.
|
| + int name_compare = h1.host_name.compare(h2.host_name);
|
| + if (name_compare != 0) {
|
| + return name_compare < 0;
|
| + }
|
| +
|
| + // Sort by last update time if names are identical.
|
| + return h1.updated_time < h2.updated_time;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| HostListFetcher::HostListFetcher(
|
| const scoped_refptr<net::URLRequestContextGetter>&
|
| url_request_context_getter)
|
| @@ -105,6 +127,7 @@ void HostListFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
|
| if (!ProcessResponse(&hostlist)) {
|
| hostlist.clear();
|
| }
|
| + std::sort(hostlist.begin(), hostlist.end(), &compareHost);
|
| base::ResetAndReturn(&hostlist_callback_).Run(hostlist);
|
| }
|
|
|
|
|