| 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 <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #if !defined(OS_WIN) | 22 #if !defined(OS_WIN) |
| 23 #include <termios.h> | 23 #include <termios.h> |
| 24 #endif // !defined(OS_WIN) | 24 #endif // !defined(OS_WIN) |
| 25 | 25 |
| 26 using remoting::HostStarter; | 26 using remoting::HostStarter; |
| 27 | 27 |
| 28 // True if the host was started successfully. | 28 // True if the host was started successfully. |
| 29 bool g_started = false; | 29 bool g_started = false; |
| 30 | 30 |
| 31 // The main message loop. | 31 // The main message loop. |
| 32 base::MessageLoop* g_message_loop = NULL; | 32 base::MessageLoop* g_message_loop = nullptr; |
| 33 | 33 |
| 34 // Lets us hide the PIN that a user types. | 34 // Lets us hide the PIN that a user types. |
| 35 void SetEcho(bool echo) { | 35 void SetEcho(bool echo) { |
| 36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 37 DWORD mode; | 37 DWORD mode; |
| 38 HANDLE console_handle = GetStdHandle(STD_INPUT_HANDLE); | 38 HANDLE console_handle = GetStdHandle(STD_INPUT_HANDLE); |
| 39 if (!GetConsoleMode(console_handle, &mode)) { | 39 if (!GetConsoleMode(console_handle, &mode)) { |
| 40 LOG(ERROR) << "GetConsoleMode failed"; | 40 LOG(ERROR) << "GetConsoleMode failed"; |
| 41 return; | 41 return; |
| 42 } | 42 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if (redirect_url.empty()) { | 178 if (redirect_url.empty()) { |
| 179 redirect_url = remoting::GetDefaultOauthRedirectUrl(); | 179 redirect_url = remoting::GetDefaultOauthRedirectUrl(); |
| 180 } | 180 } |
| 181 host_starter->StartHost(host_name, host_pin, true, auth_code, redirect_url, | 181 host_starter->StartHost(host_name, host_pin, true, auth_code, redirect_url, |
| 182 base::Bind(&OnDone)); | 182 base::Bind(&OnDone)); |
| 183 | 183 |
| 184 // Run the message loop until the StartHost completion callback. | 184 // Run the message loop until the StartHost completion callback. |
| 185 base::RunLoop run_loop; | 185 base::RunLoop run_loop; |
| 186 run_loop.Run(); | 186 run_loop.Run(); |
| 187 | 187 |
| 188 g_message_loop = NULL; | 188 g_message_loop = nullptr; |
| 189 | 189 |
| 190 // Destroy the HostStarter and URLRequestContextGetter before stopping the | 190 // Destroy the HostStarter and URLRequestContextGetter before stopping the |
| 191 // IO thread. | 191 // IO thread. |
| 192 host_starter.reset(); | 192 host_starter.reset(); |
| 193 url_request_context_getter = NULL; | 193 url_request_context_getter = nullptr; |
| 194 | 194 |
| 195 io_thread.Stop(); | 195 io_thread.Stop(); |
| 196 | 196 |
| 197 return g_started ? 0 : 1; | 197 return g_started ? 0 : 1; |
| 198 } | 198 } |
| OLD | NEW |