OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // A simple command-line app that registers and starts a host. | 5 // A simple command-line app that registers and starts a host. |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 base::Thread file_thread("file thread"); | 183 base::Thread file_thread("file thread"); |
184 file_thread.StartWithOptions(io_thread_options); | 184 file_thread.StartWithOptions(io_thread_options); |
185 | 185 |
186 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter( | 186 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter( |
187 new remoting::URLRequestContextGetter(io_thread.task_runner(), | 187 new remoting::URLRequestContextGetter(io_thread.task_runner(), |
188 file_thread.task_runner())); | 188 file_thread.task_runner())); |
189 | 189 |
190 net::URLFetcher::SetIgnoreCertificateRequests(true); | 190 net::URLFetcher::SetIgnoreCertificateRequests(true); |
191 | 191 |
192 // Start the host. | 192 // Start the host. |
193 scoped_ptr<HostStarter> host_starter(HostStarter::Create( | 193 std::unique_ptr<HostStarter> host_starter(HostStarter::Create( |
194 remoting::ServiceUrls::GetInstance()->directory_hosts_url(), | 194 remoting::ServiceUrls::GetInstance()->directory_hosts_url(), |
195 url_request_context_getter.get())); | 195 url_request_context_getter.get())); |
196 if (redirect_url.empty()) { | 196 if (redirect_url.empty()) { |
197 redirect_url = remoting::GetDefaultOauthRedirectUrl(); | 197 redirect_url = remoting::GetDefaultOauthRedirectUrl(); |
198 } | 198 } |
199 host_starter->StartHost(host_name, host_pin, true, auth_code, redirect_url, | 199 host_starter->StartHost(host_name, host_pin, true, auth_code, redirect_url, |
200 base::Bind(&OnDone)); | 200 base::Bind(&OnDone)); |
201 | 201 |
202 // Run the message loop until the StartHost completion callback. | 202 // Run the message loop until the StartHost completion callback. |
203 base::RunLoop run_loop; | 203 base::RunLoop run_loop; |
204 run_loop.Run(); | 204 run_loop.Run(); |
205 | 205 |
206 g_message_loop = nullptr; | 206 g_message_loop = nullptr; |
207 | 207 |
208 // Destroy the HostStarter and URLRequestContextGetter before stopping the | 208 // Destroy the HostStarter and URLRequestContextGetter before stopping the |
209 // IO thread. | 209 // IO thread. |
210 host_starter.reset(); | 210 host_starter.reset(); |
211 url_request_context_getter = nullptr; | 211 url_request_context_getter = nullptr; |
212 | 212 |
213 io_thread.Stop(); | 213 io_thread.Stop(); |
214 | 214 |
215 return g_started ? 0 : 1; | 215 return g_started ? 0 : 1; |
216 } | 216 } |
OLD | NEW |