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

Side by Side Diff: ash/shell/content_client/shell_content_browser_client.cc

Issue 1156873002: Load v8 snapshots directly from APK (and store them uncompressed) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8initializer
Patch Set: Pass FDs & Regions through to child process (Still has formatting errors) 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 "ash/shell/content_client/shell_content_browser_client.h" 5 #include "ash/shell/content_client/shell_content_browser_client.h"
6 6
7 #include "ash/shell/content_client/shell_browser_main_parts.h" 7 #include "ash/shell/content_client/shell_browser_main_parts.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/public/common/content_descriptors.h" 9 #include "content/public/common/content_descriptors.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "content/shell/browser/shell_browser_context.h" 11 #include "content/shell/browser/shell_browser_context.h"
12 #include "gin/v8_initializer.h" 12 #include "gin/v8_initializer.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 14
15 namespace ash { 15 namespace ash {
16 namespace shell { 16 namespace shell {
17 17
18 ShellContentBrowserClient::ShellContentBrowserClient() 18 ShellContentBrowserClient::ShellContentBrowserClient()
19 : 19 : shell_browser_main_parts_(nullptr) {
20 #if defined(OS_POSIX) && !defined(OS_MACOSX)
21 v8_natives_fd_(-1),
22 v8_snapshot_fd_(-1),
23 #endif // OS_POSIX && !OS_MACOSX
24 shell_browser_main_parts_(nullptr) {
25 } 20 }
26 21
27 ShellContentBrowserClient::~ShellContentBrowserClient() { 22 ShellContentBrowserClient::~ShellContentBrowserClient() {
28 } 23 }
29 24
30 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts( 25 content::BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
31 const content::MainFunctionParams& parameters) { 26 const content::MainFunctionParams& parameters) {
32 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters); 27 shell_browser_main_parts_ = new ShellBrowserMainParts(parameters);
33 return shell_browser_main_parts_; 28 return shell_browser_main_parts_;
34 } 29 }
(...skipping 22 matching lines...) Expand all
57 #endif // V8_USE_EXTERNAL_STARTUP_DATA 52 #endif // V8_USE_EXTERNAL_STARTUP_DATA
58 #endif // OS_POSIX && !OS_MACOSX 53 #endif // OS_POSIX && !OS_MACOSX
59 } 54 }
60 55
61 #if defined(OS_POSIX) && !defined(OS_MACOSX) 56 #if defined(OS_POSIX) && !defined(OS_MACOSX)
62 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 57 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
63 const base::CommandLine& command_line, 58 const base::CommandLine& command_line,
64 int child_process_id, 59 int child_process_id,
65 content::FileDescriptorInfo* mappings) { 60 content::FileDescriptorInfo* mappings) {
66 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 61 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
67 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { 62 if (!v8_files_.IsLoaded()) {
68 int v8_natives_fd = -1; 63 gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_);
69 int v8_snapshot_fd = -1;
70 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd,
71 &v8_snapshot_fd)) {
72 v8_natives_fd_.reset(v8_natives_fd);
73 v8_snapshot_fd_.reset(v8_snapshot_fd);
74 }
75 } 64 }
76 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); 65 DCHECK(v8_files_.IsLoaded());
77 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); 66 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
78 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); 67 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
79 #endif // V8_USE_EXTERNAL_STARTUP_DATA 68 #endif // V8_USE_EXTERNAL_STARTUP_DATA
80 } 69 }
81 #endif // OS_POSIX && !OS_MACOSX 70 #endif // OS_POSIX && !OS_MACOSX
82 71
83 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() { 72 content::ShellBrowserContext* ShellContentBrowserClient::browser_context() {
84 return shell_browser_main_parts_->browser_context(); 73 return shell_browser_main_parts_->browser_context();
85 } 74 }
86 75
87 } // namespace examples 76 } // namespace examples
88 } // namespace views 77 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698