OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 GIN_V8_INITIALIZER_H_ | |
6 #define GIN_V8_INITIALIZER_H_ | |
7 | |
8 #include "base/files/file.h" | |
9 #include "gin/array_buffer.h" | |
10 #include "gin/gin_export.h" | |
11 #include "gin/public/v8_platform.h" | |
12 #include "v8/include/v8.h" | |
13 | |
14 namespace gin { | |
15 | |
16 class GIN_EXPORT V8Initializer { | |
17 public: | |
18 // Controls whether or not V8 should only accept strict mode scripts. | |
19 enum ScriptMode { kNonStrictMode, kStrictMode }; | |
rmcilroy
2015/03/30 10:29:22
note for future cleanup (or now if it's easy) we s
oth
2015/03/30 15:55:19
Yes, good point. In the near term, the code now ju
| |
20 | |
21 static const int kV8SnapshotBasePathKey; | |
22 static const char kNativesFileName[]; | |
23 static const char kSnapshotFileName[]; | |
24 | |
25 // Should be invoked once before creating IsolateHolder instances to | |
26 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is defined, | |
27 // V8's initial snapshot should be loaded (by calling LoadV8Snapshot or | |
28 // LoadV8SnapshotFd) before calling Initialize. | |
rmcilroy
2015/03/30 10:29:22
update "LoadV8SnapshotFd" in comment with name cho
oth
2015/03/30 15:55:19
Done and comment moved to IsolateHolder.h for now.
| |
29 static void Initialize(ScriptMode mode, | |
30 v8::ArrayBuffer::Allocator* allocator); | |
31 | |
32 static v8::ArrayBuffer::Allocator* GetArrayBufferAllocator(); | |
33 | |
34 static void GetV8ExternalSnapshotData(const char** natives_data_out, | |
rmcilroy
2015/03/30 10:29:22
Could you document these methods please (you can c
oth
2015/03/30 15:55:19
Done.
oth
2015/03/30 15:55:19
Done.
| |
35 int* natives_size_out, | |
36 const char** snapshot_data_out, | |
37 int* snapshot_size_out); | |
38 | |
39 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
40 | |
41 static bool LoadV8SnapshotFromFile(base::PlatformFile natives_fd, | |
rmcilroy
2015/03/30 10:29:22
Both this and LoadV8Snapshot load it from a file,
oth
2015/03/30 15:55:19
Done.
| |
42 int64 natives_offset, | |
43 int64 natives_size, | |
44 base::PlatformFile snapshot_fd, | |
45 int64 snapshot_offset, | |
46 int64 snapshot_size); | |
47 | |
48 static bool LoadV8Snapshot(); | |
49 | |
50 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
51 }; | |
52 | |
53 } // namespace gin | |
54 | |
55 #endif // GIN_V8_INITIALIZER_H_ | |
OLD | NEW |