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

Side by Side Diff: mojo/runner/child_process.cc

Issue 1425853003: mandoline: Fix ICU initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to to Created 5 years, 1 month 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 | « mojo/runner/BUILD.gn ('k') | mojo/runner/context.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 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 "mojo/runner/child_process.h" 5 #include "mojo/runner/child_process.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/i18n/icu_util.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
20 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "base/threading/thread_checker.h" 23 #include "base/threading/thread_checker.h"
23 #include "mojo/message_pump/message_pump_mojo.h" 24 #include "mojo/message_pump/message_pump_mojo.h"
24 #include "mojo/public/cpp/bindings/binding.h" 25 #include "mojo/public/cpp/bindings/binding.h"
25 #include "mojo/public/cpp/system/core.h" 26 #include "mojo/public/cpp/system/core.h"
26 #include "mojo/runner/child/child_controller.mojom.h" 27 #include "mojo/runner/child/child_controller.mojom.h"
28 #include "mojo/runner/init.h"
27 #include "mojo/runner/native_application_support.h" 29 #include "mojo/runner/native_application_support.h"
28 #include "mojo/runner/switches.h" 30 #include "mojo/runner/switches.h"
29 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" 31 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
30 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" 32 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h"
31 #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" 33 #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h"
32 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h" 34 #include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
33 35
34 #if defined(OS_LINUX) && !defined(OS_ANDROID) 36 #if defined(OS_LINUX) && !defined(OS_ANDROID)
35 #include "base/rand_util.h" 37 #include "base/rand_util.h"
36 #include "base/sys_info.h" 38 #include "base/sys_info.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 #if defined(OS_LINUX) && !defined(OS_ANDROID) 287 #if defined(OS_LINUX) && !defined(OS_ANDROID)
286 using sandbox::syscall_broker::BrokerFilePermission; 288 using sandbox::syscall_broker::BrokerFilePermission;
287 scoped_ptr<mandoline::LinuxSandbox> sandbox; 289 scoped_ptr<mandoline::LinuxSandbox> sandbox;
288 #endif 290 #endif
289 base::NativeLibrary app_library = 0; 291 base::NativeLibrary app_library = 0;
290 if (command_line.HasSwitch(switches::kChildProcess)) { 292 if (command_line.HasSwitch(switches::kChildProcess)) {
291 // Load the application library before we engage the sandbox. 293 // Load the application library before we engage the sandbox.
292 app_library = mojo::runner::LoadNativeApplication( 294 app_library = mojo::runner::LoadNativeApplication(
293 command_line.GetSwitchValuePath(switches::kChildProcess)); 295 command_line.GetSwitchValuePath(switches::kChildProcess));
294 296
297 base::i18n::InitializeICU();
298 CallLibraryEarlyInitialization(app_library);
299
295 #if defined(OS_LINUX) && !defined(OS_ANDROID) 300 #if defined(OS_LINUX) && !defined(OS_ANDROID)
296 if (command_line.HasSwitch(switches::kEnableSandbox)) { 301 if (command_line.HasSwitch(switches::kEnableSandbox)) {
297 // Warm parts of base. 302 // Warm parts of base in the copy of base in the mojo runner.
298 base::RandUint64(); 303 base::RandUint64();
299 base::SysInfo::AmountOfPhysicalMemory(); 304 base::SysInfo::AmountOfPhysicalMemory();
300 base::SysInfo::MaxSharedMemorySize(); 305 base::SysInfo::MaxSharedMemorySize();
301 base::SysInfo::NumberOfProcessors(); 306 base::SysInfo::NumberOfProcessors();
302 307
303 // Do whatever warming that the mojo application wants.
304 typedef void (*SandboxWarmFunction)();
305 SandboxWarmFunction sandbox_warm = reinterpret_cast<SandboxWarmFunction>(
306 base::GetFunctionPointerFromNativeLibrary(app_library,
307 "MojoSandboxWarm"));
308 if (sandbox_warm)
309 sandbox_warm();
310
311 // TODO(erg,jln): Allowing access to all of /dev/shm/ makes it easy to 308 // TODO(erg,jln): Allowing access to all of /dev/shm/ makes it easy to
312 // spy on other shared memory using processes. This is a temporary hack 309 // spy on other shared memory using processes. This is a temporary hack
313 // so that we have some sandbox until we have proper shared memory 310 // so that we have some sandbox until we have proper shared memory
314 // support integrated into mojo. 311 // support integrated into mojo.
315 std::vector<BrokerFilePermission> permissions; 312 std::vector<BrokerFilePermission> permissions;
316 permissions.push_back( 313 permissions.push_back(
317 BrokerFilePermission::ReadWriteCreateUnlinkRecursive("/dev/shm/")); 314 BrokerFilePermission::ReadWriteCreateUnlinkRecursive("/dev/shm/"));
318 sandbox.reset(new mandoline::LinuxSandbox(permissions)); 315 sandbox.reset(new mandoline::LinuxSandbox(permissions));
319 sandbox->Warmup(); 316 sandbox->Warmup();
320 sandbox->EngageNamespaceSandbox(); 317 sandbox->EngageNamespaceSandbox();
(...skipping 22 matching lines...) Expand all
343 // This will block, then run whatever the controller wants. 340 // This will block, then run whatever the controller wants.
344 blocker.Block(); 341 blocker.Block();
345 342
346 app_context.Shutdown(); 343 app_context.Shutdown();
347 344
348 return 0; 345 return 0;
349 } 346 }
350 347
351 } // namespace runner 348 } // namespace runner
352 } // namespace mojo 349 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/BUILD.gn ('k') | mojo/runner/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698