| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/app/mojo/mojo_init.h" | 5 #include "content/app/mojo/mojo_init.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "ipc/ipc_channel.h" | 11 #include "ipc/ipc_channel.h" |
| 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 13 | 13 |
| 14 #if defined(MOJO_SHELL_CLIENT) | 14 #if defined(MOJO_SHELL_CLIENT) |
| 15 #include "content/common/mojo/mojo_shell_connection_impl.h" | 15 #include "content/common/mojo/mojo_shell_connection_impl.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class MojoInitializer { | 22 class MojoInitializer { |
| 23 public: | 23 public: |
| 24 MojoInitializer() { | 24 MojoInitializer() { |
| 25 const base::CommandLine& command_line = | 25 const base::CommandLine& command_line = |
| 26 *base::CommandLine::ForCurrentProcess(); | 26 *base::CommandLine::ForCurrentProcess(); |
| 27 std::string process_type = |
| 28 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 29 if (0 && process_type.empty() && !command_line.HasSwitch("use-old-edk")) { |
| 30 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 31 "use-new-edk"); |
| 32 } |
| 33 |
| 27 if (command_line.HasSwitch("use-new-edk")) { | 34 if (command_line.HasSwitch("use-new-edk")) { |
| 28 bool initialize_as_parent = | 35 bool initialize_as_parent = process_type.empty(); |
| 29 command_line.GetSwitchValueASCII(switches::kProcessType).empty(); | |
| 30 #if defined(MOJO_SHELL_CLIENT) | 36 #if defined(MOJO_SHELL_CLIENT) |
| 31 if (IsRunningInMojoShell()) { | 37 if (IsRunningInMojoShell()) |
| 32 initialize_as_parent = false; | 38 initialize_as_parent = false; |
| 33 } | |
| 34 #endif | 39 #endif |
| 35 if (initialize_as_parent) { | 40 if (initialize_as_parent) { |
| 36 mojo::embedder::PreInitializeParentProcess(); | 41 mojo::embedder::PreInitializeParentProcess(); |
| 37 } else { | 42 } else { |
| 38 mojo::embedder::PreInitializeChildProcess(); | 43 mojo::embedder::PreInitializeChildProcess(); |
| 39 } | 44 } |
| 40 } | 45 } |
| 41 | 46 |
| 42 mojo::embedder::SetMaxMessageSize(IPC::Channel::kMaximumMessageSize); | 47 mojo::embedder::SetMaxMessageSize(IPC::Channel::kMaximumMessageSize); |
| 43 mojo::embedder::Init(); | 48 mojo::embedder::Init(); |
| 44 } | 49 } |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 base::LazyInstance<MojoInitializer>::Leaky mojo_initializer; | 52 base::LazyInstance<MojoInitializer>::Leaky mojo_initializer; |
| 48 | 53 |
| 49 } // namespace | 54 } // namespace |
| 50 | 55 |
| 51 void InitializeMojo() { | 56 void InitializeMojo() { |
| 52 mojo_initializer.Get(); | 57 mojo_initializer.Get(); |
| 53 } | 58 } |
| 54 | 59 |
| 55 } // namespace content | 60 } // namespace content |
| OLD | NEW |