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

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

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Support runtime feature on templates Created 3 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 "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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 command_line, switches::kFieldTrialHandle, -1); 170 command_line, switches::kFieldTrialHandle, -1);
175 #endif 171 #endif
176 172
177 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 173 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
178 base::FieldTrialList::CreateFeaturesFromCommandLine( 174 base::FieldTrialList::CreateFeaturesFromCommandLine(
179 command_line, switches::kEnableFeatures, switches::kDisableFeatures, 175 command_line, switches::kEnableFeatures, switches::kDisableFeatures,
180 feature_list.get()); 176 feature_list.get());
181 base::FeatureList::SetInstance(std::move(feature_list)); 177 base::FeatureList::SetInstance(std::move(feature_list));
182 } 178 }
183 179
180 void LoadBlinkV8SnapshotFile() {
181 #if defined(OS_POSIX) && !defined(OS_MACOSX)
182 base::FileDescriptorStore& file_descriptor_store =
183 base::FileDescriptorStore::GetInstance();
184 base::MemoryMappedFile::Region region;
185 base::ScopedFD fd = file_descriptor_store.MaybeTakeFD(
186 kBlinkV8SnapshotDataDescriptor, &region);
187 if (fd.is_valid()) {
188 gin::V8Initializer::LoadBlinkV8SnapshotFromFD(fd.get(), region.offset,
189 region.size);
190 return;
191 }
192 #endif // OS
193 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
194 gin::V8Initializer::LoadBlinkV8Snapshot();
195 #endif // !CHROME_MULTIPLE_DLL_BROWSER
196 }
197
184 void InitializeV8IfNeeded( 198 void InitializeV8IfNeeded(
185 const base::CommandLine& command_line, 199 const base::CommandLine& command_line,
186 const std::string& process_type) { 200 const std::string& process_type) {
187 if (process_type == switches::kGpuProcess) 201 if (process_type == switches::kGpuProcess)
188 return; 202 return;
189 203
190 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 204 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
191 #if defined(OS_POSIX) && !defined(OS_MACOSX) 205 #if defined(OS_POSIX) && !defined(OS_MACOSX)
192 base::FileDescriptorStore& file_descriptor_store = 206 base::FileDescriptorStore& file_descriptor_store =
193 base::FileDescriptorStore::GetInstance(); 207 base::FileDescriptorStore::GetInstance();
194 base::MemoryMappedFile::Region region; 208 base::MemoryMappedFile::Region region;
195 base::ScopedFD v8_snapshot_fd = 209 base::ScopedFD v8_snapshot_fd =
196 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region); 210 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region);
197 if (v8_snapshot_fd.is_valid()) { 211 if (v8_snapshot_fd.is_valid()) {
198 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(), 212 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(),
199 region.offset, region.size); 213 region.offset, region.size);
200 } else { 214 } else {
201 gin::V8Initializer::LoadV8Snapshot(); 215 gin::V8Initializer::LoadV8Snapshot();
202 } 216 }
203 base::ScopedFD v8_natives_fd = 217 base::ScopedFD v8_natives_fd =
204 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region); 218 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region);
205 if (v8_natives_fd.is_valid()) { 219 if (v8_natives_fd.is_valid()) {
206 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), 220 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), region.offset,
207 region.offset, region.size); 221 region.size);
208 } else { 222 } else {
209 gin::V8Initializer::LoadV8Natives(); 223 gin::V8Initializer::LoadV8Natives();
210 } 224 }
211 #else 225 #else
212 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 226 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
213 gin::V8Initializer::LoadV8Snapshot(); 227 gin::V8Initializer::LoadV8Snapshot();
214 gin::V8Initializer::LoadV8Natives(); 228 gin::V8Initializer::LoadV8Natives();
215 #endif // !CHROME_MULTIPLE_DLL_BROWSER 229 #endif // !CHROME_MULTIPLE_DLL_BROWSER
216 #endif // OS_POSIX && !OS_MACOSX 230 #endif // OS_POSIX && !OS_MACOSX
217 #endif // V8_USE_EXTERNAL_STARTUP_DATA 231 #endif // V8_USE_EXTERNAL_STARTUP_DATA
232
233 LoadBlinkV8SnapshotFile();
218 } 234 }
219 235
220 } // namespace 236 } // namespace
221 237
222 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 238 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
223 base::LazyInstance<ContentBrowserClient>::DestructorAtExit 239 base::LazyInstance<ContentBrowserClient>::DestructorAtExit
224 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 240 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
225 #endif // !CHROME_MULTIPLE_DLL_CHILD 241 #endif // !CHROME_MULTIPLE_DLL_CHILD
226 242
227 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 243 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 776
761 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 777 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
762 }; 778 };
763 779
764 // static 780 // static
765 ContentMainRunner* ContentMainRunner::Create() { 781 ContentMainRunner* ContentMainRunner::Create() {
766 return new ContentMainRunnerImpl(); 782 return new ContentMainRunnerImpl();
767 } 783 }
768 784
769 } // namespace content 785 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698