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 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <termios.h> | 6 #include <termios.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (no_echo) | 46 if (no_echo) |
47 SetEcho(false); | 47 SetEcho(false); |
48 const int kMaxLen = 1024; | 48 const int kMaxLen = 1024; |
49 std::string str(kMaxLen, 0); | 49 std::string str(kMaxLen, 0); |
50 char* result = fgets(&str[0], kMaxLen, stdin); | 50 char* result = fgets(&str[0], kMaxLen, stdin); |
51 if (no_echo) { | 51 if (no_echo) { |
52 printf("\n"); | 52 printf("\n"); |
53 SetEcho(true); | 53 SetEcho(true); |
54 } | 54 } |
55 if (!result) | 55 if (!result) |
56 return ""; | 56 return std::string(); |
57 size_t newline_index = str.find('\n'); | 57 size_t newline_index = str.find('\n'); |
58 if (newline_index != std::string::npos) | 58 if (newline_index != std::string::npos) |
59 str[newline_index] = '\0'; | 59 str[newline_index] = '\0'; |
60 str.resize(strlen(&str[0])); | 60 str.resize(strlen(&str[0])); |
61 return str; | 61 return str; |
62 } | 62 } |
63 | 63 |
64 // Called when the HostStarter has finished. | 64 // Called when the HostStarter has finished. |
65 void OnDone(HostStarter::Result result) { | 65 void OnDone(HostStarter::Result result) { |
66 if (MessageLoop::current() != g_message_loop) { | 66 if (MessageLoop::current() != g_message_loop) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 // Destroy the HostStarter and URLRequestContextGetter before stopping the | 179 // Destroy the HostStarter and URLRequestContextGetter before stopping the |
180 // IO thread. | 180 // IO thread. |
181 host_starter.reset(); | 181 host_starter.reset(); |
182 url_request_context_getter = NULL; | 182 url_request_context_getter = NULL; |
183 | 183 |
184 io_thread.Stop(); | 184 io_thread.Stop(); |
185 | 185 |
186 return g_started ? 0 : 1; | 186 return g_started ? 0 : 1; |
187 } | 187 } |
OLD | NEW |