Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Side by Side Diff: remoting/host/setup/start_host.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/setup/oauth_helper.cc ('k') | remoting/jingle_glue/iq_sender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « remoting/host/setup/oauth_helper.cc ('k') | remoting/jingle_glue/iq_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698