OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "services/shell/runner/host/child_process.h" | |
6 | |
7 #include <stdint.h> | |
8 | |
9 #include <memory> | |
10 #include <utility> | |
11 | |
12 #include "base/base_switches.h" | |
13 #include "base/bind.h" | |
14 #include "base/callback_helpers.h" | |
15 #include "base/command_line.h" | |
16 #include "base/files/file_path.h" | |
17 #include "base/i18n/icu_util.h" | |
18 #include "base/location.h" | |
19 #include "base/logging.h" | |
20 #include "base/macros.h" | |
21 #include "base/memory/ref_counted.h" | |
22 #include "base/message_loop/message_loop.h" | |
23 #include "base/single_thread_task_runner.h" | |
24 #include "base/synchronization/waitable_event.h" | |
25 #include "base/threading/thread.h" | |
26 #include "base/threading/thread_checker.h" | |
27 #include "base/threading/thread_task_runner_handle.h" | |
28 #include "mojo/edk/embedder/embedder.h" | |
29 #include "mojo/edk/embedder/platform_channel_pair.h" | |
30 #include "mojo/edk/embedder/process_delegate.h" | |
31 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
32 #include "mojo/public/cpp/bindings/binding.h" | |
33 #include "mojo/public/cpp/system/core.h" | |
34 #include "services/shell/runner/common/switches.h" | |
35 #include "services/shell/runner/host/child_process_base.h" | |
36 #include "services/shell/runner/host/native_library_runner.h" | |
37 #include "services/shell/runner/init.h" | |
38 | |
39 namespace shell { | |
40 | |
41 namespace { | |
42 | |
43 void RunNativeLibrary(base::NativeLibrary library, | |
44 mojom::ServiceRequest service_request) { | |
45 if (!RunServiceInNativeLibrary(library, std::move(service_request))) { | |
46 LOG(ERROR) << "Failure to RunServiceInNativeLibrary()"; | |
47 } | |
48 } | |
49 | |
50 } // namespace | |
51 | |
52 int ChildProcessMain() { | |
53 DVLOG(2) << "ChildProcessMain()"; | |
54 const base::CommandLine& command_line = | |
55 *base::CommandLine::ForCurrentProcess(); | |
56 | |
57 base::NativeLibrary library = 0; | |
58 // Load the application library before we engage the sandbox. | |
59 base::FilePath library_path = | |
60 command_line.GetSwitchValuePath(switches::kChildProcess); | |
61 if (!library_path.empty()) | |
62 library = LoadNativeLibrary(library_path); | |
63 base::i18n::InitializeICU(); | |
64 if (library) | |
65 CallLibraryEarlyInitialization(library); | |
66 | |
67 ChildProcessMainWithCallback(base::Bind(&RunNativeLibrary, library)); | |
68 | |
69 return 0; | |
70 } | |
71 | |
72 } // namespace shell | |
OLD | NEW |