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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1164483003: Allow startup with missing V8 snapshot file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix misplaced ifdef for Windows 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 (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
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
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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 browser_context, storage_partition_path, additional_backends); 2231 browser_context, storage_partition_path, additional_backends);
2215 } 2232 }
2216 } 2233 }
2217 2234
2218 #if defined(OS_POSIX) && !defined(OS_MACOSX) 2235 #if defined(OS_POSIX) && !defined(OS_MACOSX)
2219 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 2236 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
2220 const base::CommandLine& command_line, 2237 const base::CommandLine& command_line,
2221 int child_process_id, 2238 int child_process_id,
2222 FileDescriptorInfo* mappings) { 2239 FileDescriptorInfo* mappings) {
2223 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 2240 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
2224 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { 2241 if (!natives_fd_exists()) {
2225 int v8_natives_fd = -1; 2242 int v8_natives_fd = -1;
2226 int v8_snapshot_fd = -1; 2243 int v8_snapshot_fd = -1;
2227 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, 2244 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
2228 &v8_snapshot_fd)) { 2245 &v8_snapshot_fd)) {
2229 v8_natives_fd_.reset(v8_natives_fd); 2246 v8_natives_fd_.reset(v8_natives_fd);
2230 v8_snapshot_fd_.reset(v8_snapshot_fd); 2247 v8_snapshot_fd_.reset(v8_snapshot_fd);
2231 } 2248 }
2232 } 2249 }
2233 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); 2250 // V8 can't start up without the source of the natives, but it can
2251 // start up (slower) without the snapshot.
2252 DCHECK(natives_fd_exists());
2234 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 2253 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
2235 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 2254 if (snapshot_fd_exists())
2255 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
2236 #endif // V8_USE_EXTERNAL_STARTUP_DATA 2256 #endif // V8_USE_EXTERNAL_STARTUP_DATA
2237 2257
2238 #if defined(OS_ANDROID) 2258 #if defined(OS_ANDROID)
2239 base::FilePath data_path; 2259 base::FilePath data_path;
2240 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); 2260 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
2241 DCHECK(!data_path.empty()); 2261 DCHECK(!data_path.empty());
2242 2262
2243 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 2263 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
2244 base::FilePath chrome_resources_pak = 2264 base::FilePath chrome_resources_pak =
2245 data_path.AppendASCII("chrome_100_percent.pak"); 2265 data_path.AppendASCII("chrome_100_percent.pak");
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 switches::kDisableWebRtcEncryption, 2462 switches::kDisableWebRtcEncryption,
2443 }; 2463 };
2444 to_command_line->CopySwitchesFrom(from_command_line, 2464 to_command_line->CopySwitchesFrom(from_command_line,
2445 kWebRtcDevSwitchNames, 2465 kWebRtcDevSwitchNames,
2446 arraysize(kWebRtcDevSwitchNames)); 2466 arraysize(kWebRtcDevSwitchNames));
2447 } 2467 }
2448 } 2468 }
2449 #endif // defined(ENABLE_WEBRTC) 2469 #endif // defined(ENABLE_WEBRTC)
2450 2470
2451 } // namespace chrome 2471 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/plugin/chrome_content_plugin_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698