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

Side by Side Diff: base/command_line.cc

Issue 3030043: PrependWrapper is platform-specific, so it should take a platform string. (Closed)
Patch Set: Created 10 years, 4 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') | chrome/browser/gpu_process_host.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #elif defined(OS_POSIX) 10 #elif defined(OS_POSIX)
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Verify include_program is used correctly. 425 // Verify include_program is used correctly.
426 // Logic could be shorter but this is clearer. 426 // Logic could be shorter but this is clearer.
427 DCHECK_EQ(include_program, !other.GetProgram().empty()); 427 DCHECK_EQ(include_program, !other.GetProgram().empty());
428 command_line_string_ += L" " + other.command_line_string_; 428 command_line_string_ += L" " + other.command_line_string_;
429 std::map<std::string, StringType>::const_iterator i; 429 std::map<std::string, StringType>::const_iterator i;
430 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) 430 for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
431 switches_[i->first] = i->second; 431 switches_[i->first] = i->second;
432 } 432 }
433 433
434 void CommandLine::PrependWrapper(const std::wstring& wrapper) { 434 void CommandLine::PrependWrapper(const std::wstring& wrapper) {
435 if (wrapper.empty())
436 return;
435 // The wrapper may have embedded arguments (like "gdb --args"). In this case, 437 // The wrapper may have embedded arguments (like "gdb --args"). In this case,
436 // we don't pretend to do anything fancy, we just split on spaces. 438 // we don't pretend to do anything fancy, we just split on spaces.
437 std::vector<std::wstring> wrapper_and_args; 439 std::vector<std::wstring> wrapper_and_args;
438 SplitString(wrapper, ' ', &wrapper_and_args); 440 SplitString(wrapper, ' ', &wrapper_and_args);
439 program_ = wrapper_and_args[0]; 441 program_ = wrapper_and_args[0];
440 command_line_string_ = wrapper + L" " + command_line_string_; 442 command_line_string_ = wrapper + L" " + command_line_string_;
441 } 443 }
442 444
443 #elif defined(OS_POSIX) 445 #elif defined(OS_POSIX)
444 void CommandLine::AppendSwitch(const std::string& switch_string) { 446 void CommandLine::AppendSwitch(const std::string& switch_string) {
(...skipping 23 matching lines...) Expand all
468 // Logic could be shorter but this is clearer. 470 // Logic could be shorter but this is clearer.
469 DCHECK_EQ(include_program, !other.GetProgram().empty()); 471 DCHECK_EQ(include_program, !other.GetProgram().empty());
470 size_t first_arg = include_program ? 0 : 1; 472 size_t first_arg = include_program ? 0 : 1;
471 for (size_t i = first_arg; i < other.argv_.size(); ++i) 473 for (size_t i = first_arg; i < other.argv_.size(); ++i)
472 argv_.push_back(other.argv_[i]); 474 argv_.push_back(other.argv_[i]);
473 std::map<std::string, StringType>::const_iterator i; 475 std::map<std::string, StringType>::const_iterator i;
474 for (i = other.switches_.begin(); i != other.switches_.end(); ++i) 476 for (i = other.switches_.begin(); i != other.switches_.end(); ++i)
475 switches_[i->first] = i->second; 477 switches_[i->first] = i->second;
476 } 478 }
477 479
478 void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { 480 void CommandLine::PrependWrapper(const std::string& wrapper) {
479 // The wrapper may have embedded arguments (like "gdb --args"). In this case, 481 // The wrapper may have embedded arguments (like "gdb --args"). In this case,
480 // we don't pretend to do anything fancy, we just split on spaces. 482 // we don't pretend to do anything fancy, we just split on spaces.
481 const std::string wrapper = base::SysWideToNativeMB(wrapper_wide);
482 std::vector<std::string> wrapper_and_args; 483 std::vector<std::string> wrapper_and_args;
483 SplitString(wrapper, ' ', &wrapper_and_args); 484 SplitString(wrapper, ' ', &wrapper_and_args);
484 argv_.insert(argv_.begin(), wrapper_and_args.begin(), wrapper_and_args.end()); 485 argv_.insert(argv_.begin(), wrapper_and_args.begin(), wrapper_and_args.end());
485 } 486 }
486 487
487 #endif 488 #endif
488 489
489 void CommandLine::AppendSwitchPath(const std::string& switch_string, 490 void CommandLine::AppendSwitchPath(const std::string& switch_string,
490 const FilePath& path) { 491 const FilePath& path) {
491 AppendSwitchNative(switch_string, path.value()); 492 AppendSwitchNative(switch_string, path.value());
492 } 493 }
493 494
494 void CommandLine::CopySwitchesFrom(const CommandLine& source, 495 void CommandLine::CopySwitchesFrom(const CommandLine& source,
495 const char* const switches[], 496 const char* const switches[],
496 size_t count) { 497 size_t count) {
497 for (size_t i = 0; i < count; ++i) { 498 for (size_t i = 0; i < count; ++i) {
498 if (source.HasSwitch(switches[i])) { 499 if (source.HasSwitch(switches[i])) {
499 StringType value = source.GetSwitchValueNative(switches[i]); 500 StringType value = source.GetSwitchValueNative(switches[i]);
500 AppendSwitchNative(switches[i], value); 501 AppendSwitchNative(switches[i], value);
501 } 502 }
502 } 503 }
503 } 504 }
504 505
505 // private 506 // private
506 CommandLine::CommandLine() { 507 CommandLine::CommandLine() {
507 } 508 }
OLDNEW
« no previous file with comments | « base/command_line.h ('k') | chrome/browser/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698