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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 | 1221 |
1222 // On Chrome OS need to pass primary user homedir (in multi-profiles session). | 1222 // On Chrome OS need to pass primary user homedir (in multi-profiles session). |
1223 base::FilePath homedir; | 1223 base::FilePath homedir; |
1224 PathService::Get(base::DIR_HOME, &homedir); | 1224 PathService::Get(base::DIR_HOME, &homedir); |
1225 command_line->AppendSwitchASCII(chromeos::switches::kHomedir, | 1225 command_line->AppendSwitchASCII(chromeos::switches::kHomedir, |
1226 homedir.value().c_str()); | 1226 homedir.value().c_str()); |
1227 #endif | 1227 #endif |
1228 | 1228 |
1229 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1229 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1230 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 1230 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
1231 if (process_type != switches::kZygoteProcess) { | 1231 if (process_type != switches::kZygoteProcess && |
| 1232 process_type != switches::kGpuProcess) { |
| 1233 // We want to pass the natives by fd because after an update the file may |
| 1234 // be updated, but we want the newly launched renderers to get the old one, |
| 1235 // opened by the browser when it started. |
| 1236 DCHECK(natives_fd_exists()); |
1232 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | 1237 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
1233 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | 1238 if (snapshot_fd_exists()) { |
| 1239 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 1240 } |
1234 } | 1241 } |
1235 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 1242 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
1236 #endif // OS_POSIX && !OS_MACOSX | 1243 #endif // OS_POSIX && !OS_MACOSX |
1237 | 1244 |
1238 if (process_type == switches::kRendererProcess) { | 1245 if (process_type == switches::kRendererProcess) { |
1239 content::RenderProcessHost* process = | 1246 content::RenderProcessHost* process = |
1240 content::RenderProcessHost::FromID(child_process_id); | 1247 content::RenderProcessHost::FromID(child_process_id); |
1241 Profile* profile = | 1248 Profile* profile = |
1242 process ? Profile::FromBrowserContext(process->GetBrowserContext()) | 1249 process ? Profile::FromBrowserContext(process->GetBrowserContext()) |
1243 : NULL; | 1250 : NULL; |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 browser_context, storage_partition_path, additional_backends); | 2225 browser_context, storage_partition_path, additional_backends); |
2219 } | 2226 } |
2220 } | 2227 } |
2221 | 2228 |
2222 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 2229 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
2223 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 2230 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
2224 const base::CommandLine& command_line, | 2231 const base::CommandLine& command_line, |
2225 int child_process_id, | 2232 int child_process_id, |
2226 FileDescriptorInfo* mappings) { | 2233 FileDescriptorInfo* mappings) { |
2227 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 2234 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
2228 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 2235 if (!natives_fd_exists()) { |
2229 int v8_natives_fd = -1; | 2236 int v8_natives_fd = -1; |
2230 int v8_snapshot_fd = -1; | 2237 int v8_snapshot_fd = -1; |
2231 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 2238 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
2232 &v8_snapshot_fd)) { | 2239 &v8_snapshot_fd)) { |
2233 v8_natives_fd_.reset(v8_natives_fd); | 2240 v8_natives_fd_.reset(v8_natives_fd); |
2234 v8_snapshot_fd_.reset(v8_snapshot_fd); | 2241 v8_snapshot_fd_.reset(v8_snapshot_fd); |
2235 } | 2242 } |
2236 } | 2243 } |
2237 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 2244 // V8 can't start up without the source of the natives, but it can |
| 2245 // start up (slower) without the snapshot. |
| 2246 DCHECK(natives_fd_exists()); |
2238 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 2247 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
2239 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 2248 if (snapshot_fd_exists()) |
| 2249 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
2240 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 2250 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
2241 | 2251 |
2242 #if defined(OS_ANDROID) | 2252 #if defined(OS_ANDROID) |
2243 base::FilePath data_path; | 2253 base::FilePath data_path; |
2244 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); | 2254 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); |
2245 DCHECK(!data_path.empty()); | 2255 DCHECK(!data_path.empty()); |
2246 | 2256 |
2247 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 2257 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
2248 base::FilePath chrome_resources_pak = | 2258 base::FilePath chrome_resources_pak = |
2249 data_path.AppendASCII("chrome_100_percent.pak"); | 2259 data_path.AppendASCII("chrome_100_percent.pak"); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 switches::kDisableWebRtcEncryption, | 2456 switches::kDisableWebRtcEncryption, |
2447 }; | 2457 }; |
2448 to_command_line->CopySwitchesFrom(from_command_line, | 2458 to_command_line->CopySwitchesFrom(from_command_line, |
2449 kWebRtcDevSwitchNames, | 2459 kWebRtcDevSwitchNames, |
2450 arraysize(kWebRtcDevSwitchNames)); | 2460 arraysize(kWebRtcDevSwitchNames)); |
2451 } | 2461 } |
2452 } | 2462 } |
2453 #endif // defined(ENABLE_WEBRTC) | 2463 #endif // defined(ENABLE_WEBRTC) |
2454 | 2464 |
2455 } // namespace chrome | 2465 } // namespace chrome |
OLD | NEW |