| 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 "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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 CommandLine::~CommandLine() { | 190 CommandLine::~CommandLine() { |
| 191 } | 191 } |
| 192 | 192 |
| 193 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
| 194 // static | 194 // static |
| 195 void CommandLine::set_slash_is_not_a_switch() { | 195 void CommandLine::set_slash_is_not_a_switch() { |
| 196 // The last switch prefix should be slash, so adjust the size to skip it. | 196 // The last switch prefix should be slash, so adjust the size to skip it. |
| 197 DCHECK_EQ(wcscmp(kSwitchPrefixes[arraysize(kSwitchPrefixes) - 1], L"/"), 0); | 197 DCHECK_EQ(wcscmp(kSwitchPrefixes[arraysize(kSwitchPrefixes) - 1], L"/"), 0); |
| 198 switch_prefix_count = arraysize(kSwitchPrefixes) - 1; | 198 switch_prefix_count = arraysize(kSwitchPrefixes) - 1; |
| 199 } | 199 } |
| 200 |
| 201 // static |
| 202 void CommandLine::InitUsingArgvForTesting(int argc, const char* const* argv) { |
| 203 DCHECK(!current_process_commandline_); |
| 204 current_process_commandline_ = new CommandLine(NO_PROGRAM); |
| 205 // On Windows we need to convert the command line arguments to string16. |
| 206 base::CommandLine::StringVector argv_vector; |
| 207 for (int i = 0; i < argc; ++i) |
| 208 argv_vector.push_back(UTF8ToUTF16(argv[i])); |
| 209 current_process_commandline_->InitFromArgv(argv_vector); |
| 210 } |
| 200 #endif | 211 #endif |
| 201 | 212 |
| 202 // static | 213 // static |
| 203 bool CommandLine::Init(int argc, const char* const* argv) { | 214 bool CommandLine::Init(int argc, const char* const* argv) { |
| 204 if (current_process_commandline_) { | 215 if (current_process_commandline_) { |
| 205 // If this is intentional, Reset() must be called first. If we are using | 216 // If this is intentional, Reset() must be called first. If we are using |
| 206 // the shared build mode, we have to share a single object across multiple | 217 // the shared build mode, we have to share a single object across multiple |
| 207 // shared libraries. | 218 // shared libraries. |
| 208 return false; | 219 return false; |
| 209 } | 220 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 return params; | 484 return params; |
| 474 } | 485 } |
| 475 | 486 |
| 476 void CommandLine::ResetStringPieces() { | 487 void CommandLine::ResetStringPieces() { |
| 477 switches_by_stringpiece_.clear(); | 488 switches_by_stringpiece_.clear(); |
| 478 for (const auto& entry : switches_) | 489 for (const auto& entry : switches_) |
| 479 switches_by_stringpiece_[entry.first] = &(entry.second); | 490 switches_by_stringpiece_[entry.first] = &(entry.second); |
| 480 } | 491 } |
| 481 | 492 |
| 482 } // namespace base | 493 } // namespace base |
| OLD | NEW |