| 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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 } | 1161 } |
| 1162 if (browser_command_line.HasSwitch( | 1162 if (browser_command_line.HasSwitch( |
| 1163 switches::kDisableOfflineAutoReloadVisibleOnly)) { | 1163 switches::kDisableOfflineAutoReloadVisibleOnly)) { |
| 1164 return false; | 1164 return false; |
| 1165 } | 1165 } |
| 1166 return true; | 1166 return true; |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 } // namespace | 1169 } // namespace |
| 1170 | 1170 |
| 1171 // When Chrome is updated on non-Windows platforms, the new files (like |
| 1172 // V8 natives and snapshot) can have the same names as the previous |
| 1173 // versions. Since the renderers for an existing Chrome browser process |
| 1174 // are likely not compatible with the new files, the browser keeps hold |
| 1175 // of the old files using an open fd. This fd is passed to subprocesses |
| 1176 // like renderers. Here we add the flag to tell the subprocesses where |
| 1177 // to find these file descriptors. |
| 1178 void ChromeContentBrowserClient::AppendMappedFileCommandLineSwitches( |
| 1179 base::CommandLine* command_line) { |
| 1180 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 1181 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 1182 std::string process_type = |
| 1183 command_line->GetSwitchValueASCII(switches::kProcessType); |
| 1184 if (process_type != switches::kZygoteProcess) { |
| 1185 // We want to pass the natives by fd because after an update the file may |
| 1186 // be updated, but we want the newly launched renderers to get the old one, |
| 1187 // opened by the browser when it started. |
| 1188 DCHECK(natives_fd_exists()); |
| 1189 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
| 1190 if (snapshot_fd_exists()) |
| 1191 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| 1192 } |
| 1193 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 1194 #endif // OS_POSIX && !OS_MACOSX |
| 1195 } |
| 1196 |
| 1171 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( | 1197 void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
| 1172 base::CommandLine* command_line, | 1198 base::CommandLine* command_line, |
| 1173 int child_process_id) { | 1199 int child_process_id) { |
| 1174 #if defined(OS_MACOSX) | 1200 #if defined(OS_MACOSX) |
| 1175 scoped_ptr<metrics::ClientInfo> client_info = | 1201 scoped_ptr<metrics::ClientInfo> client_info = |
| 1176 GoogleUpdateSettings::LoadMetricsClientInfo(); | 1202 GoogleUpdateSettings::LoadMetricsClientInfo(); |
| 1177 if (client_info) { | 1203 if (client_info) { |
| 1178 command_line->AppendSwitchASCII(switches::kMetricsClientID, | 1204 command_line->AppendSwitchASCII(switches::kMetricsClientID, |
| 1179 client_info->client_id); | 1205 client_info->client_id); |
| 1180 } | 1206 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 command_line->CopySwitchesFrom(browser_command_line, kChromeOSSwitches, | 1245 command_line->CopySwitchesFrom(browser_command_line, kChromeOSSwitches, |
| 1220 arraysize(kChromeOSSwitches)); | 1246 arraysize(kChromeOSSwitches)); |
| 1221 | 1247 |
| 1222 // On Chrome OS need to pass primary user homedir (in multi-profiles session). | 1248 // On Chrome OS need to pass primary user homedir (in multi-profiles session). |
| 1223 base::FilePath homedir; | 1249 base::FilePath homedir; |
| 1224 PathService::Get(base::DIR_HOME, &homedir); | 1250 PathService::Get(base::DIR_HOME, &homedir); |
| 1225 command_line->AppendSwitchASCII(chromeos::switches::kHomedir, | 1251 command_line->AppendSwitchASCII(chromeos::switches::kHomedir, |
| 1226 homedir.value().c_str()); | 1252 homedir.value().c_str()); |
| 1227 #endif | 1253 #endif |
| 1228 | 1254 |
| 1229 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 1230 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
| 1231 if (process_type != switches::kZygoteProcess) { | |
| 1232 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); | |
| 1233 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
| 1234 } | |
| 1235 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 1236 #endif // OS_POSIX && !OS_MACOSX | |
| 1237 | |
| 1238 if (process_type == switches::kRendererProcess) { | 1255 if (process_type == switches::kRendererProcess) { |
| 1239 content::RenderProcessHost* process = | 1256 content::RenderProcessHost* process = |
| 1240 content::RenderProcessHost::FromID(child_process_id); | 1257 content::RenderProcessHost::FromID(child_process_id); |
| 1241 Profile* profile = | 1258 Profile* profile = |
| 1242 process ? Profile::FromBrowserContext(process->GetBrowserContext()) | 1259 process ? Profile::FromBrowserContext(process->GetBrowserContext()) |
| 1243 : NULL; | 1260 : NULL; |
| 1244 for (size_t i = 0; i < extra_parts_.size(); ++i) { | 1261 for (size_t i = 0; i < extra_parts_.size(); ++i) { |
| 1245 extra_parts_[i]->AppendExtraRendererCommandLineSwitches( | 1262 extra_parts_[i]->AppendExtraRendererCommandLineSwitches( |
| 1246 command_line, process, profile); | 1263 command_line, process, profile); |
| 1247 } | 1264 } |
| (...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 browser_context, storage_partition_path, additional_backends); | 2235 browser_context, storage_partition_path, additional_backends); |
| 2219 } | 2236 } |
| 2220 } | 2237 } |
| 2221 | 2238 |
| 2222 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 2239 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 2223 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 2240 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
| 2224 const base::CommandLine& command_line, | 2241 const base::CommandLine& command_line, |
| 2225 int child_process_id, | 2242 int child_process_id, |
| 2226 FileDescriptorInfo* mappings) { | 2243 FileDescriptorInfo* mappings) { |
| 2227 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 2244 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 2228 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 2245 if (!natives_fd_exists()) { |
| 2229 int v8_natives_fd = -1; | 2246 int v8_natives_fd = -1; |
| 2230 int v8_snapshot_fd = -1; | 2247 int v8_snapshot_fd = -1; |
| 2231 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | 2248 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, |
| 2232 &v8_snapshot_fd)) { | 2249 &v8_snapshot_fd)) { |
| 2233 v8_natives_fd_.reset(v8_natives_fd); | 2250 v8_natives_fd_.reset(v8_natives_fd); |
| 2234 v8_snapshot_fd_.reset(v8_snapshot_fd); | 2251 v8_snapshot_fd_.reset(v8_snapshot_fd); |
| 2235 } | 2252 } |
| 2236 } | 2253 } |
| 2237 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 2254 // V8 can't start up without the source of the natives, but it can |
| 2255 // start up (slower) without the snapshot. |
| 2256 DCHECK(natives_fd_exists()); |
| 2238 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 2257 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); |
| 2239 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 2258 if (snapshot_fd_exists()) |
| 2259 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); |
| 2240 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 2260 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 2241 | 2261 |
| 2242 #if defined(OS_ANDROID) | 2262 #if defined(OS_ANDROID) |
| 2243 base::FilePath data_path; | 2263 base::FilePath data_path; |
| 2244 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); | 2264 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); |
| 2245 DCHECK(!data_path.empty()); | 2265 DCHECK(!data_path.empty()); |
| 2246 | 2266 |
| 2247 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; | 2267 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; |
| 2248 base::FilePath chrome_resources_pak = | 2268 base::FilePath chrome_resources_pak = |
| 2249 data_path.AppendASCII("chrome_100_percent.pak"); | 2269 data_path.AppendASCII("chrome_100_percent.pak"); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 switches::kDisableWebRtcEncryption, | 2466 switches::kDisableWebRtcEncryption, |
| 2447 }; | 2467 }; |
| 2448 to_command_line->CopySwitchesFrom(from_command_line, | 2468 to_command_line->CopySwitchesFrom(from_command_line, |
| 2449 kWebRtcDevSwitchNames, | 2469 kWebRtcDevSwitchNames, |
| 2450 arraysize(kWebRtcDevSwitchNames)); | 2470 arraysize(kWebRtcDevSwitchNames)); |
| 2451 } | 2471 } |
| 2452 } | 2472 } |
| 2453 #endif // defined(ENABLE_WEBRTC) | 2473 #endif // defined(ENABLE_WEBRTC) |
| 2454 | 2474 |
| 2455 } // namespace chrome | 2475 } // namespace chrome |
| OLD | NEW |