| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "gin/gin_export.h" | 10 #include "gin/gin_export.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Controls whether or not V8 should only accept strict mode scripts. | 24 // Controls whether or not V8 should only accept strict mode scripts. |
| 25 enum ScriptMode { | 25 enum ScriptMode { |
| 26 kNonStrictMode, | 26 kNonStrictMode, |
| 27 kStrictMode | 27 kStrictMode |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 IsolateHolder(); | 30 IsolateHolder(); |
| 31 ~IsolateHolder(); | 31 ~IsolateHolder(); |
| 32 | 32 |
| 33 // Should be invoked once before creating IsolateHolder instances to | 33 // Should be invoked once before creating IsolateHolder instances to |
| 34 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is defined, | 34 // initialize V8 and Gin. In case V8_USE_EXTERNAL_STARTUP_DATA is |
| 35 // V8's initial snapshot should be loaded (by calling LoadV8Snapshot or | 35 // defined, V8's initial snapshot should be loaded (by calling |
| 36 // LoadV8SnapshotFd) before calling Initialize. | 36 // V8Initializer::LoadV8SnapshotFromFD or |
| 37 // V8Initializer::LoadV8Snapshot) before calling this method. |
| 37 static void Initialize(ScriptMode mode, | 38 static void Initialize(ScriptMode mode, |
| 38 v8::ArrayBuffer::Allocator* allocator); | 39 v8::ArrayBuffer::Allocator* allocator); |
| 39 | 40 |
| 40 v8::Isolate* isolate() { return isolate_; } | 41 v8::Isolate* isolate() { return isolate_; } |
| 41 | 42 |
| 42 // The implementations of Object.observe() and Promise enqueue v8 Microtasks | 43 // The implementations of Object.observe() and Promise enqueue v8 Microtasks |
| 43 // that should be executed just before control is returned to the message | 44 // that should be executed just before control is returned to the message |
| 44 // loop. This method adds a MessageLoop TaskObserver which runs any pending | 45 // loop. This method adds a MessageLoop TaskObserver which runs any pending |
| 45 // Microtasks each time a Task is completed. This method should be called | 46 // Microtasks each time a Task is completed. This method should be called |
| 46 // once, when a MessageLoop is created and it should be called on the | 47 // once, when a MessageLoop is created and it should be called on the |
| 47 // MessageLoop's thread. | 48 // MessageLoop's thread. |
| 48 void AddRunMicrotasksObserver(); | 49 void AddRunMicrotasksObserver(); |
| 49 | 50 |
| 50 // This method should also only be called once, and on the MessageLoop's | 51 // This method should also only be called once, and on the MessageLoop's |
| 51 // thread. | 52 // thread. |
| 52 void RemoveRunMicrotasksObserver(); | 53 void RemoveRunMicrotasksObserver(); |
| 53 | 54 |
| 54 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 55 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| 55 static const int kV8SnapshotBasePathKey; | |
| 56 static const char kNativesFileName[]; | |
| 57 static const char kSnapshotFileName[]; | |
| 58 | 56 |
| 59 static bool LoadV8SnapshotFd(int natives_fd, | 57 // Deprecated and to be removed: Use gin::V8Initializer::LoadV8Snapshot() |
| 60 int64 natives_offset, | 58 // Load V8 snapshot from default resources. Returns true on success or |
| 61 int64 natives_size, | 59 // snapshot is already loaded, false otherwise. |
| 62 int snapshot_fd, | |
| 63 int64 snapshot_offset, | |
| 64 int64 snapshot_size); | |
| 65 static bool LoadV8Snapshot(); | 60 static bool LoadV8Snapshot(); |
| 61 |
| 66 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 62 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 67 static void GetV8ExternalSnapshotData(const char** natives_data_out, | |
| 68 int* natives_size_out, | |
| 69 const char** snapshot_data_out, | |
| 70 int* snapshot_size_out); | |
| 71 | 63 |
| 72 private: | 64 private: |
| 73 v8::Isolate* isolate_; | 65 v8::Isolate* isolate_; |
| 74 scoped_ptr<PerIsolateData> isolate_data_; | 66 scoped_ptr<PerIsolateData> isolate_data_; |
| 75 scoped_ptr<RunMicrotasksObserver> task_observer_; | 67 scoped_ptr<RunMicrotasksObserver> task_observer_; |
| 76 | 68 |
| 77 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); | 69 DISALLOW_COPY_AND_ASSIGN(IsolateHolder); |
| 78 }; | 70 }; |
| 79 | 71 |
| 80 } // namespace gin | 72 } // namespace gin |
| 81 | 73 |
| 82 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ | 74 #endif // GIN_PUBLIC_ISOLATE_HOLDER_H_ |
| OLD | NEW |