summaryrefslogtreecommitdiffstats
path: root/base/command_line.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 22:50:39 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-12 22:50:39 +0000
commit0189bbd4cc569eaec4c6664109659c32fed8e4b7 (patch)
treef792f823d15a1e806d1b25d0f6d318622db6daf4 /base/command_line.cc
parent079487b08bf7867eb7c078b59dec61f142a42df2 (diff)
downloadchromium_src-0189bbd4cc569eaec4c6664109659c32fed8e4b7.zip
chromium_src-0189bbd4cc569eaec4c6664109659c32fed8e4b7.tar.gz
chromium_src-0189bbd4cc569eaec4c6664109659c32fed8e4b7.tar.bz2
CommandLine: rejigger how initialization works.
I'm attempting to clean up CommandLine. This change rearranges how initialization is done. I am trying to eliminate redundant functions; more will come in subsequent changes. Review URL: http://codereview.chromium.org/273018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.cc')
-rw-r--r--base/command_line.cc24
1 files changed, 5 insertions, 19 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index ac8402cb..84fa415 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -109,17 +109,14 @@ CommandLine::CommandLine(const std::wstring& program) {
}
}
#elif defined(OS_POSIX)
-CommandLine::CommandLine(int argc, const char* const* argv) {
+void CommandLine::InitFromArgv(int argc, const char* const* argv) {
for (int i = 0; i < argc; ++i)
argv_.push_back(argv[i]);
- InitFromArgv();
-}
-CommandLine::CommandLine(const std::vector<std::string>& argv) {
- argv_ = argv;
- InitFromArgv();
+ InitFromArgv(argv_);
}
-void CommandLine::InitFromArgv() {
+void CommandLine::InitFromArgv(const std::vector<std::string>& argv) {
+ argv_ = argv;
bool parse_switches = true;
for (size_t i = 1; i < argv_.size(); ++i) {
const std::string& arg = argv_[i];
@@ -192,22 +189,11 @@ bool CommandLine::IsSwitch(const StringType& parameter_string,
// static
void CommandLine::Init(int argc, const char* const* argv) {
-#if defined(OS_WIN)
current_process_commandline_ = new CommandLine;
- current_process_commandline_->ParseFromString(::GetCommandLineW());
-#elif defined(OS_POSIX)
- current_process_commandline_ = new CommandLine(argc, argv);
-#endif
-}
-
-// static
-void CommandLine::Init(const std::vector<std::string>& argv) {
- DCHECK(current_process_commandline_ == NULL);
#if defined(OS_WIN)
- current_process_commandline_ = new CommandLine;
current_process_commandline_->ParseFromString(::GetCommandLineW());
#elif defined(OS_POSIX)
- current_process_commandline_ = new CommandLine(argv);
+ current_process_commandline_->InitFromArgv(argc, argv);
#endif
}