scheduler: Always create a real scheduler in unit tests
[chromium-blink-merge.git] / gin / v8_initializer.h
blob0189f594f939322a7b5ec65d2f2612afa5660d4e
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.
5 #ifndef GIN_V8_INITIALIZER_H_
6 #define GIN_V8_INITIALIZER_H_
8 #include "base/files/file.h"
9 #include "gin/array_buffer.h"
10 #include "gin/gin_export.h"
11 #include "gin/public/isolate_holder.h"
12 #include "gin/public/v8_platform.h"
13 #include "v8/include/v8.h"
15 namespace gin {
17 class GIN_EXPORT V8Initializer {
18 public:
19 // This should be called by IsolateHolder::Initialize().
20 static void Initialize(gin::IsolateHolder::ScriptMode mode);
22 // Get address and size information for currently loaded snapshot.
23 // If no snapshot is loaded, the return values are null for addresses
24 // and 0 for sizes.
25 static void GetV8ExternalSnapshotData(const char** natives_data_out,
26 int* natives_size_out,
27 const char** snapshot_data_out,
28 int* snapshot_size_out);
30 #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
32 // Load V8 snapshot from user provided platform file descriptors.
33 // The offset and size arguments, if non-zero, specify the portions
34 // of the files to be loaded. This methods returns true on success
35 // (or if snapshot is already loaded), false otherwise.
36 static bool LoadV8SnapshotFromFD(base::PlatformFile natives_fd,
37 int64 natives_offset,
38 int64 natives_size,
39 base::PlatformFile snapshot_fd,
40 int64 snapshot_offset,
41 int64 snapshot_size);
43 // Load V8 snapshot from default resources. Returns true on success or
44 // snapshot is already loaded, false otherwise.
45 static bool LoadV8Snapshot();
47 // Opens the V8 snapshot data files and returns open file descriptors to these
48 // files in |natives_fd_out| and |snapshot_fd_out|, which can be passed to
49 // child processes.
50 static bool OpenV8FilesForChildProcesses(base::PlatformFile* natives_fd_out,
51 base::PlatformFile* snapshot_fd_out);
53 #endif // V8_USE_EXTERNAL_STARTUP_DATA
56 } // namespace gin
58 #endif // GIN_V8_INITIALIZER_H_