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

Side by Side Diff: content/shell/browser/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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shell/browser/shell_content_browser_client.h" 5 #include "content/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/shell/browser/shell_browser_context.h" 27 #include "content/shell/browser/shell_browser_context.h"
28 #include "content/shell/browser/shell_browser_main_parts.h" 28 #include "content/shell/browser/shell_browser_main_parts.h"
29 #include "content/shell/browser/shell_devtools_manager_delegate.h" 29 #include "content/shell/browser/shell_devtools_manager_delegate.h"
30 #include "content/shell/browser/shell_net_log.h" 30 #include "content/shell/browser/shell_net_log.h"
31 #include "content/shell/browser/shell_quota_permission_context.h" 31 #include "content/shell/browser/shell_quota_permission_context.h"
32 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" 32 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h"
33 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h" 33 #include "content/shell/browser/shell_web_contents_view_delegate_creator.h"
34 #include "content/shell/common/shell_messages.h" 34 #include "content/shell/common/shell_messages.h"
35 #include "content/shell/common/shell_switches.h" 35 #include "content/shell/common/shell_switches.h"
36 #include "content/shell/renderer/layout_test/blink_test_helpers.h" 36 #include "content/shell/renderer/layout_test/blink_test_helpers.h"
37 #include "gin/v8_initializer.h"
38 #include "net/url_request/url_request_context_getter.h" 37 #include "net/url_request/url_request_context_getter.h"
39 #include "url/gurl.h" 38 #include "url/gurl.h"
40 39
41 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
42 #include "base/android/path_utils.h" 41 #include "base/android/path_utils.h"
43 #include "components/crash/browser/crash_dump_manager_android.h" 42 #include "components/crash/browser/crash_dump_manager_android.h"
44 #include "content/shell/android/shell_descriptors.h" 43 #include "content/shell/android/shell_descriptors.h"
45 #endif 44 #endif
46 45
47 #if defined(OS_POSIX) && !defined(OS_MACOSX) 46 #if defined(OS_POSIX) && !defined(OS_MACOSX)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 121
123 ShellContentBrowserClient* ShellContentBrowserClient::Get() { 122 ShellContentBrowserClient* ShellContentBrowserClient::Get() {
124 return g_browser_client; 123 return g_browser_client;
125 } 124 }
126 125
127 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) { 126 void ShellContentBrowserClient::SetSwapProcessesForRedirect(bool swap) {
128 g_swap_processes_for_redirect = swap; 127 g_swap_processes_for_redirect = swap;
129 } 128 }
130 129
131 ShellContentBrowserClient::ShellContentBrowserClient() 130 ShellContentBrowserClient::ShellContentBrowserClient()
132 : 131 : shell_browser_main_parts_(NULL) {
133 #if defined(OS_POSIX) && !defined(OS_MACOSX)
134 v8_natives_fd_(-1),
135 v8_snapshot_fd_(-1),
136 #endif // OS_POSIX && !OS_MACOSX
137 shell_browser_main_parts_(NULL) {
138 DCHECK(!g_browser_client); 132 DCHECK(!g_browser_client);
139 g_browser_client = this; 133 g_browser_client = this;
140 } 134 }
141 135
142 ShellContentBrowserClient::~ShellContentBrowserClient() { 136 ShellContentBrowserClient::~ShellContentBrowserClient() {
143 g_browser_client = NULL; 137 g_browser_client = NULL;
144 } 138 }
145 139
146 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( 140 BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
147 const MainFunctionParams& parameters) { 141 const MainFunctionParams& parameters) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 url::kDataScheme, 193 url::kDataScheme,
200 url::kFileScheme, 194 url::kFileScheme,
201 }; 195 };
202 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { 196 for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
203 if (url.scheme() == kProtocolList[i]) 197 if (url.scheme() == kProtocolList[i])
204 return true; 198 return true;
205 } 199 }
206 return false; 200 return false;
207 } 201 }
208 202
209 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches(
210 base::CommandLine* command_line) {
211 #if defined(OS_POSIX) && !defined(OS_MACOSX)
212 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
213 std::string process_type =
214 command_line->GetSwitchValueASCII(switches::kProcessType);
215 if (process_type != switches::kZygoteProcess) {
216 DCHECK(natives_fd_exists());
217 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
218 if (snapshot_fd_exists())
219 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
220 }
221 #endif // V8_USE_EXTERNAL_STARTUP_DATA
222 #endif // OS_POSIX && !OS_MACOSX
223 }
224
225 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( 203 void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
226 base::CommandLine* command_line, 204 base::CommandLine* command_line,
227 int child_process_id) { 205 int child_process_id) {
228 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 206 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
229 switches::kRunLayoutTest)) 207 switches::kRunLayoutTest))
230 command_line->AppendSwitch(switches::kRunLayoutTest); 208 command_line->AppendSwitch(switches::kRunLayoutTest);
231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 209 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
232 switches::kEnableFontAntialiasing)) 210 switches::kEnableFontAntialiasing))
233 command_line->AppendSwitch(switches::kEnableFontAntialiasing); 211 command_line->AppendSwitch(switches::kEnableFontAntialiasing);
234 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 212 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 params.url, 319 params.url,
342 nullptr, 320 nullptr,
343 gfx::Size())->web_contents()); 321 gfx::Size())->web_contents());
344 } 322 }
345 323
346 #if defined(OS_POSIX) && !defined(OS_MACOSX) 324 #if defined(OS_POSIX) && !defined(OS_MACOSX)
347 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 325 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
348 const base::CommandLine& command_line, 326 const base::CommandLine& command_line,
349 int child_process_id, 327 int child_process_id,
350 FileDescriptorInfo* mappings) { 328 FileDescriptorInfo* mappings) {
351 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
352 if (!natives_fd_exists()) {
353 int v8_natives_fd = -1;
354 int v8_snapshot_fd = -1;
355 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
356 &v8_snapshot_fd)) {
357 v8_natives_fd_.reset(v8_natives_fd);
358 v8_snapshot_fd_.reset(v8_snapshot_fd);
359 }
360 }
361 // V8 can't start up without the source of the natives, but it can
362 // start up (slower) without the snapshot.
363 DCHECK(natives_fd_exists());
364 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
365 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
366 #endif // V8_USE_EXTERNAL_STARTUP_DATA
367
368 #if defined(OS_ANDROID) 329 #if defined(OS_ANDROID)
369 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 330 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
370 base::FilePath pak_file; 331 base::FilePath pak_file;
371 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); 332 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
372 CHECK(r); 333 CHECK(r);
373 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); 334 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
374 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); 335 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak"));
375 336
376 base::File f(pak_file, flags); 337 base::File f(pak_file, flags);
377 if (!f.IsValid()) { 338 if (!f.IsValid()) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 ShellBrowserContext* 394 ShellBrowserContext*
434 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 395 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
435 BrowserContext* content_browser_context) { 396 BrowserContext* content_browser_context) {
436 if (content_browser_context == browser_context()) 397 if (content_browser_context == browser_context())
437 return browser_context(); 398 return browser_context();
438 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 399 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
439 return off_the_record_browser_context(); 400 return off_the_record_browser_context();
440 } 401 }
441 402
442 } // namespace content 403 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_content_browser_client.h ('k') | extensions/shell/browser/shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698