| 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/remote_host_info_fetcher.h" | 5 #include "remoting/test/remote_host_info_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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 LOG(ERROR) << "Unrecognized service type: " << service_environment; | 62 LOG(ERROR) << "Unrecognized service type: " << service_environment; |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 remote_host_info_callback_ = callback; | 66 remote_host_info_callback_ = callback; |
| 67 | 67 |
| 68 request_context_getter_ = new remoting::URLRequestContextGetter( | 68 request_context_getter_ = new remoting::URLRequestContextGetter( |
| 69 base::ThreadTaskRunnerHandle::Get(), // network_runner | 69 base::ThreadTaskRunnerHandle::Get(), // network_runner |
| 70 base::ThreadTaskRunnerHandle::Get()); // file_runner | 70 base::ThreadTaskRunnerHandle::Get()); // file_runner |
| 71 | 71 |
| 72 request_.reset( | 72 request_ = |
| 73 net::URLFetcher::Create(GURL(service_url), net::URLFetcher::POST, this)); | 73 net::URLFetcher::Create(GURL(service_url), net::URLFetcher::POST, this); |
| 74 request_->SetRequestContext(request_context_getter_.get()); | 74 request_->SetRequestContext(request_context_getter_.get()); |
| 75 request_->AddExtraRequestHeader("Authorization: OAuth " + access_token); | 75 request_->AddExtraRequestHeader("Authorization: OAuth " + access_token); |
| 76 request_->AddExtraRequestHeader(kRequestTestOrigin); | 76 request_->AddExtraRequestHeader(kRequestTestOrigin); |
| 77 request_->SetUploadData("application/json; charset=UTF-8", "{}"); | 77 request_->SetUploadData("application/json; charset=UTF-8", "{}"); |
| 78 request_->Start(); | 78 request_->Start(); |
| 79 | 79 |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 83 void RemoteHostInfoFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 response->GetString("authorizationCode", | 128 response->GetString("authorizationCode", |
| 129 &remote_host_info.authorization_code); | 129 &remote_host_info.authorization_code); |
| 130 response->GetString("sharedSecret", &remote_host_info.shared_secret); | 130 response->GetString("sharedSecret", &remote_host_info.shared_secret); |
| 131 } | 131 } |
| 132 | 132 |
| 133 base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info); | 133 base::ResetAndReturn(&remote_host_info_callback_).Run(remote_host_info); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace test | 136 } // namespace test |
| 137 } // namespace remoting | 137 } // namespace remoting |
| OLD | NEW |