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

Side by Side Diff: extensions/shell/browser/shell_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: Feedback from sky 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_content_browser_client.h" 5 #include "extensions/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "components/guest_view/browser/guest_view_message_filter.h" 8 #include "components/guest_view/browser/guest_view_message_filter.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 BrowserThread::PostTask( 196 BrowserThread::PostTask(
197 BrowserThread::IO, 197 BrowserThread::IO,
198 FROM_HERE, 198 FROM_HERE,
199 base::Bind(&InfoMap::UnregisterExtensionProcess, 199 base::Bind(&InfoMap::UnregisterExtensionProcess,
200 browser_main_parts_->extension_system()->info_map(), 200 browser_main_parts_->extension_system()->info_map(),
201 extension->id(), 201 extension->id(),
202 site_instance->GetProcess()->GetID(), 202 site_instance->GetProcess()->GetID(),
203 site_instance->GetId())); 203 site_instance->GetId()));
204 } 204 }
205 205
206 void ShellContentBrowserClient::AppendMappedFileCommandLineSwitches(
207 base::CommandLine* command_line) {
208 std::string process_type =
209 command_line->GetSwitchValueASCII(::switches::kProcessType);
210
211 #if defined(OS_POSIX) && !defined(OS_MACOSX)
212 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
213 DCHECK(natives_fd_exists());
214 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
215 if (snapshot_fd_exists())
216 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
217 #endif // V8_USE_EXTERNAL_STARTUP_DATA
218 #endif // OS_POSIX && !OS_MACOSX
219 }
220
206 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( 221 void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
207 base::CommandLine* command_line, 222 base::CommandLine* command_line,
208 int child_process_id) { 223 int child_process_id) {
209 std::string process_type = 224 std::string process_type =
210 command_line->GetSwitchValueASCII(::switches::kProcessType); 225 command_line->GetSwitchValueASCII(::switches::kProcessType);
211
212 #if defined(OS_POSIX) && !defined(OS_MACOSX)
213 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
214 if (process_type != ::switches::kZygoteProcess) {
215 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
216 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
217 }
218 #endif // V8_USE_EXTERNAL_STARTUP_DATA
219 #endif // OS_POSIX && !OS_MACOSX
220
221 if (process_type == ::switches::kRendererProcess) 226 if (process_type == ::switches::kRendererProcess)
222 AppendRendererSwitches(command_line); 227 AppendRendererSwitches(command_line);
223 } 228 }
224 229
225 content::SpeechRecognitionManagerDelegate* 230 content::SpeechRecognitionManagerDelegate*
226 ShellContentBrowserClient::CreateSpeechRecognitionManagerDelegate() { 231 ShellContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
227 return new speech::ShellSpeechRecognitionManagerDelegate(); 232 return new speech::ShellSpeechRecognitionManagerDelegate();
228 } 233 }
229 234
230 content::BrowserPpapiHost* 235 content::BrowserPpapiHost*
(...skipping 20 matching lines...) Expand all
251 additional_allowed_schemes); 256 additional_allowed_schemes);
252 additional_allowed_schemes->push_back(kExtensionScheme); 257 additional_allowed_schemes->push_back(kExtensionScheme);
253 } 258 }
254 259
255 #if defined(OS_POSIX) && !defined(OS_MACOSX) 260 #if defined(OS_POSIX) && !defined(OS_MACOSX)
256 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 261 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
257 const base::CommandLine& command_line, 262 const base::CommandLine& command_line,
258 int child_process_id, 263 int child_process_id,
259 content::FileDescriptorInfo* mappings) { 264 content::FileDescriptorInfo* mappings) {
260 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 265 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
261 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { 266 if (!natives_fd_exists()) {
262 int v8_natives_fd = -1; 267 int v8_natives_fd = -1;
263 int v8_snapshot_fd = -1; 268 int v8_snapshot_fd = -1;
264 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, 269 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
265 &v8_snapshot_fd)) { 270 &v8_snapshot_fd)) {
266 v8_natives_fd_.reset(v8_natives_fd); 271 v8_natives_fd_.reset(v8_natives_fd);
267 v8_snapshot_fd_.reset(v8_snapshot_fd); 272 v8_snapshot_fd_.reset(v8_snapshot_fd);
268 } 273 }
269 } 274 }
270 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); 275 // V8 can't start up without the source of the natives, but it can
276 // start up (slower) without the snapshot.
277 DCHECK(natives_fd_exists());
271 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 278 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
272 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 279 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
273 #endif // V8_USE_EXTERNAL_STARTUP_DATA 280 #endif // V8_USE_EXTERNAL_STARTUP_DATA
274 } 281 }
275 #endif // OS_POSIX && !OS_MACOSX 282 #endif // OS_POSIX && !OS_MACOSX
276 283
277 content::DevToolsManagerDelegate* 284 content::DevToolsManagerDelegate*
278 ShellContentBrowserClient::GetDevToolsManagerDelegate() { 285 ShellContentBrowserClient::GetDevToolsManagerDelegate() {
279 return new content::ShellDevToolsManagerDelegate(GetBrowserContext()); 286 return new content::ShellDevToolsManagerDelegate(GetBrowserContext());
280 } 287 }
(...skipping 24 matching lines...) Expand all
305 312
306 const Extension* ShellContentBrowserClient::GetExtension( 313 const Extension* ShellContentBrowserClient::GetExtension(
307 content::SiteInstance* site_instance) { 314 content::SiteInstance* site_instance) {
308 ExtensionRegistry* registry = 315 ExtensionRegistry* registry =
309 ExtensionRegistry::Get(site_instance->GetBrowserContext()); 316 ExtensionRegistry::Get(site_instance->GetBrowserContext());
310 return registry->enabled_extensions().GetExtensionOrAppByURL( 317 return registry->enabled_extensions().GetExtensionOrAppByURL(
311 site_instance->GetSiteURL()); 318 site_instance->GetSiteURL());
312 } 319 }
313 320
314 } // namespace extensions 321 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698