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

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 1182443003: Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix lin Created 5 years, 6 months 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 | « content/browser/DEPS ('k') | content/content_browser.gypi » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/browser/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/i18n/icu_util.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/process/process.h" 14 #include "base/process/process.h"
14 #include "base/profiler/scoped_tracker.h" 15 #include "base/profiler/scoped_tracker.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/common/content_descriptors.h" 19 #include "content/public/common/content_descriptors.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
(...skipping 16 matching lines...) Expand all
36 #include "base/memory/shared_memory.h" 37 #include "base/memory/shared_memory.h"
37 #include "base/memory/singleton.h" 38 #include "base/memory/singleton.h"
38 #include "content/browser/renderer_host/render_sandbox_host_linux.h" 39 #include "content/browser/renderer_host/render_sandbox_host_linux.h"
39 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 40 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
40 #include "content/common/child_process_sandbox_support_impl_linux.h" 41 #include "content/common/child_process_sandbox_support_impl_linux.h"
41 #endif 42 #endif
42 43
43 #if defined(OS_POSIX) 44 #if defined(OS_POSIX)
44 #include "base/posix/global_descriptors.h" 45 #include "base/posix/global_descriptors.h"
45 #include "content/browser/file_descriptor_info_impl.h" 46 #include "content/browser/file_descriptor_info_impl.h"
47 #include "gin/v8_initializer.h"
46 #endif 48 #endif
47 49
48 namespace content { 50 namespace content {
49 51
50 namespace { 52 namespace {
51 53
52 typedef base::Callback<void(bool, 54 typedef base::Callback<void(bool,
53 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
54 base::ScopedFD, 56 base::ScopedFD,
55 #endif 57 #endif
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 scoped_ptr<FileDescriptorInfo> files_to_register( 136 scoped_ptr<FileDescriptorInfo> files_to_register(
135 FileDescriptorInfoImpl::Create()); 137 FileDescriptorInfoImpl::Create());
136 138
137 #if defined(OS_ANDROID) 139 #if defined(OS_ANDROID)
138 files_to_register->Share(kPrimaryIPCChannel, ipcfd.get()); 140 files_to_register->Share(kPrimaryIPCChannel, ipcfd.get());
139 #else 141 #else
140 files_to_register->Transfer(kPrimaryIPCChannel, ipcfd.Pass()); 142 files_to_register->Transfer(kPrimaryIPCChannel, ipcfd.Pass());
141 #endif 143 #endif
142 #endif 144 #endif
143 145
146 #if defined(OS_POSIX) && !defined(OS_MACOSX)
147 std::map<int, base::MemoryMappedFile::Region> regions;
148 GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
149 *cmd_line, child_process_id, files_to_register.get());
150 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
151 base::PlatformFile natives_pf =
152 gin::V8Initializer::GetOpenNativesFileForChildProcesses(
153 &regions[kV8NativesDataDescriptor]);
154 DCHECK_GE(natives_pf, 0);
155 files_to_register->Share(kV8NativesDataDescriptor, natives_pf);
156
157 base::MemoryMappedFile::Region snapshot_region;
158 base::PlatformFile snapshot_pf =
159 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(
160 &snapshot_region);
161 // Failure to load the V8 snapshot is not necessarily an error. V8 can start
162 // up (slower) without the snapshot.
163 if (snapshot_pf != -1) {
164 files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf);
165 regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region));
166 }
167
168 if (process_type != switches::kZygoteProcess) {
169 cmd_line->AppendSwitch(::switches::kV8NativesPassedByFD);
170 if (snapshot_pf != -1) {
171 cmd_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
172 }
173 }
174 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA)
175 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
176
144 #if defined(OS_ANDROID) 177 #if defined(OS_ANDROID)
178 files_to_register->Share(
179 kAndroidICUDataDescriptor,
180 base::i18n::GetIcuDataFileHandle(&regions[kAndroidICUDataDescriptor]));
181
145 // Android WebView runs in single process, ensure that we never get here 182 // Android WebView runs in single process, ensure that we never get here
146 // when running in single process mode. 183 // when running in single process mode.
147 CHECK(!cmd_line->HasSwitch(switches::kSingleProcess)); 184 CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
148 std::map<int, base::MemoryMappedFile::Region> regions;
149 GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
150 *cmd_line, child_process_id, files_to_register.get());
151
152 GetContentClient()->browser()->AppendMappedFileCommandLineSwitches(cmd_line);
153 185
154 StartChildProcess( 186 StartChildProcess(
155 cmd_line->argv(), child_process_id, files_to_register.Pass(), regions, 187 cmd_line->argv(), child_process_id, files_to_register.Pass(), regions,
156 base::Bind(&OnChildProcessStartedAndroid, callback, client_thread_id, 188 base::Bind(&OnChildProcessStartedAndroid, callback, client_thread_id,
157 begin_launch_time, base::Passed(&ipcfd))); 189 begin_launch_time, base::Passed(&ipcfd)));
158 190
159 #elif defined(OS_POSIX) 191 #elif defined(OS_POSIX)
160 // We need to close the client end of the IPC channel to reliably detect 192 // We need to close the client end of the IPC channel to reliably detect
161 // child termination. 193 // child termination.
162 194
163 #if !defined(OS_MACOSX) 195 #if !defined(OS_MACOSX)
164 GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
165 *cmd_line, child_process_id, files_to_register.get());
166
167 GetContentClient()->browser()->AppendMappedFileCommandLineSwitches(cmd_line);
168
169 if (use_zygote) { 196 if (use_zygote) {
170 base::ProcessHandle handle = ZygoteHostImpl::GetInstance()->ForkRequest( 197 base::ProcessHandle handle = ZygoteHostImpl::GetInstance()->ForkRequest(
171 cmd_line->argv(), files_to_register.Pass(), process_type); 198 cmd_line->argv(), files_to_register.Pass(), process_type);
172 process = base::Process(handle); 199 process = base::Process(handle);
173 } else 200 } else
174 // Fall through to the normal posix case below when we're not zygoting. 201 // Fall through to the normal posix case below when we're not zygoting.
175 #endif // !defined(OS_MACOSX) 202 #endif // !defined(OS_MACOSX)
176 { 203 {
177 // Convert FD mapping to FileHandleMappingVector 204 // Convert FD mapping to FileHandleMappingVector
178 base::FileHandleMappingVector fds_to_map = 205 base::FileHandleMappingVector fds_to_map =
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 537 }
511 538
512 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 539 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
513 Client* client) { 540 Client* client) {
514 Client* ret = client_; 541 Client* ret = client_;
515 client_ = client; 542 client_ = client;
516 return ret; 543 return ret;
517 } 544 }
518 545
519 } // namespace content 546 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/DEPS ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698