| 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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 kStableAndExperimentalV8Extras, | 53 kStableAndExperimentalV8Extras, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 explicit IsolateHolder( | 56 explicit IsolateHolder( |
| 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 58 IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 58 IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 59 AccessMode access_mode); | 59 AccessMode access_mode); |
| 60 IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 60 IsolateHolder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 61 AccessMode access_mode, | 61 AccessMode access_mode, |
| 62 AllowAtomicsWaitMode atomics_wait_mode); | 62 AllowAtomicsWaitMode atomics_wait_mode); |
| 63 |
| 64 // This constructor is to create V8 snapshot for Blink. |
| 65 // Note this constructor calls isolate->Enter() internally. |
| 66 IsolateHolder(intptr_t* reference_table, v8::StartupData* existing_blob); |
| 67 |
| 63 ~IsolateHolder(); | 68 ~IsolateHolder(); |
| 64 | 69 |
| 65 // Should be invoked once before creating IsolateHolder instances to | 70 // Should be invoked once before creating IsolateHolder instances to |
| 66 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is | 71 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is |
| 67 // defined, V8's initial natives should be loaded (by calling | 72 // defined, V8's initial natives should be loaded (by calling |
| 68 // V8Initializer::LoadV8NativesFromFD or | 73 // V8Initializer::LoadV8NativesFromFD or |
| 69 // V8Initializer::LoadV8Natives) before calling this method. If the | 74 // V8Initializer::LoadV8Natives) before calling this method. If the |
| 70 // snapshot file is available, it should also be loaded (by calling | 75 // snapshot file is available, it should also be loaded (by calling |
| 71 // V8Initializer::LoadV8SnapshotFromFD or | 76 // V8Initializer::LoadV8SnapshotFromFD or |
| 72 // V8Initializer::LoadV8Snapshot) before calling this method. | 77 // V8Initializer::LoadV8Snapshot) before calling this method. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 // MessageLoop's thread. | 89 // MessageLoop's thread. |
| 85 void AddRunMicrotasksObserver(); | 90 void AddRunMicrotasksObserver(); |
| 86 | 91 |
| 87 // This method should also only be called once, and on the MessageLoop's | 92 // This method should also only be called once, and on the MessageLoop's |
| 88 // thread. | 93 // thread. |
| 89 void RemoveRunMicrotasksObserver(); | 94 void RemoveRunMicrotasksObserver(); |
| 90 | 95 |
| 91 // This method returns if v8::Locker is needed to access isolate. | 96 // This method returns if v8::Locker is needed to access isolate. |
| 92 AccessMode access_mode() const { return access_mode_; } | 97 AccessMode access_mode() const { return access_mode_; } |
| 93 | 98 |
| 99 v8::SnapshotCreator* snapshot_creator() const { |
| 100 return snapshot_creator_.get(); |
| 101 } |
| 102 |
| 94 void EnableIdleTasks(std::unique_ptr<V8IdleTaskRunner> idle_task_runner); | 103 void EnableIdleTasks(std::unique_ptr<V8IdleTaskRunner> idle_task_runner); |
| 95 | 104 |
| 96 // This method returns V8IsolateMemoryDumpProvider of this isolate, used for | 105 // This method returns V8IsolateMemoryDumpProvider of this isolate, used for |
| 97 // testing. | 106 // testing. |
| 98 V8IsolateMemoryDumpProvider* isolate_memory_dump_provider_for_testing() | 107 V8IsolateMemoryDumpProvider* isolate_memory_dump_provider_for_testing() |
| 99 const { | 108 const { |
| 100 return isolate_memory_dump_provider_.get(); | 109 return isolate_memory_dump_provider_.get(); |
| 101 } | 110 } |
| 102 | 111 |
| 103 private: | 112 private: |
| 104 v8::Isolate* isolate_; | 113 v8::Isolate* isolate_; |
| 105 std::unique_ptr<PerIsolateData> isolate_data_; | 114 std::unique_ptr<PerIsolateData> isolate_data_; |
| 106 std::unique_ptr<RunMicrotasksObserver> task_observer_; | 115 std::unique_ptr<RunMicrotasksObserver> task_observer_; |
| 107 std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_; | 116 std::unique_ptr<V8IsolateMemoryDumpProvider> isolate_memory_dump_provider_; |
| 117 std::unique_ptr<v8::SnapshotCreator> snapshot_creator_; |
| 108 AccessMode access_mode_; | 118 AccessMode access_mode_; |
| 109 | 119 |
| 110 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); | 120 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); |
| 111 }; | 121 }; |
| 112 | 122 |
| 113 } // namespace gin | 123 } // namespace gin |
| 114 | 124 |
| 115 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ | 125 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| OLD | NEW |