OLD | NEW |
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 url::kDataScheme, | 199 url::kDataScheme, |
200 url::kFileScheme, | 200 url::kFileScheme, |
201 }; | 201 }; |
202 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { | 202 for (size_t i = 0; i < arraysize(kProtocolList); ++i) { |
203 if (url.scheme() == kProtocolList[i]) | 203 if (url.scheme() == kProtocolList[i]) |
204 return true; | 204 return true; |
205 } | 205 } |
206 return false; | 206 return false; |
207 } | 207 } |
208 | 208 |
| 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 |
209 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 225 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( |
210 base::CommandLine* command_line, | 226 base::CommandLine* command_line, |
211 int child_process_id) { | 227 int child_process_id) { |
212 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
213 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
214 std::string process_type = | |
215 command_line->GetSwitchValueASCII(switches::kProcessType); | |
216 if (process_type != switches::kZygoteProcess) { | |
217 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | |
218 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
219 } | |
220 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
221 #endif // OS_POSIX && !OS_MACOSX | |
222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 228 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
223 switches::kRunLayoutTest)) | 229 switches::kRunLayoutTest)) |
224 command_line->AppendSwitch(switches::kRunLayoutTest); | 230 command_line->AppendSwitch(switches::kRunLayoutTest); |
225 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
226 switches::kEnableFontAntialiasing)) | 232 switches::kEnableFontAntialiasing)) |
227 command_line->AppendSwitch(switches::kEnableFontAntialiasing); | 233 command_line->AppendSwitch(switches::kEnableFontAntialiasing); |
228 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 234 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
229 switches::kExposeInternalsForTesting)) | 235 switches::kExposeInternalsForTesting)) |
230 command_line->AppendSwitch(switches::kExposeInternalsForTesting); | 236 command_line->AppendSwitch(switches::kExposeInternalsForTesting); |
231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 237 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 nullptr, | 342 nullptr, |
337 gfx::Size())->web_contents()); | 343 gfx::Size())->web_contents()); |
338 } | 344 } |
339 | 345 |
340 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 346 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
341 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 347 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
342 const base::CommandLine& command_line, | 348 const base::CommandLine& command_line, |
343 int child_process_id, | 349 int child_process_id, |
344 FileDescriptorInfo* mappings) { | 350 FileDescriptorInfo* mappings) { |
345 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 351 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
346 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 352 if (!natives_fd_exists()) { |
347 int v8_natives_fd = -1; | 353 int v8_natives_fd = -1; |
348 int v8_snapshot_fd = -1; | 354 int v8_snapshot_fd = -1; |
349 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 355 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
350 &v8_snapshot_fd)) { | 356 &v8_snapshot_fd)) { |
351 v8_natives_fd_.reset(v8_natives_fd); | 357 v8_natives_fd_.reset(v8_natives_fd); |
352 v8_snapshot_fd_.reset(v8_snapshot_fd); | 358 v8_snapshot_fd_.reset(v8_snapshot_fd); |
353 } | 359 } |
354 } | 360 } |
355 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 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()); |
356 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 364 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
357 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 365 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
358 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 366 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
359 | 367 |
360 #if defined(OS_ANDROID) | 368 #if defined(OS_ANDROID) |
361 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 369 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
362 base::FilePath pak_file; | 370 base::FilePath pak_file; |
363 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); | 371 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); |
364 CHECK(r); | 372 CHECK(r); |
365 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); | 373 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 ShellBrowserContext* | 433 ShellBrowserContext* |
426 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( | 434 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( |
427 BrowserContext* content_browser_context) { | 435 BrowserContext* content_browser_context) { |
428 if (content_browser_context == browser_context()) | 436 if (content_browser_context == browser_context()) |
429 return browser_context(); | 437 return browser_context(); |
430 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); | 438 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); |
431 return off_the_record_browser_context(); | 439 return off_the_record_browser_context(); |
432 } | 440 } |
433 | 441 |
434 } // namespace content | 442 } // namespace content |
OLD | NEW |