Chromium Code Reviews| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 | 358 |
| 359 void CommandLine::AppendSwitchASCII(const std::string& switch_string, | 359 void CommandLine::AppendSwitchASCII(const std::string& switch_string, |
| 360 const std::string& value_string) { | 360 const std::string& value_string) { |
| 361 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 362 AppendSwitchNative(switch_string, ASCIIToUTF16(value_string)); | 362 AppendSwitchNative(switch_string, ASCIIToUTF16(value_string)); |
| 363 #elif defined(OS_POSIX) | 363 #elif defined(OS_POSIX) |
| 364 AppendSwitchNative(switch_string, value_string); | 364 AppendSwitchNative(switch_string, value_string); |
| 365 #endif | 365 #endif |
| 366 } | 366 } |
| 367 | 367 |
| 368 void CommandLine::RemoveSwitchASCIIForTesting( | |
| 369 const std::string& switch_string) { | |
| 370 #if defined(OS_WIN) | |
| 371 const std::string switch_key = ToLowerASCII(switch_string); | |
| 372 StringType combined_switch_string(ASCIIToUTF16(switch_key)); | |
| 373 #elif defined(OS_POSIX) | |
| 374 const std::string& switch_key = switch_string; | |
| 375 StringType combined_switch_string(switch_key); | |
| 376 #endif | |
|
Ilya Sherman
2017/06/07 21:32:36
These few lines are duplicated from above. Please
| |
| 377 size_t prefix_length = GetSwitchPrefixLength(combined_switch_string); | |
| 378 switches_by_stringpiece_.erase(switch_key.substr(prefix_length)); | |
| 379 switches_.erase(switch_string.substr(prefix_length)); | |
|
Ilya Sherman
2017/06/07 21:32:36
Does argv_ need to be updated as well? (I am not
| |
| 380 } | |
| 381 | |
| 368 void CommandLine::CopySwitchesFrom(const CommandLine& source, | 382 void CommandLine::CopySwitchesFrom(const CommandLine& source, |
| 369 const char* const switches[], | 383 const char* const switches[], |
| 370 size_t count) { | 384 size_t count) { |
| 371 for (size_t i = 0; i < count; ++i) { | 385 for (size_t i = 0; i < count; ++i) { |
| 372 if (source.HasSwitch(switches[i])) | 386 if (source.HasSwitch(switches[i])) |
| 373 AppendSwitchNative(switches[i], source.GetSwitchValueNative(switches[i])); | 387 AppendSwitchNative(switches[i], source.GetSwitchValueNative(switches[i])); |
| 374 } | 388 } |
| 375 } | 389 } |
| 376 | 390 |
| 377 CommandLine::StringVector CommandLine::GetArgs() const { | 391 CommandLine::StringVector CommandLine::GetArgs() const { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 return params; | 503 return params; |
| 490 } | 504 } |
| 491 | 505 |
| 492 void CommandLine::ResetStringPieces() { | 506 void CommandLine::ResetStringPieces() { |
| 493 switches_by_stringpiece_.clear(); | 507 switches_by_stringpiece_.clear(); |
| 494 for (const auto& entry : switches_) | 508 for (const auto& entry : switches_) |
| 495 switches_by_stringpiece_[entry.first] = &(entry.second); | 509 switches_by_stringpiece_[entry.first] = &(entry.second); |
| 496 } | 510 } |
| 497 | 511 |
| 498 } // namespace base | 512 } // namespace base |
| OLD | NEW |