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

Side by Side Diff: base/command_line.cc

Issue 9477001: Allow callers of CommandLine::Init to know whether they were the first caller. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comment clarification. Created 8 years, 10 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
« no previous file with comments | « base/command_line.h ('k') | base/command_line_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 CommandLine::CommandLine(const StringVector& argv) 160 CommandLine::CommandLine(const StringVector& argv)
161 : argv_(1), 161 : argv_(1),
162 begin_args_(1) { 162 begin_args_(1) {
163 InitFromArgv(argv); 163 InitFromArgv(argv);
164 } 164 }
165 165
166 CommandLine::~CommandLine() { 166 CommandLine::~CommandLine() {
167 } 167 }
168 168
169 // static 169 // static
170 void CommandLine::Init(int argc, const char* const* argv) { 170 bool CommandLine::Init(int argc, const char* const* argv) {
171 if (current_process_commandline_) { 171 if (current_process_commandline_) {
172 // If this is intentional, Reset() must be called first. If we are using 172 // If this is intentional, Reset() must be called first. If we are using
173 // the shared build mode, we have to share a single object across multiple 173 // the shared build mode, we have to share a single object across multiple
174 // shared libraries. 174 // shared libraries.
175 return; 175 return false;
176 } 176 }
177 177
178 current_process_commandline_ = new CommandLine(NO_PROGRAM); 178 current_process_commandline_ = new CommandLine(NO_PROGRAM);
179 #if defined(OS_WIN) 179 #if defined(OS_WIN)
180 current_process_commandline_->ParseFromString(::GetCommandLineW()); 180 current_process_commandline_->ParseFromString(::GetCommandLineW());
181 #elif defined(OS_POSIX) 181 #elif defined(OS_POSIX)
182 current_process_commandline_->InitFromArgv(argc, argv); 182 current_process_commandline_->InitFromArgv(argc, argv);
183 #endif 183 #endif
184
185 return true;
184 } 186 }
185 187
186 // static 188 // static
187 void CommandLine::Reset() { 189 void CommandLine::Reset() {
188 DCHECK(current_process_commandline_); 190 DCHECK(current_process_commandline_);
189 delete current_process_commandline_; 191 delete current_process_commandline_;
190 current_process_commandline_ = NULL; 192 current_process_commandline_ = NULL;
191 } 193 }
192 194
193 // static 195 // static
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 int num_args = 0; 395 int num_args = 0;
394 wchar_t** args = NULL; 396 wchar_t** args = NULL;
395 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); 397 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args);
396 398
397 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " 399 DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: "
398 << command_line; 400 << command_line;
399 InitFromArgv(num_args, args); 401 InitFromArgv(num_args, args);
400 LocalFree(args); 402 LocalFree(args);
401 } 403 }
402 #endif 404 #endif
OLDNEW
« no previous file with comments | « base/command_line.h ('k') | base/command_line_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698