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

Side by Side Diff: content/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: Add natives_fd_exists and snapshot_fd_exists instead of checking for -1 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/shell_content_browser_client.h" 5 #include "content/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 void ShellContentBrowserClient::AppendExtraCommandLineSwitches( 209 void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
210 base::CommandLine* command_line, 210 base::CommandLine* command_line,
211 int child_process_id) { 211 int child_process_id) {
212 #if defined(OS_POSIX) && !defined(OS_MACOSX) 212 #if defined(OS_POSIX) && !defined(OS_MACOSX)
213 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 213 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
214 std::string process_type = 214 std::string process_type =
215 command_line->GetSwitchValueASCII(switches::kProcessType); 215 command_line->GetSwitchValueASCII(switches::kProcessType);
216 if (process_type != switches::kZygoteProcess) { 216 if (process_type != switches::kZygoteProcess) {
217 command_line->AppendSwitch(::switches::kV8NativesPassedByFD); 217 if (natives_fd_exists()) {
218 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); 218 command_line->AppendSwitch(::switches::kV8NativesPassedByFD);
219 }
220 if (snapshot_fd_exists()) {
221 command_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
222 }
219 } 223 }
220 #endif // V8_USE_EXTERNAL_STARTUP_DATA 224 #endif // V8_USE_EXTERNAL_STARTUP_DATA
221 #endif // OS_POSIX && !OS_MACOSX 225 #endif // OS_POSIX && !OS_MACOSX
222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 226 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
223 switches::kRunLayoutTest)) 227 switches::kRunLayoutTest))
224 command_line->AppendSwitch(switches::kRunLayoutTest); 228 command_line->AppendSwitch(switches::kRunLayoutTest);
225 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 229 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
226 switches::kEnableFontAntialiasing)) 230 switches::kEnableFontAntialiasing))
227 command_line->AppendSwitch(switches::kEnableFontAntialiasing); 231 command_line->AppendSwitch(switches::kEnableFontAntialiasing);
228 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 nullptr, 340 nullptr,
337 gfx::Size())->web_contents()); 341 gfx::Size())->web_contents());
338 } 342 }
339 343
340 #if defined(OS_POSIX) && !defined(OS_MACOSX) 344 #if defined(OS_POSIX) && !defined(OS_MACOSX)
341 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 345 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
342 const base::CommandLine& command_line, 346 const base::CommandLine& command_line,
343 int child_process_id, 347 int child_process_id,
344 FileDescriptorInfo* mappings) { 348 FileDescriptorInfo* mappings) {
345 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 349 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
346 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { 350 if (!natives_fd_exists()) {
347 int v8_natives_fd = -1; 351 int v8_natives_fd = -1;
348 int v8_snapshot_fd = -1; 352 int v8_snapshot_fd = -1;
349 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, 353 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
350 &v8_snapshot_fd)) { 354 &v8_snapshot_fd)) {
351 v8_natives_fd_.reset(v8_natives_fd); 355 v8_natives_fd_.reset(v8_natives_fd);
352 v8_snapshot_fd_.reset(v8_snapshot_fd); 356 v8_snapshot_fd_.reset(v8_snapshot_fd);
353 } 357 }
354 } 358 }
355 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); 359 // V8 can't start up without the source of the natives, but it can
360 // start up (slower) without the snapshot.
rmcilroy 2015/06/02 15:20:27 Can you add this comment to all ContentBrowserClie
Erik Corry Chromium.org 2015/06/04 11:40:40 Done.
361 DCHECK(natives_fd_exists());
356 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 362 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
357 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 363 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
358 #endif // V8_USE_EXTERNAL_STARTUP_DATA 364 #endif // V8_USE_EXTERNAL_STARTUP_DATA
359 365
360 #if defined(OS_ANDROID) 366 #if defined(OS_ANDROID)
361 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 367 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
362 base::FilePath pak_file; 368 base::FilePath pak_file;
363 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); 369 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
364 CHECK(r); 370 CHECK(r);
365 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); 371 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 ShellBrowserContext* 431 ShellBrowserContext*
426 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 432 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
427 BrowserContext* content_browser_context) { 433 BrowserContext* content_browser_context) {
428 if (content_browser_context == browser_context()) 434 if (content_browser_context == browser_context())
429 return browser_context(); 435 return browser_context();
430 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 436 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
431 return off_the_record_browser_context(); 437 return off_the_record_browser_context();
432 } 438 }
433 439
434 } // namespace content 440 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698