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

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 tot 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
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 // ICU data is a thing every part of the system needs. This here warms
298 // up the copy of ICU in the mojo runner.
299 base::i18n::InitializeICU();
sky 2015/11/05 03:40:17 Is there a way this could be optional? Seems sad t
300 CallLibraryEarlyInitialization(app_library);
301
295 #if defined(OS_LINUX) && !defined(OS_ANDROID) 302 #if defined(OS_LINUX) && !defined(OS_ANDROID)
296 if (command_line.HasSwitch(switches::kEnableSandbox)) { 303 if (command_line.HasSwitch(switches::kEnableSandbox)) {
297 // Warm parts of base. 304 // Warm parts of base in the copy of base in the mojo runner.
298 base::RandUint64(); 305 base::RandUint64();
299 base::SysInfo::AmountOfPhysicalMemory(); 306 base::SysInfo::AmountOfPhysicalMemory();
300 base::SysInfo::MaxSharedMemorySize(); 307 base::SysInfo::MaxSharedMemorySize();
301 base::SysInfo::NumberOfProcessors(); 308 base::SysInfo::NumberOfProcessors();
302 309
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 310 // 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 311 // 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 312 // so that we have some sandbox until we have proper shared memory
314 // support integrated into mojo. 313 // support integrated into mojo.
315 std::vector<BrokerFilePermission> permissions; 314 std::vector<BrokerFilePermission> permissions;
316 permissions.push_back( 315 permissions.push_back(
317 BrokerFilePermission::ReadWriteCreateUnlinkRecursive("/dev/shm/")); 316 BrokerFilePermission::ReadWriteCreateUnlinkRecursive("/dev/shm/"));
318 sandbox.reset(new mandoline::LinuxSandbox(permissions)); 317 sandbox.reset(new mandoline::LinuxSandbox(permissions));
319 sandbox->Warmup(); 318 sandbox->Warmup();
320 sandbox->EngageNamespaceSandbox(); 319 sandbox->EngageNamespaceSandbox();
(...skipping 22 matching lines...) Expand all
343 // This will block, then run whatever the controller wants. 342 // This will block, then run whatever the controller wants.
344 blocker.Block(); 343 blocker.Block();
345 344
346 app_context.Shutdown(); 345 app_context.Shutdown();
347 346
348 return 0; 347 return 0;
349 } 348 }
350 349
351 } // namespace runner 350 } // namespace runner
352 } // namespace mojo 351 } // namespace mojo
OLDNEW
« base/i18n/icu_util.h ('K') | « mojo/runner/BUILD.gn ('k') | mojo/runner/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698