Commit 7cb2c679 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Use base::CommandLine in mojo/

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272712 0039d316-1c4b-4281-b951-d872f2087c98
parent f95da62f
...@@ -33,7 +33,8 @@ void MultiprocessTestHelper::StartChild(const std::string& test_child_name) { ...@@ -33,7 +33,8 @@ void MultiprocessTestHelper::StartChild(const std::string& test_child_name) {
std::string test_child_main = test_child_name + "TestChildMain"; std::string test_child_main = test_child_name + "TestChildMain";
CommandLine command_line(base::GetMultiProcessTestChildBaseCommandLine()); base::CommandLine command_line(
base::GetMultiProcessTestChildBaseCommandLine());
embedder::HandlePassingInformation handle_passing_info; embedder::HandlePassingInformation handle_passing_info;
platform_channel_pair_->PrepareToPassClientHandleToChildProcess( platform_channel_pair_->PrepareToPassClientHandleToChildProcess(
&command_line, &handle_passing_info); &command_line, &handle_passing_info);
...@@ -72,10 +73,10 @@ bool MultiprocessTestHelper::WaitForChildTestShutdown() { ...@@ -72,10 +73,10 @@ bool MultiprocessTestHelper::WaitForChildTestShutdown() {
// static // static
void MultiprocessTestHelper::ChildSetup() { void MultiprocessTestHelper::ChildSetup() {
CHECK(CommandLine::InitializedForCurrentProcess()); CHECK(base::CommandLine::InitializedForCurrentProcess());
client_platform_handle = client_platform_handle =
embedder::PlatformChannelPair::PassClientHandleFromParentProcess( embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
*CommandLine::ForCurrentProcess()); *base::CommandLine::ForCurrentProcess());
} }
// static // static
......
...@@ -60,7 +60,7 @@ PlatformChannelPair::PlatformChannelPair() { ...@@ -60,7 +60,7 @@ PlatformChannelPair::PlatformChannelPair() {
// static // static
ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess( ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
const CommandLine& command_line) { const base::CommandLine& command_line) {
std::string client_fd_string = std::string client_fd_string =
command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch); command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch);
int client_fd = -1; int client_fd = -1;
...@@ -75,7 +75,7 @@ ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess( ...@@ -75,7 +75,7 @@ ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
} }
void PlatformChannelPair::PrepareToPassClientHandleToChildProcess( void PlatformChannelPair::PrepareToPassClientHandleToChildProcess(
CommandLine* command_line, base::CommandLine* command_line,
base::FileHandleMappingVector* handle_passing_info) const { base::FileHandleMappingVector* handle_passing_info) const {
DCHECK(command_line); DCHECK(command_line);
DCHECK(handle_passing_info); DCHECK(handle_passing_info);
......
...@@ -73,7 +73,7 @@ PlatformChannelPair::PlatformChannelPair() { ...@@ -73,7 +73,7 @@ PlatformChannelPair::PlatformChannelPair() {
// static // static
ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess( ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
const CommandLine& command_line) { const base::CommandLine& command_line) {
std::string client_handle_string = std::string client_handle_string =
command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch); command_line.GetSwitchValueASCII(kMojoPlatformChannelHandleSwitch);
...@@ -89,7 +89,7 @@ ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess( ...@@ -89,7 +89,7 @@ ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
} }
void PlatformChannelPair::PrepareToPassClientHandleToChildProcess( void PlatformChannelPair::PrepareToPassClientHandleToChildProcess(
CommandLine* command_line, base::CommandLine* command_line,
base::HandlesToInheritVector* handle_passing_info) const { base::HandlesToInheritVector* handle_passing_info) const {
DCHECK(command_line); DCHECK(command_line);
DCHECK(handle_passing_info); DCHECK(handle_passing_info);
......
...@@ -177,7 +177,7 @@ class AuraDemo : public Application { ...@@ -177,7 +177,7 @@ class AuraDemo : public Application {
extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain( extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain(
MojoHandle shell_handle) { MojoHandle shell_handle) {
CommandLine::Init(0, NULL); base::CommandLine::Init(0, NULL);
base::AtExitManager at_exit; base::AtExitManager at_exit;
base::MessageLoop loop; base::MessageLoop loop;
mojo::GLES2Initializer gles2; mojo::GLES2Initializer gles2;
......
...@@ -267,7 +267,7 @@ class LauncherImpl : public InterfaceImpl<Launcher>, ...@@ -267,7 +267,7 @@ class LauncherImpl : public InterfaceImpl<Launcher>,
extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain(
MojoHandle shell_handle) { MojoHandle shell_handle) {
CommandLine::Init(0, NULL); base::CommandLine::Init(0, NULL);
base::AtExitManager at_exit; base::AtExitManager at_exit;
base::i18n::InitializeICU(); base::i18n::InitializeICU();
......
...@@ -35,7 +35,7 @@ const char kServiceName[] = "org.chromium.EchoService"; ...@@ -35,7 +35,7 @@ const char kServiceName[] = "org.chromium.EchoService";
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::AtExitManager exit_manager; base::AtExitManager exit_manager;
CommandLine::Init(argc, argv); base::CommandLine::Init(argc, argv);
logging::LoggingSettings settings; logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain( extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain(
MojoHandle shell_handle) { MojoHandle shell_handle) {
CommandLine::Init(0, NULL); base::CommandLine::Init(0, NULL);
base::AtExitManager at_exit; base::AtExitManager at_exit;
base::MessageLoop loop; base::MessageLoop loop;
mojo::Application app(shell_handle); mojo::Application app(shell_handle);
......
...@@ -38,14 +38,14 @@ LazyInstance<scoped_ptr<shell::Context> > g_context = ...@@ -38,14 +38,14 @@ LazyInstance<scoped_ptr<shell::Context> > g_context =
LazyInstance<scoped_ptr<mojo::Environment> > g_env = LazyInstance<scoped_ptr<mojo::Environment> > g_env =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
} // namspace } // namespace
static void Init(JNIEnv* env, jclass clazz, jobject context) { static void Init(JNIEnv* env, jclass clazz, jobject context) {
base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
base::android::InitApplicationContext(env, scoped_context); base::android::InitApplicationContext(env, scoped_context);
CommandLine::Init(0, 0); base::CommandLine::Init(0, 0);
mojo::shell::InitializeLogging(); mojo::shell::InitializeLogging();
g_java_message_loop.Get().reset(new base::MessageLoopForUI); g_java_message_loop.Get().reset(new base::MessageLoopForUI);
...@@ -71,7 +71,7 @@ static void Start(JNIEnv* env, jclass clazz, jobject context, jstring jurl) { ...@@ -71,7 +71,7 @@ static void Start(JNIEnv* env, jclass clazz, jobject context, jstring jurl) {
std::vector<std::string> argv; std::vector<std::string> argv;
argv.push_back("mojo_shell"); argv.push_back("mojo_shell");
argv.push_back(app_url); argv.push_back(app_url);
CommandLine::ForCurrentProcess()->InitFromArgv(argv); base::CommandLine::ForCurrentProcess()->InitFromArgv(argv);
} }
g_env.Get().reset(new Environment); g_env.Get().reset(new Environment);
......
...@@ -19,7 +19,8 @@ ChildProcess::~ChildProcess() { ...@@ -19,7 +19,8 @@ ChildProcess::~ChildProcess() {
} }
// static // static
scoped_ptr<ChildProcess> ChildProcess::Create(const CommandLine& command_line) { scoped_ptr<ChildProcess> ChildProcess::Create(
const base::CommandLine& command_line) {
if (!command_line.HasSwitch(switches::kChildProcessType)) if (!command_line.HasSwitch(switches::kChildProcessType))
return scoped_ptr<ChildProcess>(); return scoped_ptr<ChildProcess>();
......
...@@ -70,8 +70,9 @@ bool ChildProcessHost::DoLaunch() { ...@@ -70,8 +70,9 @@ bool ChildProcessHost::DoLaunch() {
switches::kVModule, switches::kVModule,
}; };
const CommandLine* parent_command_line = CommandLine::ForCurrentProcess(); const base::CommandLine* parent_command_line =
CommandLine child_command_line(parent_command_line->GetProgram()); base::CommandLine::ForCurrentProcess();
base::CommandLine child_command_line(parent_command_line->GetProgram());
child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches, child_command_line.CopySwitchesFrom(*parent_command_line, kForwardSwitches,
arraysize(kForwardSwitches)); arraysize(kForwardSwitches));
child_command_line.AppendSwitchASCII( child_command_line.AppendSwitchASCII(
......
...@@ -83,7 +83,7 @@ Context::Context() ...@@ -83,7 +83,7 @@ Context::Context()
scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()), scoped_ptr<net::NetworkDelegate>(new NetworkDelegate()),
storage_.profile_path()) { storage_.profile_path()) {
setup.Get(); setup.Get();
CommandLine* cmdline = CommandLine::ForCurrentProcess(); base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
scoped_ptr<DynamicServiceRunnerFactory> runner_factory; scoped_ptr<DynamicServiceRunnerFactory> runner_factory;
if (cmdline->HasSwitch(switches::kEnableMultiprocess)) if (cmdline->HasSwitch(switches::kEnableMultiprocess))
runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory());
......
...@@ -38,11 +38,11 @@ class TestChildProcessHostDelegate ...@@ -38,11 +38,11 @@ class TestChildProcessHostDelegate
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::AtExitManager at_exit; base::AtExitManager at_exit;
mojo::Environment env; mojo::Environment env;
CommandLine::Init(argc, argv); base::CommandLine::Init(argc, argv);
mojo::shell::InitializeLogging(); mojo::shell::InitializeLogging();
// TODO(vtl): Move this a proper test (and remove includes marked "remove"). // TODO(vtl): Move this a proper test (and remove includes marked "remove").
if (CommandLine::ForCurrentProcess()->HasSwitch("run-test-child")) { if (base::CommandLine::ForCurrentProcess()->HasSwitch("run-test-child")) {
base::MessageLoop message_loop( base::MessageLoop message_loop(
scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo()));
...@@ -61,7 +61,7 @@ int main(int argc, char** argv) { ...@@ -61,7 +61,7 @@ int main(int argc, char** argv) {
// TODO(vtl): Unify parent and child process cases to the extent possible. // TODO(vtl): Unify parent and child process cases to the extent possible.
if (scoped_ptr<mojo::shell::ChildProcess> child_process = if (scoped_ptr<mojo::shell::ChildProcess> child_process =
mojo::shell::ChildProcess::Create( mojo::shell::ChildProcess::Create(
*CommandLine::ForCurrentProcess())) { *base::CommandLine::ForCurrentProcess())) {
child_process->Main(); child_process->Main();
} else { } else {
gfx::GLSurface::InitializeOneOff(); gfx::GLSurface::InitializeOneOff();
......
...@@ -45,7 +45,7 @@ class DynamicServiceLoader::LoadContext : public mojo::shell::Loader::Delegate { ...@@ -45,7 +45,7 @@ class DynamicServiceLoader::LoadContext : public mojo::shell::Loader::Delegate {
if (url.SchemeIs("mojo")) { if (url.SchemeIs("mojo")) {
std::string origin = std::string origin =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII( base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kOrigin); switches::kOrigin);
std::string lib = MakeSharedLibraryName(url.ExtractFileName()); std::string lib = MakeSharedLibraryName(url.ExtractFileName());
url_to_load = GURL(origin + "/" + lib); url_to_load = GURL(origin + "/" + lib);
......
...@@ -77,7 +77,8 @@ scoped_ptr<Loader::Job> Loader::Load(const GURL& app_url, Delegate* delegate) { ...@@ -77,7 +77,8 @@ scoped_ptr<Loader::Job> Loader::Load(const GURL& app_url, Delegate* delegate) {
#else #else
job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get()); job->fetcher_->SaveResponseToTemporaryFile(file_runner_.get());
#endif #endif
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableCache)) if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableCache))
job->fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); job->fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
job->fetcher_->Start(); job->fetcher_->Start();
return job.Pass(); return job.Pass();
......
...@@ -19,15 +19,16 @@ namespace shell { ...@@ -19,15 +19,16 @@ namespace shell {
void Run(Context* context) { void Run(Context* context) {
KeepAlive keep_alive(context); KeepAlive keep_alive(context);
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); const base::CommandLine& command_line =
CommandLine::StringVector args = command_line.GetArgs(); *base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line.GetArgs();
if (args.empty()) { if (args.empty()) {
LOG(ERROR) << "No app path specified."; LOG(ERROR) << "No app path specified.";
return; return;
} }
for (CommandLine::StringVector::const_iterator it = args.begin(); for (base::CommandLine::StringVector::const_iterator it = args.begin();
it != args.end(); ++it) { it != args.end(); ++it) {
GURL url(*it); GURL url(*it);
if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) { if (url.scheme() == "mojo" && !command_line.HasSwitch(switches::kOrigin)) {
......
...@@ -51,7 +51,7 @@ class ShellTestHelper::TestShellClient : public ShellClient { ...@@ -51,7 +51,7 @@ class ShellTestHelper::TestShellClient : public ShellClient {
ShellTestHelper::ShellTestHelper() ShellTestHelper::ShellTestHelper()
: shell_thread_("shell_test_helper"), : shell_thread_("shell_test_helper"),
state_(NULL) { state_(NULL) {
CommandLine::Init(0, NULL); base::CommandLine::Init(0, NULL);
mojo::shell::InitializeLogging(); mojo::shell::InitializeLogging();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment