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

Side by Side Diff: extensions/shell/browser/shell_content_browser_client.cc

Issue 1187213002: Revert of 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: 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 | « extensions/shell/browser/shell_content_browser_client.h ('k') | gin/v8_initializer.h » ('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 "extensions/shell/browser/shell_content_browser_client.h" 5 #include "extensions/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "components/guest_view/browser/guest_view_message_filter.h" 8 #include "components/guest_view/browser/guest_view_message_filter.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 10 matching lines...) Expand all
21 #include "extensions/browser/info_map.h" 21 #include "extensions/browser/info_map.h"
22 #include "extensions/browser/io_thread_extension_message_filter.h" 22 #include "extensions/browser/io_thread_extension_message_filter.h"
23 #include "extensions/browser/process_map.h" 23 #include "extensions/browser/process_map.h"
24 #include "extensions/common/constants.h" 24 #include "extensions/common/constants.h"
25 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
26 #include "extensions/common/switches.h" 26 #include "extensions/common/switches.h"
27 #include "extensions/shell/browser/shell_browser_context.h" 27 #include "extensions/shell/browser/shell_browser_context.h"
28 #include "extensions/shell/browser/shell_browser_main_parts.h" 28 #include "extensions/shell/browser/shell_browser_main_parts.h"
29 #include "extensions/shell/browser/shell_extension_system.h" 29 #include "extensions/shell/browser/shell_extension_system.h"
30 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h" 30 #include "extensions/shell/browser/shell_speech_recognition_manager_delegate.h"
31 #include "gin/v8_initializer.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 33
33 #if !defined(DISABLE_NACL) 34 #if !defined(DISABLE_NACL)
34 #include "components/nacl/browser/nacl_browser.h" 35 #include "components/nacl/browser/nacl_browser.h"
35 #include "components/nacl/browser/nacl_host_message_filter.h" 36 #include "components/nacl/browser/nacl_host_message_filter.h"
36 #include "components/nacl/browser/nacl_process_host.h" 37 #include "components/nacl/browser/nacl_process_host.h"
37 #include "components/nacl/common/nacl_process_type.h" 38 #include "components/nacl/common/nacl_process_type.h"
38 #include "components/nacl/common/nacl_switches.h" 39 #include "components/nacl/common/nacl_switches.h"
39 #include "content/public/browser/browser_child_process_host.h" 40 #include "content/public/browser/browser_child_process_host.h"
40 #include "content/public/browser/child_process_data.h" 41 #include "content/public/browser/child_process_data.h"
41 #endif 42 #endif
42 43
43 using base::CommandLine; 44 using base::CommandLine;
44 using content::BrowserContext; 45 using content::BrowserContext;
45 using content::BrowserThread; 46 using content::BrowserThread;
46 47
47 namespace extensions { 48 namespace extensions {
48 namespace { 49 namespace {
49 50
50 ShellContentBrowserClient* g_instance = nullptr; 51 ShellContentBrowserClient* g_instance = nullptr;
51 52
52 } // namespace 53 } // namespace
53 54
54 ShellContentBrowserClient::ShellContentBrowserClient( 55 ShellContentBrowserClient::ShellContentBrowserClient(
55 ShellBrowserMainDelegate* browser_main_delegate) 56 ShellBrowserMainDelegate* browser_main_delegate)
56 : browser_main_parts_(nullptr), 57 :
58 #if defined(OS_POSIX) && !defined(OS_MACOSX)
59 v8_natives_fd_(-1),
60 v8_snapshot_fd_(-1),
61 #endif // OS_POSIX && !OS_MACOSX
62 browser_main_parts_(nullptr),
57 browser_main_delegate_(browser_main_delegate) { 63 browser_main_delegate_(browser_main_delegate) {
58 DCHECK(!g_instance); 64 DCHECK(!g_instance);
59 g_instance = this; 65 g_instance = this;
60 } 66 }
61 67
62 ShellContentBrowserClient::~ShellContentBrowserClient() { 68 ShellContentBrowserClient::~ShellContentBrowserClient() {
63 g_instance = nullptr; 69 g_instance = nullptr;
64 } 70 }
65 71
66 // static 72 // static
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 BrowserThread::PostTask( 193 BrowserThread::PostTask(
188 BrowserThread::IO, 194 BrowserThread::IO,
189 FROM_HERE, 195 FROM_HERE,
190 base::Bind(&InfoMap::UnregisterExtensionProcess, 196 base::Bind(&InfoMap::UnregisterExtensionProcess,
191 browser_main_parts_->extension_system()->info_map(), 197 browser_main_parts_->extension_system()->info_map(),
192 extension->id(), 198 extension->id(),
193 site_instance->GetProcess()->GetID(), 199 site_instance->GetProcess()->GetID(),
194 site_instance->GetId())); 200 site_instance->GetId()));
195 } 201 }
196 202
203 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches(
204 base::CommandLine* command_line) {
205 std::string process_type =
206 command_line->GetSwitchValueASCII(::switches::kProcessType);
207
208 #if defined(OS_POSIX) && !defined(OS_MACOSX)
209 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
210 DCHECK(natives_fd_exists());
211 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
212 if (snapshot_fd_exists())
213 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
214 #endif // V8_USE_EXTERNAL_STARTUP_DATA
215 #endif // OS_POSIX && !OS_MACOSX
216 }
217
197 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( 218 void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
198 base::CommandLine* command_line, 219 base::CommandLine* command_line,
199 int child_process_id) { 220 int child_process_id) {
200 std::string process_type = 221 std::string process_type =
201 command_line->GetSwitchValueASCII(::switches::kProcessType); 222 command_line->GetSwitchValueASCII(::switches::kProcessType);
202 if (process_type == ::switches::kRendererProcess) 223 if (process_type == ::switches::kRendererProcess)
203 AppendRendererSwitches(command_line); 224 AppendRendererSwitches(command_line);
204 } 225 }
205 226
206 content::SpeechRecognitionManagerDelegate* 227 content::SpeechRecognitionManagerDelegate*
(...skipping 19 matching lines...) Expand all
226 return nullptr; 247 return nullptr;
227 } 248 }
228 249
229 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( 250 void ShellContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
230 std::vector<std::string>* additional_allowed_schemes) { 251 std::vector<std::string>* additional_allowed_schemes) {
231 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem( 252 ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
232 additional_allowed_schemes); 253 additional_allowed_schemes);
233 additional_allowed_schemes->push_back(kExtensionScheme); 254 additional_allowed_schemes->push_back(kExtensionScheme);
234 } 255 }
235 256
257 #if defined(OS_POSIX) && !defined(OS_MACOSX)
258 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
259 const base::CommandLine& command_line,
260 int child_process_id,
261 content::FileDescriptorInfo* mappings) {
262 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
263 if (!natives_fd_exists()) {
264 int v8_natives_fd = -1;
265 int v8_snapshot_fd = -1;
266 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
267 &v8_snapshot_fd)) {
268 v8_natives_fd_.reset(v8_natives_fd);
269 v8_snapshot_fd_.reset(v8_snapshot_fd);
270 }
271 }
272 // V8 can't start up without the source of the natives, but it can
273 // start up (slower) without the snapshot.
274 DCHECK(natives_fd_exists());
275 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
276 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
277 #endif // V8_USE_EXTERNAL_STARTUP_DATA
278 }
279 #endif // OS_POSIX && !OS_MACOSX
280
236 content::DevToolsManagerDelegate* 281 content::DevToolsManagerDelegate*
237 ShellContentBrowserClient::GetDevToolsManagerDelegate() { 282 ShellContentBrowserClient::GetDevToolsManagerDelegate() {
238 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); 283 return new content::ShellDevToolsManagerDelegate(GetBrowserContext());
239 } 284 }
240 285
241 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts( 286 ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts(
242 const content::MainFunctionParams& parameters, 287 const content::MainFunctionParams& parameters,
243 ShellBrowserMainDelegate* browser_main_delegate) { 288 ShellBrowserMainDelegate* browser_main_delegate) {
244 return new ShellBrowserMainParts(parameters, browser_main_delegate); 289 return new ShellBrowserMainParts(parameters, browser_main_delegate);
245 } 290 }
(...skipping 18 matching lines...) Expand all
264 309
265 const Extension* ShellContentBrowserClient::GetExtension( 310 const Extension* ShellContentBrowserClient::GetExtension(
266 content::SiteInstance* site_instance) { 311 content::SiteInstance* site_instance) {
267 ExtensionRegistry* registry = 312 ExtensionRegistry* registry =
268 ExtensionRegistry::Get(site_instance->GetBrowserContext()); 313 ExtensionRegistry::Get(site_instance->GetBrowserContext());
269 return registry->enabled_extensions().GetExtensionOrAppByURL( 314 return registry->enabled_extensions().GetExtensionOrAppByURL(
270 site_instance->GetSiteURL()); 315 site_instance->GetSiteURL());
271 } 316 }
272 317
273 } // namespace extensions 318 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/browser/shell_content_browser_client.h ('k') | gin/v8_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698