OLD | NEW |
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" | 9 #include "content/public/common/content_descriptors.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( | 36 net::URLRequestContextGetter* ShellContentBrowserClient::CreateRequestContext( |
37 content::BrowserContext* content_browser_context, | 37 content::BrowserContext* content_browser_context, |
38 content::ProtocolHandlerMap* protocol_handlers, | 38 content::ProtocolHandlerMap* protocol_handlers, |
39 content::URLRequestInterceptorScopedVector request_interceptors) { | 39 content::URLRequestInterceptorScopedVector request_interceptors) { |
40 content::ShellBrowserContext* shell_context = | 40 content::ShellBrowserContext* shell_context = |
41 static_cast<content::ShellBrowserContext*>(content_browser_context); | 41 static_cast<content::ShellBrowserContext*>(content_browser_context); |
42 return shell_context->CreateRequestContext(protocol_handlers, | 42 return shell_context->CreateRequestContext(protocol_handlers, |
43 request_interceptors.Pass()); | 43 request_interceptors.Pass()); |
44 } | 44 } |
45 | 45 |
46 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( | 46 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches( |
47 base::CommandLine* command_line, | 47 base::CommandLine* command_line) { |
48 int child_process_id) { | |
49 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 48 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
50 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 49 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
51 std::string process_type = | 50 std::string process_type = |
52 command_line->GetSwitchValueASCII(switches::kProcessType); | 51 command_line->GetSwitchValueASCII(switches::kProcessType); |
53 if (process_type != switches::kZygoteProcess) { | 52 if (process_type != switches::kZygoteProcess) { |
| 53 DCHECK(natives_fd_exists()); |
54 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | 54 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
55 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | 55 if (snapshot_fd_exists()) |
| 56 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
56 } | 57 } |
57 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 58 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
58 #endif // OS_POSIX && !OS_MACOSX | 59 #endif // OS_POSIX && !OS_MACOSX |
59 } | 60 } |
60 | 61 |
61 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 62 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
62 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 63 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
63 const base::CommandLine& command_line, | 64 const base::CommandLine& command_line, |
64 int child_process_id, | 65 int child_process_id, |
65 content::FileDescriptorInfo* mappings) { | 66 content::FileDescriptorInfo* mappings) { |
66 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 67 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
67 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 68 if (!natives_fd_exists()) { |
68 int v8_natives_fd = -1; | 69 int v8_natives_fd = -1; |
69 int v8_snapshot_fd = -1; | 70 int v8_snapshot_fd = -1; |
70 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 71 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
71 &v8_snapshot_fd)) { | 72 &v8_snapshot_fd)) { |
72 v8_natives_fd_.reset(v8_natives_fd); | 73 v8_natives_fd_.reset(v8_natives_fd); |
73 v8_snapshot_fd_.reset(v8_snapshot_fd); | 74 v8_snapshot_fd_.reset(v8_snapshot_fd); |
74 } | 75 } |
75 } | 76 } |
76 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 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()); |
77 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 80 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
78 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 81 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
79 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 82 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
80 } | 83 } |
81 #endif // OS_POSIX && !OS_MACOSX | 84 #endif // OS_POSIX && !OS_MACOSX |
82 | 85 |
83 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { | 86 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { |
84 return shell_browser_main_parts_->browser_context(); | 87 return shell_browser_main_parts_->browser_context(); |
85 } | 88 } |
86 | 89 |
87 } // namespace examples | 90 } // namespace examples |
88 } // namespace views | 91 } // namespace views |
OLD | NEW |