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