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

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

Issue 2989793003: Revert of [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Created 3 years, 4 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/BUILD.gn ('k') | content/public/app/mojo/content_renderer_manifest.json » ('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 (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"
58 #include "media/base/media.h" 57 #include "media/base/media.h"
59 #include "media/media_features.h" 58 #include "media/media_features.h"
60 #include "ppapi/features/features.h" 59 #include "ppapi/features/features.h"
61 #include "services/service_manager/embedder/switches.h" 60 #include "services/service_manager/embedder/switches.h"
62 #include "ui/base/ui_base_paths.h" 61 #include "ui/base/ui_base_paths.h"
63 #include "ui/base/ui_base_switches.h" 62 #include "ui/base/ui_base_switches.h"
64 63
64 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) && \
65 !defined(CHROME_MULTIPLE_DLL_BROWSER)
66 #include "gin/v8_initializer.h"
67 #endif
68
65 #if defined(OS_WIN) 69 #if defined(OS_WIN)
66 #include <malloc.h> 70 #include <malloc.h>
67 #include <cstring> 71 #include <cstring>
68 72
69 #include "base/trace_event/trace_event_etw_export_win.h" 73 #include "base/trace_event/trace_event_etw_export_win.h"
70 #include "sandbox/win/src/sandbox_types.h" 74 #include "sandbox/win/src/sandbox_types.h"
71 #include "ui/display/win/dpi.h" 75 #include "ui/display/win/dpi.h"
72 #elif defined(OS_MACOSX) 76 #elif defined(OS_MACOSX)
73 #include "base/mac/scoped_nsautorelease_pool.h" 77 #include "base/mac/scoped_nsautorelease_pool.h"
74 #include "base/power_monitor/power_monitor_device_source.h" 78 #include "base/power_monitor/power_monitor_device_source.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 command_line, switches::kFieldTrialHandle, -1); 171 command_line, switches::kFieldTrialHandle, -1);
168 #endif 172 #endif
169 173
170 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 174 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
171 base::FieldTrialList::CreateFeaturesFromCommandLine( 175 base::FieldTrialList::CreateFeaturesFromCommandLine(
172 command_line, switches::kEnableFeatures, switches::kDisableFeatures, 176 command_line, switches::kEnableFeatures, switches::kDisableFeatures,
173 feature_list.get()); 177 feature_list.get());
174 base::FeatureList::SetInstance(std::move(feature_list)); 178 base::FeatureList::SetInstance(std::move(feature_list));
175 } 179 }
176 180
177 void LoadV8ContextSnapshotFile() {
178 #if defined(OS_POSIX) && !defined(OS_MACOSX)
179 base::FileDescriptorStore& file_descriptor_store =
180 base::FileDescriptorStore::GetInstance();
181 base::MemoryMappedFile::Region region;
182 base::ScopedFD fd = file_descriptor_store.MaybeTakeFD(
183 kV8ContextSnapshotDataDescriptor, &region);
184 if (fd.is_valid()) {
185 gin::V8Initializer::LoadV8ContextSnapshotFromFD(fd.get(), region.offset,
186 region.size);
187 return;
188 }
189 #endif // OS
190 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
191 gin::V8Initializer::LoadV8ContextSnapshot();
192 #endif // !CHROME_MULTIPLE_DLL_BROWSER
193 }
194
195 void InitializeV8IfNeeded( 181 void InitializeV8IfNeeded(
196 const base::CommandLine& command_line, 182 const base::CommandLine& command_line,
197 const std::string& process_type) { 183 const std::string& process_type) {
198 if (process_type == switches::kGpuProcess) 184 if (process_type == switches::kGpuProcess)
199 return; 185 return;
200 186
201 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) 187 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
202 #if defined(OS_POSIX) && !defined(OS_MACOSX) 188 #if defined(OS_POSIX) && !defined(OS_MACOSX)
203 base::FileDescriptorStore& file_descriptor_store = 189 base::FileDescriptorStore& file_descriptor_store =
204 base::FileDescriptorStore::GetInstance(); 190 base::FileDescriptorStore::GetInstance();
205 base::MemoryMappedFile::Region region; 191 base::MemoryMappedFile::Region region;
206 base::ScopedFD v8_snapshot_fd = 192 base::ScopedFD v8_snapshot_fd =
207 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region); 193 file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region);
208 if (v8_snapshot_fd.is_valid()) { 194 if (v8_snapshot_fd.is_valid()) {
209 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(), 195 gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(),
210 region.offset, region.size); 196 region.offset, region.size);
211 } else { 197 } else {
212 gin::V8Initializer::LoadV8Snapshot(); 198 gin::V8Initializer::LoadV8Snapshot();
213 } 199 }
214 base::ScopedFD v8_natives_fd = 200 base::ScopedFD v8_natives_fd =
215 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region); 201 file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region);
216 if (v8_natives_fd.is_valid()) { 202 if (v8_natives_fd.is_valid()) {
217 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), region.offset, 203 gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(),
218 region.size); 204 region.offset, region.size);
219 } else { 205 } else {
220 gin::V8Initializer::LoadV8Natives(); 206 gin::V8Initializer::LoadV8Natives();
221 } 207 }
222 #else 208 #else
223 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 209 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
224 gin::V8Initializer::LoadV8Snapshot(); 210 gin::V8Initializer::LoadV8Snapshot();
225 gin::V8Initializer::LoadV8Natives(); 211 gin::V8Initializer::LoadV8Natives();
226 #endif // !CHROME_MULTIPLE_DLL_BROWSER 212 #endif // !CHROME_MULTIPLE_DLL_BROWSER
227 #endif // OS_POSIX && !OS_MACOSX 213 #endif // OS_POSIX && !OS_MACOSX
228 #endif // V8_USE_EXTERNAL_STARTUP_DATA 214 #endif // V8_USE_EXTERNAL_STARTUP_DATA
229
230 LoadV8ContextSnapshotFile();
231 } 215 }
232 216
233 } // namespace 217 } // namespace
234 218
235 #if !defined(CHROME_MULTIPLE_DLL_CHILD) 219 #if !defined(CHROME_MULTIPLE_DLL_CHILD)
236 base::LazyInstance<ContentBrowserClient>::DestructorAtExit 220 base::LazyInstance<ContentBrowserClient>::DestructorAtExit
237 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; 221 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER;
238 #endif // !CHROME_MULTIPLE_DLL_CHILD 222 #endif // !CHROME_MULTIPLE_DLL_CHILD
239 223
240 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) 224 #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 743
760 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 744 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
761 }; 745 };
762 746
763 // static 747 // static
764 ContentMainRunner* ContentMainRunner::Create() { 748 ContentMainRunner* ContentMainRunner::Create() {
765 return new ContentMainRunnerImpl(); 749 return new ContentMainRunnerImpl();
766 } 750 }
767 751
768 } // namespace content 752 } // namespace content
OLDNEW
« no previous file with comments | « chrome/BUILD.gn ('k') | content/public/app/mojo/content_renderer_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698