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

Side by Side Diff: content/app/content_main_runner.cc

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Disable on ChromeOS and reduce size of table Created 3 years, 5 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 "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "content/public/app/content_main.h" 47 #include "content/public/app/content_main.h"
48 #include "content/public/app/content_main_delegate.h" 48 #include "content/public/app/content_main_delegate.h"
49 #include "content/public/common/content_client.h" 49 #include "content/public/common/content_client.h"
50 #include "content/public/common/content_constants.h" 50 #include "content/public/common/content_constants.h"
51 #include "content/public/common/content_descriptor_keys.h" 51 #include "content/public/common/content_descriptor_keys.h"
52 #include "content/public/common/content_features.h" 52 #include "content/public/common/content_features.h"
53 #include "content/public/common/content_paths.h" 53 #include "content/public/common/content_paths.h"
54 #include "content/public/common/content_switches.h" 54 #include "content/public/common/content_switches.h"
55 #include "content/public/common/main_function_params.h" 55 #include "content/public/common/main_function_params.h"
56 #include "content/public/common/sandbox_init.h" 56 #include "content/public/common/sandbox_init.h"
57 #include "gin/v8_initializer.h"
57 #include "media/base/media.h" 58 #include "media/base/media.h"
58 #include "ppapi/features/features.h" 59 #include "ppapi/features/features.h"
59 #include "services/service_manager/embedder/switches.h" 60 #include "services/service_manager/embedder/switches.h"
60 #include "ui/base/ui_base_paths.h" 61 #include "ui/base/ui_base_paths.h"
61 #include "ui/base/ui_base_switches.h" 62 #include "ui/base/ui_base_switches.h"
62 63
63 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) && \
64 !defined(CHROME_MULTIPLE_DLL_BROWSER)
65 #include "gin/v8_initializer.h"
66 #endif
67
68 #if defined(OS_WIN) 64 #if defined(OS_WIN)
69 #include <malloc.h> 65 #include <malloc.h>
70 #include <cstring> 66 #include <cstring>
71 67
72 #include "base/trace_event/trace_event_etw_export_win.h" 68 #include "base/trace_event/trace_event_etw_export_win.h"
73 #include "sandbox/win/src/sandbox_types.h" 69 #include "sandbox/win/src/sandbox_types.h"
74 #include "ui/display/win/dpi.h" 70 #include "ui/display/win/dpi.h"
75 #elif defined(OS_MACOSX) 71 #elif defined(OS_MACOSX)
76 #include "base/mac/scoped_nsautorelease_pool.h" 72 #include "base/mac/scoped_nsautorelease_pool.h"
77 #include "base/power_monitor/power_monitor_device_source.h" 73 #include "base/power_monitor/power_monitor_device_source.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 command_line, switches::kFieldTrialHandle, -1); 166 command_line, switches::kFieldTrialHandle, -1);
171 #endif 167 #endif
172 168
173 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 169 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
174 base::FieldTrialList::CreateFeaturesFromCommandLine( 170 base::FieldTrialList::CreateFeaturesFromCommandLine(
175 command_line, switches::kEnableFeatures, switches::kDisableFeatures, 171 command_line, switches::kEnableFeatures, switches::kDisableFeatures,
176 feature_list.get()); 172 feature_list.get());
177 base::FeatureList::SetInstance(std::move(feature_list)); 173 base::FeatureList::SetInstance(std::move(feature_list));
178 } 174 }
179 175
176 void LoadBlinkV8SnapshotFile() {
177 #if defined(OS_POSIX) && !defined(OS_MACOSX)
178 base::FileDescriptorStore& file_descriptor_store =
179 base::FileDescriptorStore::GetInstance();
180 base::MemoryMappedFile::Region region;
181 base::ScopedFD fd = file_descriptor_store.MaybeTakeFD(
182 kBlinkV8SnapshotDataDescriptor, &region);
183 if (fd.is_valid()) {
184 gin::V8Initializer::LoadBlinkV8SnapshotFromFD(fd.get(), region.offset,
185 region.size);
186 return;
187 }
188 #endif // OS
189 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
190 gin::V8Initializer::LoadBlinkV8Snapshot();
191 #endif // !CHROME_MULTIPLE_DLL_BROWSER
192 }
193
180 void InitializeV8IfNeeded( 194 void InitializeV8IfNeeded(
181 const base::CommandLine& command_line, 195 const base::CommandLine& command_line,
182 const std::string& process_type) { 196 const std::string& process_type) {
183 if (process_type == switches::kGpuProcess) 197 if (process_type == switches::kGpuProcess)
184 return; 198 return;
185 199
186 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 200 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
187 #if defined(OS_POSIX) && !defined(OS_MACOSX) 201 #if defined(OS_POSIX) && !defined(OS_MACOSX)
188 base::FileDescriptorStore& file_descriptor_store = 202 base::FileDescriptorStore& file_descriptor_store =
189 base::FileDescriptorStore::GetInstance(); 203 base::FileDescriptorStore::GetInstance();
190 base::MemoryMappedFile::Region region; 204 base::MemoryMappedFile::Region region;
191 base::ScopedFD v8_snapshot_fd = 205 base::ScopedFD v8_snapshot_fd =
192 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region); 206 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region);
193 if (v8_snapshot_fd.is_valid()) { 207 if (v8_snapshot_fd.is_valid()) {
194 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(), 208 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(),
195 region.offset, region.size); 209 region.offset, region.size);
196 } else { 210 } else {
197 gin::V8Initializer::LoadV8Snapshot(); 211 gin::V8Initializer::LoadV8Snapshot();
198 } 212 }
199 base::ScopedFD v8_natives_fd = 213 base::ScopedFD v8_natives_fd =
200 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region); 214 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region);
201 if (v8_natives_fd.is_valid()) { 215 if (v8_natives_fd.is_valid()) {
202 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), 216 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), region.offset,
203 region.offset, region.size); 217 region.size);
204 } else { 218 } else {
205 gin::V8Initializer::LoadV8Natives(); 219 gin::V8Initializer::LoadV8Natives();
206 } 220 }
207 #else 221 #else
208 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 222 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
209 gin::V8Initializer::LoadV8Snapshot(); 223 gin::V8Initializer::LoadV8Snapshot();
210 gin::V8Initializer::LoadV8Natives(); 224 gin::V8Initializer::LoadV8Natives();
211 #endif // !CHROME_MULTIPLE_DLL_BROWSER 225 #endif // !CHROME_MULTIPLE_DLL_BROWSER
212 #endif // OS_POSIX && !OS_MACOSX 226 #endif // OS_POSIX && !OS_MACOSX
213 #endif // V8_USE_EXTERNAL_STARTUP_DATA 227 #endif // V8_USE_EXTERNAL_STARTUP_DATA
228
229 LoadBlinkV8SnapshotFile();
haraken 2017/07/04 15:04:19 LoadV8ContextSnapshotFile
peria 2017/07/07 06:21:51 Done.
214 } 230 }
215 231
216 } // namespace 232 } // namespace
217 233
218 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 234 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
219 base::LazyInstance<ContentBrowserClient>::DestructorAtExit 235 base::LazyInstance<ContentBrowserClient>::DestructorAtExit
220 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 236 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
221 #endif // !CHROME_MULTIPLE_DLL_CHILD 237 #endif // !CHROME_MULTIPLE_DLL_CHILD
222 238
223 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 239 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 768
753 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 769 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
754 }; 770 };
755 771
756 // static 772 // static
757 ContentMainRunner* ContentMainRunner::Create() { 773 ContentMainRunner* ContentMainRunner::Create() {
758 return new ContentMainRunnerImpl(); 774 return new ContentMainRunnerImpl();
759 } 775 }
760 776
761 } // namespace content 777 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698