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

Side by Side Diff: ash/shell/content_client/shell_content_browser_client.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 | « ash/shell/content_client/shell_content_browser_client.h ('k') | base/i18n/icu_util.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ash/shell/content_client/shell_content_browser_client.h" 5 #include "ash/shell/content_client/shell_content_browser_client.h"
6 6
7 #include "ash/shell/content_client/shell_browser_main_parts.h" 7 #include "ash/shell/content_client/shell_browser_main_parts.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/public/common/content_descriptors.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/shell/browser/shell_browser_context.h" 9 #include "content/shell/browser/shell_browser_context.h"
12 #include "gin/v8_initializer.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
14 11
15 namespace ash { 12 namespace ash {
16 namespace shell { 13 namespace shell {
17 14
18 ShellContentBrowserClient::ShellContentBrowserClient() 15 ShellContentBrowserClient::ShellContentBrowserClient()
19 : 16 : shell_browser_main_parts_(nullptr) {
20 #if defined(OS_POSIX) && !defined(OS_MACOSX)
21 v8_natives_fd_(-1),
22 v8_snapshot_fd_(-1),
23 #endif // OS_POSIX && !OS_MACOSX
24 shell_browser_main_parts_(nullptr) {
25 } 17 }
26 18
27 ShellContentBrowserClient::~ShellContentBrowserClient() { 19 ShellContentBrowserClient::~ShellContentBrowserClient() {
28 } 20 }
29 21
30 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( 22 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
31 const content::MainFunctionParams& parameters) { 23 const content::MainFunctionParams& parameters) {
32 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); 24 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);
33 return shell_browser_main_parts_; 25 return shell_browser_main_parts_;
34 } 26 }
35 27
36 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( 28 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext(
37 content::BrowserContext* content_browser_context, 29 content::BrowserContext* content_browser_context,
38 content::ProtocolHandlerMap* protocol_handlers, 30 content::ProtocolHandlerMap* protocol_handlers,
39 content::URLRequestInterceptorScopedVector request_interceptors) { 31 content::URLRequestInterceptorScopedVector request_interceptors) {
40 content::ShellBrowserContext* shell_context = 32 content::ShellBrowserContext* shell_context =
41 static_cast<content::ShellBrowserContext*>(content_browser_context); 33 static_cast<content::ShellBrowserContext*>(content_browser_context);
42 return shell_context->CreateRequestContext(protocol_handlers, 34 return shell_context->CreateRequestContext(protocol_handlers,
43 request_interceptors.Pass()); 35 request_interceptors.Pass());
44 } 36 }
45 37
46 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches(
47 base::CommandLine* command_line) {
48 #if defined(OS_POSIX) && !defined(OS_MACOSX)
49 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
50 std::string process_type =
51 command_line->GetSwitchValueASCII(switches::kProcessType);
52 if (process_type != switches::kZygoteProcess) {
53 DCHECK(natives_fd_exists());
54 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
55 if (snapshot_fd_exists())
56 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
57 }
58 #endif // V8_USE_EXTERNAL_STARTUP_DATA
59 #endif // OS_POSIX && !OS_MACOSX
60 }
61
62 #if defined(OS_POSIX) && !defined(OS_MACOSX)
63 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
64 const base::CommandLine& command_line,
65 int child_process_id,
66 content::FileDescriptorInfo* mappings) {
67 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
68 if (!natives_fd_exists()) {
69 int v8_natives_fd = -1;
70 int v8_snapshot_fd = -1;
71 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
72 &v8_snapshot_fd)) {
73 v8_natives_fd_.reset(v8_natives_fd);
74 v8_snapshot_fd_.reset(v8_snapshot_fd);
75 }
76 }
77 // V8 can't start up without the source of the natives, but it can
78 // start up (slower) without the snapshot.
79 DCHECK(natives_fd_exists());
80 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
81 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
82 #endif // V8_USE_EXTERNAL_STARTUP_DATA
83 }
84 #endif // OS_POSIX && !OS_MACOSX
85
86 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { 38 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() {
87 return shell_browser_main_parts_->browser_context(); 39 return shell_browser_main_parts_->browser_context();
88 } 40 }
89 41
90 } // namespace examples 42 } // namespace examples
91 } // namespace views 43 } // namespace views
OLDNEW
« no previous file with comments | « ash/shell/content_client/shell_content_browser_client.h ('k') | base/i18n/icu_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698