OLD | NEW |
---|---|
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 void CommandLine::Init(int argc, const char* const* argv) { |
171 delete current_process_commandline_; | 171 if (current_process_commandline_) { |
msw
2011/06/28 23:19:42
I don't think this should fail silently. There mig
rvargas (doing something else)
2011/06/28 23:57:35
I was going to CHECK... except that it will defeat
| |
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 | |
174 // shared libraries. | |
175 return; | |
176 } | |
177 | |
172 current_process_commandline_ = new CommandLine(NO_PROGRAM); | 178 current_process_commandline_ = new CommandLine(NO_PROGRAM); |
173 #if defined(OS_WIN) | 179 #if defined(OS_WIN) |
174 current_process_commandline_->ParseFromString(::GetCommandLineW()); | 180 current_process_commandline_->ParseFromString(::GetCommandLineW()); |
175 #elif defined(OS_POSIX) | 181 #elif defined(OS_POSIX) |
176 current_process_commandline_->InitFromArgv(argc, argv); | 182 current_process_commandline_->InitFromArgv(argc, argv); |
177 #endif | 183 #endif |
178 } | 184 } |
179 | 185 |
180 // static | 186 // static |
181 void CommandLine::Reset() { | 187 void CommandLine::Reset() { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 int num_args = 0; | 397 int num_args = 0; |
392 wchar_t** args = NULL; | 398 wchar_t** args = NULL; |
393 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); | 399 args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args); |
394 | 400 |
395 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << | 401 PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " << |
396 command_line; | 402 command_line; |
397 InitFromArgv(num_args, args); | 403 InitFromArgv(num_args, args); |
398 LocalFree(args); | 404 LocalFree(args); |
399 } | 405 } |
400 #endif | 406 #endif |
OLD | NEW |