| 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 11 matching lines...) Expand all Loading... |
| 22 const scoped_refptr<net::URLRequestContextGetter>& | 22 const scoped_refptr<net::URLRequestContextGetter>& |
| 23 url_request_context_getter) | 23 url_request_context_getter) |
| 24 : url_request_context_getter_(url_request_context_getter) {} | 24 : url_request_context_getter_(url_request_context_getter) {} |
| 25 | 25 |
| 26 HostListFetcher::~HostListFetcher() {} | 26 HostListFetcher::~HostListFetcher() {} |
| 27 | 27 |
| 28 // TODO(nicholss): This was written assuming only one request at a time. Fix | 28 // TODO(nicholss): This was written assuming only one request at a time. Fix |
| 29 // that. For the moment it will work to make progress in the app. | 29 // that. For the moment it will work to make progress in the app. |
| 30 void HostListFetcher::RetrieveHostlist(const std::string& access_token, | 30 void HostListFetcher::RetrieveHostlist(const std::string& access_token, |
| 31 const HostlistCallback& callback) { | 31 const HostlistCallback& callback) { |
| 32 // TODO(nicholss): There is a bug here if two host list fetches are happening |
| 33 // at the same time there will be a dcheck thrown. Fix this for release. |
| 32 DCHECK(!access_token.empty()); | 34 DCHECK(!access_token.empty()); |
| 33 DCHECK(callback); | 35 DCHECK(callback); |
| 34 DCHECK(!hostlist_callback_); | 36 DCHECK(!hostlist_callback_); |
| 35 | 37 |
| 36 hostlist_callback_ = callback; | 38 hostlist_callback_ = callback; |
| 37 | 39 |
| 38 request_ = net::URLFetcher::Create(GURL(kHostListProdRequestUrl), | 40 request_ = net::URLFetcher::Create(GURL(kHostListProdRequestUrl), |
| 39 net::URLFetcher::GET, this); | 41 net::URLFetcher::GET, this); |
| 40 request_->SetRequestContext(url_request_context_getter_.get()); | 42 request_->SetRequestContext(url_request_context_getter_.get()); |
| 41 request_->AddExtraRequestHeader("Authorization: OAuth " + access_token); | 43 request_->AddExtraRequestHeader("Authorization: OAuth " + access_token); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DCHECK(source); | 102 DCHECK(source); |
| 101 | 103 |
| 102 std::vector<HostInfo> hostlist; | 104 std::vector<HostInfo> hostlist; |
| 103 if (!ProcessResponse(&hostlist)) { | 105 if (!ProcessResponse(&hostlist)) { |
| 104 hostlist.clear(); | 106 hostlist.clear(); |
| 105 } | 107 } |
| 106 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); | 108 base::ResetAndReturn(&hostlist_callback_).Run(hostlist); |
| 107 } | 109 } |
| 108 | 110 |
| 109 } // namespace remoting | 111 } // namespace remoting |
| OLD | NEW |