OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8SnapshotUtil_h |
| 6 #define V8SnapshotUtil_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "platform/wtf/Allocator.h" |
| 10 #include "v8/include/v8.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class Document; |
| 15 class DOMWrapperWorld; |
| 16 struct WrapperTypeInfo; |
| 17 |
| 18 // V8SnapshotUtil supports handling V8 snapshots. |
| 19 class CORE_EXPORT V8SnapshotUtil { |
| 20 STATIC_ONLY(V8SnapshotUtil); |
| 21 |
| 22 public: |
| 23 static v8::Local<v8::Context> CreateContext( |
| 24 v8::Isolate*, |
| 25 const DOMWrapperWorld&, |
| 26 v8::ExtensionConfiguration*, |
| 27 v8::Local<v8::Object> global_proxy, |
| 28 Document*); |
| 29 // Install runtime enabled features on some v8::Objects in a context |
| 30 // created with a snapshot. |
| 31 static void SetupContext(v8::Local<v8::Context>, Document*); |
| 32 |
| 33 static void EnsureInterfaceTemplates(v8::Isolate*); |
| 34 |
| 35 static void SetReferenceTable(intptr_t* table); |
| 36 static intptr_t* GetReferenceTable(); |
| 37 |
| 38 // Do not call this in production. |
| 39 static v8::StartupData TakeSnapshot(); |
| 40 |
| 41 private: |
| 42 static v8::StartupData SerializeInternalField(v8::Local<v8::Object> holder, |
| 43 int index, |
| 44 void* data); |
| 45 static void DeserializeInternalField(v8::Local<v8::Object> holder, |
| 46 int index, |
| 47 v8::StartupData payload, |
| 48 void* data); |
| 49 static bool CanCreateContextFromSnapshot(v8::Isolate*, |
| 50 const DOMWrapperWorld&, |
| 51 Document*); |
| 52 |
| 53 static void EnsureInterfaceTemplatesForWorld(v8::Isolate*, |
| 54 const DOMWrapperWorld&); |
| 55 static v8::Local<v8::FunctionTemplate> InterfaceTemplateFromSnapshot( |
| 56 v8::Isolate*, |
| 57 const DOMWrapperWorld&, |
| 58 const WrapperTypeInfo*); |
| 59 |
| 60 static void TakeSnapshotForWorld(v8::SnapshotCreator*, |
| 61 const DOMWrapperWorld&); |
| 62 }; |
| 63 |
| 64 } // namespace blink |
| 65 |
| 66 #endif // V8SnapshotUtil_h |
OLD | NEW |