OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef GIN_PUBLIC_ISOLATE_HOLDER_H_ | 5 #ifndef GIN_PUBLIC_ISOLATE_HOLDER_H_ |
6 #define GIN_PUBLIC_ISOLATE_HOLDER_H_ | 6 #define GIN_PUBLIC_ISOLATE_HOLDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" |
11 #include "gin/gin_export.h" | 12 #include "gin/gin_export.h" |
12 #include "gin/public/v8_idle_task_runner.h" | 13 #include "gin/public/v8_idle_task_runner.h" |
13 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
14 | 15 |
| 16 namespace base { |
| 17 class SingleThreadTaskRunner; |
| 18 } |
| 19 |
15 namespace gin { | 20 namespace gin { |
16 | 21 |
17 class PerIsolateData; | 22 class PerIsolateData; |
18 class RunMicrotasksObserver; | 23 class RunMicrotasksObserver; |
19 class V8IsolateMemoryDumpProvider; | 24 class V8IsolateMemoryDumpProvider; |
20 | 25 |
21 // To embed Gin, first initialize gin using IsolateHolder::Initialize and then | 26 // To embed Gin, first initialize gin using IsolateHolder::Initialize and then |
22 // create an instance of IsolateHolder to hold the v8::Isolate in which you | 27 // create an instance of IsolateHolder to hold the v8::Isolate in which you |
23 // will execute JavaScript. You might wish to subclass IsolateHolder if you | 28 // will execute JavaScript. You might wish to subclass IsolateHolder if you |
24 // want to tie more state to the lifetime of the isolate. | 29 // want to tie more state to the lifetime of the isolate. |
(...skipping 10 matching lines...) Expand all Loading... |
35 kSingleThread, | 40 kSingleThread, |
36 kUseLocker | 41 kUseLocker |
37 }; | 42 }; |
38 | 43 |
39 // Indicates whether V8 works with stable or experimental v8 extras. | 44 // Indicates whether V8 works with stable or experimental v8 extras. |
40 enum V8ExtrasMode { | 45 enum V8ExtrasMode { |
41 kStableV8Extras, | 46 kStableV8Extras, |
42 kStableAndExperimentalV8Extras, | 47 kStableAndExperimentalV8Extras, |
43 }; | 48 }; |
44 | 49 |
45 IsolateHolder(); | 50 explicit IsolateHolder( |
46 explicit IsolateHolder(AccessMode access_mode); | 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 52 IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 53 AccessMode access_mode); |
47 ~IsolateHolder(); | 54 ~IsolateHolder(); |
48 | 55 |
49 // Should be invoked once before creating IsolateHolder instances to | 56 // Should be invoked once before creating IsolateHolder instances to |
50 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is | 57 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is |
51 // defined, V8's initial natives should be loaded (by calling | 58 // defined, V8's initial natives should be loaded (by calling |
52 // V8Initializer::LoadV8NativesFromFD or | 59 // V8Initializer::LoadV8NativesFromFD or |
53 // V8Initializer::LoadV8Natives) before calling this method. If the | 60 // V8Initializer::LoadV8Natives) before calling this method. If the |
54 // snapshot file is available, it should also be loaded (by calling | 61 // snapshot file is available, it should also be loaded (by calling |
55 // V8Initializer::LoadV8SnapshotFromFD or | 62 // V8Initializer::LoadV8SnapshotFromFD or |
56 // V8Initializer::LoadV8Snapshot) before calling this method. | 63 // V8Initializer::LoadV8Snapshot) before calling this method. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 std::unique_ptr<RunMicrotasksObserver> task_observer_; | 97 std::unique_ptr<RunMicrotasksObserver> task_observer_; |
91 std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_; | 98 std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_; |
92 AccessMode access_mode_; | 99 AccessMode access_mode_; |
93 | 100 |
94 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); | 101 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); |
95 }; | 102 }; |
96 | 103 |
97 } // namespace gin | 104 } // namespace gin |
98 | 105 |
99 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ | 106 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ |
OLD | NEW |