[M120 Migration] Set IO|GPU thread type with higher priorites
[platform/framework/web/chromium-efl.git] / gin / v8_initializer.h
1 // Copyright 2013 The Chromium Authors
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 <stdint.h>
9
10 #include "base/files/file.h"
11 #include "base/files/memory_mapped_file.h"
12 #include "build/build_config.h"
13 #include "gin/array_buffer.h"
14 #include "gin/gin_export.h"
15 #include "gin/public/isolate_holder.h"
16 #include "gin/public/v8_platform.h"
17 #include "v8/include/v8-callbacks.h"
18
19 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
20 #include "gin/public/v8_snapshot_file_type.h"
21 #endif
22
23 namespace v8 {
24 class StartupData;
25 }
26
27 namespace gin {
28
29 class GIN_EXPORT V8Initializer {
30  public:
31   // This should be called by IsolateHolder::Initialize().
32   static void Initialize(IsolateHolder::ScriptMode mode,
33                          const std::string js_command_line_flags = {},
34 #if defined(ENABLE_WRT_JS)
35                          v8::OOMErrorCallback oom_error_callback = nullptr,
36                          bool create_v8_platform = true);
37 #else
38                          v8::OOMErrorCallback oom_error_callback = nullptr);
39 #endif
40
41   // Get address and size information for currently loaded snapshot.
42   // If no snapshot is loaded, the return values are null for addresses
43   // and 0 for sizes.
44   static void GetV8ExternalSnapshotData(v8::StartupData* snapshot);
45   static void GetV8ExternalSnapshotData(const char** snapshot_data_out,
46                                         int* snapshot_size_out);
47
48 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
49   // Load V8 snapshot from default resources, if they are available.
50   static void LoadV8Snapshot(
51       V8SnapshotFileType snapshot_file_type = V8SnapshotFileType::kDefault);
52
53   // Load V8 snapshot from user provided file.
54   // The region argument, if non-zero, specifies the portions
55   // of the files to be mapped. Since the VM can boot with or without
56   // the snapshot, this function does not return a status.
57   static void LoadV8SnapshotFromFile(
58       base::File snapshot_file,
59       base::MemoryMappedFile::Region* snapshot_file_region,
60       V8SnapshotFileType snapshot_file_type);
61
62 #if BUILDFLAG(IS_ANDROID)
63   static base::FilePath GetSnapshotFilePath(
64       bool abi_32_bit,
65       V8SnapshotFileType snapshot_file_type);
66 #endif
67
68 #endif  // V8_USE_EXTERNAL_STARTUP_DATA
69
70 };
71
72 }  // namespace gin
73
74 #endif  // GIN_V8_INITIALIZER_H_