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

Side by Side Diff: content/shell/browser/shell_content_browser_client.cc

Issue 1019483002: Add support to extension_shell and ash_shell to use external V8 snapshot files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac and Win builds Created 5 years, 9 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
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | extensions/shell/browser/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 nullptr, 345 nullptr,
346 gfx::Size())->web_contents()); 346 gfx::Size())->web_contents());
347 } 347 }
348 348
349 #if defined(OS_POSIX) && !defined(OS_MACOSX) 349 #if defined(OS_POSIX) && !defined(OS_MACOSX)
350 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 350 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
351 const base::CommandLine& command_line, 351 const base::CommandLine& command_line,
352 int child_process_id, 352 int child_process_id,
353 FileDescriptorInfo* mappings) { 353 FileDescriptorInfo* mappings) {
354 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 354 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
355 if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) { 355 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) {
356 base::FilePath v8_data_path; 356 int v8_natives_fd = -1;
357 PathService::Get(gin::IsolateHolder::kV8SnapshotBasePathKey, &v8_data_path); 357 int v8_snapshot_fd = -1;
358 DCHECK(!v8_data_path.empty()); 358 if (gin::IsolateHolder::OpenV8FilesForChildProcesses(&v8_natives_fd,
359 359 &v8_snapshot_fd)) {
360 int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 360 v8_natives_fd_.reset(v8_natives_fd);
361 base::FilePath v8_natives_data_path = 361 v8_snapshot_fd_.reset(v8_snapshot_fd);
362 v8_data_path.AppendASCII(gin::IsolateHolder::kNativesFileName); 362 }
363 base::FilePath v8_snapshot_data_path =
364 v8_data_path.AppendASCII(gin::IsolateHolder::kSnapshotFileName);
365 base::File v8_natives_data_file(v8_natives_data_path, file_flags);
366 base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags);
367 DCHECK(v8_natives_data_file.IsValid());
368 DCHECK(v8_snapshot_data_file.IsValid());
369 v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile());
370 v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile());
371 } 363 }
364 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1);
372 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 365 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
373 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 366 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
374 #endif // V8_USE_EXTERNAL_STARTUP_DATA 367 #endif // V8_USE_EXTERNAL_STARTUP_DATA
375 368
376 #if defined(OS_ANDROID) 369 #if defined(OS_ANDROID)
377 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 370 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
378 base::FilePath pak_file; 371 base::FilePath pak_file;
379 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); 372 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
380 CHECK(r); 373 CHECK(r);
381 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); 374 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 ShellBrowserContext* 434 ShellBrowserContext*
442 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 435 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
443 BrowserContext* content_browser_context) { 436 BrowserContext* content_browser_context) {
444 if (content_browser_context == browser_context()) 437 if (content_browser_context == browser_context())
445 return browser_context(); 438 return browser_context();
446 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 439 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
447 return off_the_record_browser_context(); 440 return off_the_record_browser_context();
448 } 441 }
449 442
450 } // namespace content 443 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | extensions/shell/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698