Skip to content

Commit

Permalink
Move CommandLine to base namespace.
Browse files Browse the repository at this point in the history
Fix all forward-declares and header files referencing CommandLine.

This keeps a "using base::CommandLine" in the command line header file so that the rest of the source files can be changes in a follow-up.

TBR=sky

Review URL: https://codereview.chromium.org/196413016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257514 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
brettw@chromium.org committed Mar 17, 2014
1 parent 936e859 commit 2f3b1cc
Show file tree
Hide file tree
Showing 194 changed files with 647 additions and 483 deletions.
2 changes: 1 addition & 1 deletion android_webview/browser/aw_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ std::string AwContentBrowserClient::GetCanonicalEncodingNameByAliasName(
}

void AwContentBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line,
base::CommandLine* command_line,
int child_process_id) {
NOTREACHED() << "Android WebView does not support multi-process yet";
}
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
virtual std::string GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual std::string GetApplicationLocale() OVERRIDE;
virtual std::string GetAcceptLangs(content::BrowserContext* context) OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions apps/app_load_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AppLoadService : public KeyedService,
PostReloadAction();

PostReloadActionType action_type;
CommandLine command_line;
base::CommandLine command_line;
base::FilePath current_dir;
};

Expand All @@ -53,7 +53,7 @@ class AppLoadService : public KeyedService,
// launch parameters. Returns true if loading the extension has begun
// successfully.
bool LoadAndLaunch(const base::FilePath& extension_path,
const CommandLine& command_line,
const base::CommandLine& command_line,
const base::FilePath& current_dir);

static AppLoadService* Get(Profile* profile);
Expand Down
4 changes: 2 additions & 2 deletions apps/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include <string>

class CommandLine;
class GURL;
class Profile;

namespace base {
class CommandLine;
class FilePath;
}

Expand All @@ -27,7 +27,7 @@ namespace apps {
// |current_directory| is used to expand any relative paths on the command line.
void LaunchPlatformAppWithCommandLine(Profile* profile,
const extensions::Extension* extension,
const CommandLine& command_line,
const base::CommandLine& command_line,
const base::FilePath& current_directory);

// Launches the platform app |extension| by issuing an onLaunched event
Expand Down
2 changes: 1 addition & 1 deletion apps/shell/browser/shell_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
OVERRIDE;
virtual void SiteInstanceDeleting(content::SiteInstance* site_instance)
OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual void GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_schemes) OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion apps/shell/browser/shell_extensions_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {

// ExtensionsBrowserClient overrides:
virtual bool IsShuttingDown() OVERRIDE;
virtual bool AreExtensionsDisabled(const CommandLine& command_line,
virtual bool AreExtensionsDisabled(const base::CommandLine& command_line,
content::BrowserContext* context) OVERRIDE;
virtual bool IsValidContext(content::BrowserContext* context) OVERRIDE;
virtual bool IsSameContext(content::BrowserContext* first,
Expand Down
10 changes: 6 additions & 4 deletions ash/desktop_background/desktop_background_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

typedef unsigned int SkColor;

class CommandLine;

namespace aura {
class Window;
}

namespace base {
class CommandLine;
}

namespace ash {

enum WallpaperLayout {
Expand Down Expand Up @@ -81,7 +83,7 @@ class ASH_EXPORT DesktopBackgroundController
return desktop_background_mode_;
}

void set_command_line_for_testing(CommandLine* command_line) {
void set_command_line_for_testing(base::CommandLine* command_line) {
command_line_for_testing_ = command_line;
}

Expand Down Expand Up @@ -189,7 +191,7 @@ class ASH_EXPORT DesktopBackgroundController
static gfx::Size GetMaxDisplaySizeInNative();

// If non-NULL, used in place of the real command line.
CommandLine* command_line_for_testing_;
base::CommandLine* command_line_for_testing_;

// Can change at runtime.
bool locked_;
Expand Down
2 changes: 0 additions & 2 deletions ash/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include "ui/gfx/size.h"
#include "ui/wm/core/cursor_manager.h"

class CommandLine;

namespace app_list {
class AppListView;
}
Expand Down
25 changes: 14 additions & 11 deletions base/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
#include <shellapi.h>
#endif

using base::FilePath;
namespace base {

CommandLine* CommandLine::current_process_commandline_ = NULL;

namespace {

const CommandLine::CharType kSwitchTerminator[] = FILE_PATH_LITERAL("--");
const CommandLine::CharType kSwitchValueSeparator[] = FILE_PATH_LITERAL("=");

Expand Down Expand Up @@ -74,14 +75,14 @@ void AppendSwitchesAndArguments(CommandLine& command_line,
bool parse_switches = true;
for (size_t i = 1; i < argv.size(); ++i) {
CommandLine::StringType arg = argv[i];
base::TrimWhitespace(arg, base::TRIM_ALL, &arg);
TrimWhitespace(arg, TRIM_ALL, &arg);

CommandLine::StringType switch_string;
CommandLine::StringType switch_value;
parse_switches &= (arg != kSwitchTerminator);
if (parse_switches && IsSwitch(arg, &switch_string, &switch_value)) {
#if defined(OS_WIN)
command_line.AppendSwitchNative(base::UTF16ToASCII(switch_string),
command_line.AppendSwitchNative(UTF16ToASCII(switch_string),
switch_value);
#elif defined(OS_POSIX)
command_line.AppendSwitchNative(switch_string, switch_value);
Expand Down Expand Up @@ -294,7 +295,7 @@ FilePath CommandLine::GetProgram() const {
}

void CommandLine::SetProgram(const FilePath& program) {
base::TrimWhitespace(program.value(), base::TRIM_ALL, &argv_[0]);
TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
}

bool CommandLine::HasSwitch(const std::string& switch_string) const {
Expand All @@ -309,7 +310,7 @@ std::string CommandLine::GetSwitchValueASCII(
return std::string();
}
#if defined(OS_WIN)
return base::UTF16ToASCII(value);
return UTF16ToASCII(value);
#else
return value;
#endif
Expand Down Expand Up @@ -340,7 +341,7 @@ void CommandLine::AppendSwitchNative(const std::string& switch_string,
const CommandLine::StringType& value) {
std::string switch_key(LowerASCIIOnWindows(switch_string));
#if defined(OS_WIN)
StringType combined_switch_string(base::ASCIIToWide(switch_key));
StringType combined_switch_string(ASCIIToWide(switch_key));
#elif defined(OS_POSIX)
StringType combined_switch_string(switch_string);
#endif
Expand All @@ -358,7 +359,7 @@ void CommandLine::AppendSwitchNative(const std::string& switch_string,
void CommandLine::AppendSwitchASCII(const std::string& switch_string,
const std::string& value_string) {
#if defined(OS_WIN)
AppendSwitchNative(switch_string, base::ASCIIToWide(value_string));
AppendSwitchNative(switch_string, ASCIIToWide(value_string));
#elif defined(OS_POSIX)
AppendSwitchNative(switch_string, value_string);
#endif
Expand Down Expand Up @@ -387,7 +388,7 @@ CommandLine::StringVector CommandLine::GetArgs() const {
void CommandLine::AppendArg(const std::string& value) {
#if defined(OS_WIN)
DCHECK(IsStringUTF8(value));
AppendArgNative(base::UTF8ToWide(value));
AppendArgNative(UTF8ToWide(value));
#elif defined(OS_POSIX)
AppendArgNative(value);
#endif
Expand All @@ -414,7 +415,7 @@ void CommandLine::PrependWrapper(const CommandLine::StringType& wrapper) {
// The wrapper may have embedded arguments (like "gdb --args"). In this case,
// we don't pretend to do anything fancy, we just split on spaces.
StringVector wrapper_argv;
base::SplitString(wrapper, FILE_PATH_LITERAL(' '), &wrapper_argv);
SplitString(wrapper, FILE_PATH_LITERAL(' '), &wrapper_argv);
// Prepend the wrapper and update the switches/arguments |begin_args_|.
argv_.insert(argv_.begin(), wrapper_argv.begin(), wrapper_argv.end());
begin_args_ += wrapper_argv.size();
Expand All @@ -423,7 +424,7 @@ void CommandLine::PrependWrapper(const CommandLine::StringType& wrapper) {
#if defined(OS_WIN)
void CommandLine::ParseFromString(const std::wstring& command_line) {
std::wstring command_line_string;
base::TrimWhitespace(command_line, base::TRIM_ALL, &command_line_string);
TrimWhitespace(command_line, TRIM_ALL, &command_line_string);
if (command_line_string.empty())
return;

Expand All @@ -432,8 +433,10 @@ void CommandLine::ParseFromString(const std::wstring& command_line) {
args = ::CommandLineToArgvW(command_line_string.c_str(), &num_args);

DPLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: "
<< command_line;
<< UTF16ToUTF8(command_line);
InitFromArgv(num_args, args);
LocalFree(args);
}
#endif

} // namespace base
19 changes: 12 additions & 7 deletions base/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "build/build_config.h"

namespace base {

class FilePath;
}

class BASE_EXPORT CommandLine {
public:
Expand All @@ -45,7 +45,7 @@ class BASE_EXPORT CommandLine {
explicit CommandLine(NoProgram no_program);

// Construct a new command line with |program| as argv[0].
explicit CommandLine(const base::FilePath& program);
explicit CommandLine(const FilePath& program);

// Construct a new command line from an argument list.
CommandLine(int argc, const CharType* const* argv);
Expand Down Expand Up @@ -108,8 +108,8 @@ class BASE_EXPORT CommandLine {
const StringVector& argv() const { return argv_; }

// Get and Set the program part of the command line string (the first item).
base::FilePath GetProgram() const;
void SetProgram(const base::FilePath& program);
FilePath GetProgram() const;
void SetProgram(const FilePath& program);

// Returns true if this command line contains the given switch.
// (Switch names are case-insensitive).
Expand All @@ -118,7 +118,7 @@ class BASE_EXPORT CommandLine {
// Returns the value associated with the given switch. If the switch has no
// value or isn't present, this method returns the empty string.
std::string GetSwitchValueASCII(const std::string& switch_string) const;
base::FilePath GetSwitchValuePath(const std::string& switch_string) const;
FilePath GetSwitchValuePath(const std::string& switch_string) const;
StringType GetSwitchValueNative(const std::string& switch_string) const;

// Get a copy of all switches, along with their values.
Expand All @@ -128,7 +128,7 @@ class BASE_EXPORT CommandLine {
// Note: Switches will precede arguments regardless of appending order.
void AppendSwitch(const std::string& switch_string);
void AppendSwitchPath(const std::string& switch_string,
const base::FilePath& path);
const FilePath& path);
void AppendSwitchNative(const std::string& switch_string,
const StringType& value);
void AppendSwitchASCII(const std::string& switch_string,
Expand All @@ -148,7 +148,7 @@ class BASE_EXPORT CommandLine {
// AppendArg is primarily for ASCII; non-ASCII input is interpreted as UTF-8.
// Note: Switches will precede arguments regardless of appending order.
void AppendArg(const std::string& value);
void AppendArgPath(const base::FilePath& value);
void AppendArgPath(const FilePath& value);
void AppendArgNative(const StringType& value);

// Append the switches and arguments from another command line to this one.
Expand Down Expand Up @@ -186,4 +186,9 @@ class BASE_EXPORT CommandLine {
size_t begin_args_;
};

} // namespace base

// TODO(brettw) remove once all callers specify the namespace properly.
using base::CommandLine;

#endif // BASE_COMMAND_LINE_H_
2 changes: 1 addition & 1 deletion base/mac/launch_services_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace mac {
// |out_psn|, if not NULL, will be set to the process serial number of the
// application's main process if the app was successfully launched.
// Returns true if the app was successfully launched.
BASE_EXPORT bool OpenApplicationWithPath(const base::FilePath& bundle_path,
BASE_EXPORT bool OpenApplicationWithPath(const FilePath& bundle_path,
const CommandLine& command_line,
LSLaunchFlags launch_flags,
ProcessSerialNumber* out_psn);
Expand Down
4 changes: 2 additions & 2 deletions base/process/launch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include "base/win/scoped_handle.h"
#endif

class CommandLine;

namespace base {

class CommandLine;

#if defined(OS_WIN)
typedef std::vector<HANDLE> HandlesToInheritVector;
#endif
Expand Down
3 changes: 1 addition & 2 deletions base/test/launcher/test_launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
#include "base/time/time.h"
#include "base/timer/timer.h"

class CommandLine;

namespace testing {
class TestCase;
class TestInfo;
}

namespace base {

class CommandLine;
struct LaunchOptions;
class SequencedWorkerPoolOwner;
class TestLauncher;
Expand Down
3 changes: 1 addition & 2 deletions base/test/launcher/test_results_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
#include "base/test/launcher/test_result.h"
#include "base/threading/thread_checker.h"

class CommandLine;

namespace base {

class CommandLine;
class FilePath;

// A helper class to output results.
Expand Down
4 changes: 2 additions & 2 deletions base/test/multiprocess_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "build/build_config.h"
#include "testing/platform_test.h"

class CommandLine;

namespace base {

class CommandLine;

// Helpers to spawn a child for a multiprocess test and execute a designated
// function. Use these when you already have another base class for your test
// fixture, but you want (some) of your tests to be multiprocess (otherwise you
Expand Down
5 changes: 3 additions & 2 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,9 @@ bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) {
}

#if defined(OS_MACOSX)
void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line,
const std::string& process_type) {
void ChromeMainDelegate::InitMacCrashReporter(
const base::CommandLine& command_line,
const std::string& process_type) {
// TODO(mark): Right now, InitCrashReporter() needs to be called after
// CommandLine::Init() and chrome::RegisterPathProvider(). Ideally,
// Breakpad initialization could occur sooner, preferably even before the
Expand Down
6 changes: 5 additions & 1 deletion chrome/app/chrome_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "chrome/common/chrome_content_client.h"
#include "content/public/app/content_main_delegate.h"

namespace base {
class CommandLine;
}

// Chrome implementation of ContentMainDelegate.
class ChromeMainDelegate : public content::ContentMainDelegate {
public:
Expand Down Expand Up @@ -42,7 +46,7 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
virtual content::ContentUtilityClient* CreateContentUtilityClient() OVERRIDE;

#if defined(OS_MACOSX)
void InitMacCrashReporter(const CommandLine& command_line,
void InitMacCrashReporter(const base::CommandLine& command_line,
const std::string& process_type);
#endif // defined(OS_MACOSX)

Expand Down
Loading

0 comments on commit 2f3b1cc

Please sign in to comment.