OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SKY_ENGINE_TONIC_DART_STATE_H_ | 5 #ifndef SKY_ENGINE_TONIC_DART_STATE_H_ |
6 #define SKY_ENGINE_TONIC_DART_STATE_H_ | 6 #define SKY_ENGINE_TONIC_DART_STATE_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
11 #include "dart/runtime/include/dart_api.h" | 11 #include "dart/runtime/include/dart_api.h" |
12 #include "tonic/dart_api_scope.h" | 12 #include "tonic/dart_api_scope.h" |
13 #include "tonic/dart_isolate_scope.h" | 13 #include "tonic/dart_isolate_scope.h" |
14 #include "tonic/dart_persistent_value.h" | 14 #include "tonic/dart_persistent_value.h" |
15 | 15 |
16 namespace blink { | 16 namespace tonic { |
17 class DartClassLibrary; | 17 class DartClassLibrary; |
18 class DartExceptionFactory; | 18 class DartExceptionFactory; |
19 class DartLibraryLoader; | 19 class DartLibraryLoader; |
20 class DartTimerHeap; | 20 class DartTimerHeap; |
21 | 21 |
22 // DartState represents the state associated with a given Dart isolate. The | 22 // DartState represents the state associated with a given Dart isolate. The |
23 // lifetime of this object is controlled by the DartVM. If you want to hold a | 23 // lifetime of this object is controlled by the DartVM. If you want to hold a |
24 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. | 24 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. |
25 // | 25 // |
26 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. | 26 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. |
27 class DartState : public base::SupportsUserData { | 27 class DartState : public base::SupportsUserData { |
28 public: | 28 public: |
29 class Scope { | 29 class Scope { |
30 public: | 30 public: |
31 Scope(DartState* dart_state); | 31 Scope(DartState* dart_state); |
32 ~Scope(); | 32 ~Scope(); |
33 | 33 |
34 private: | 34 private: |
35 DartIsolateScope scope_; | 35 DartIsolateScope scope_; |
36 DartApiScope api_scope_; | 36 DartApiScope api_scope_; |
37 }; | 37 }; |
38 | 38 |
39 DartState(); | 39 DartState(); |
40 virtual ~DartState(); | 40 ~DartState() override; |
41 | 41 |
42 static DartState* From(Dart_Isolate isolate); | 42 static DartState* From(Dart_Isolate isolate); |
43 static DartState* Current(); | 43 static DartState* Current(); |
44 | 44 |
45 base::WeakPtr<DartState> GetWeakPtr(); | 45 base::WeakPtr<DartState> GetWeakPtr(); |
46 | 46 |
47 Dart_Isolate isolate() { return isolate_; } | 47 Dart_Isolate isolate() { return isolate_; } |
48 void SetIsolate(Dart_Isolate isolate); | 48 void SetIsolate(Dart_Isolate isolate); |
49 | 49 |
50 DartClassLibrary& class_library() { return *class_library_; } | 50 DartClassLibrary& class_library() { return *class_library_; } |
(...skipping 12 matching lines...) Expand all Loading... |
63 std::unique_ptr<DartLibraryLoader> library_loader_; | 63 std::unique_ptr<DartLibraryLoader> library_loader_; |
64 std::unique_ptr<DartTimerHeap> timer_heap_; | 64 std::unique_ptr<DartTimerHeap> timer_heap_; |
65 DartPersistentValue index_handle_; | 65 DartPersistentValue index_handle_; |
66 | 66 |
67 protected: | 67 protected: |
68 base::WeakPtrFactory<DartState> weak_factory_; | 68 base::WeakPtrFactory<DartState> weak_factory_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(DartState); | 70 DISALLOW_COPY_AND_ASSIGN(DartState); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace blink | 73 } // namespace tonic |
74 | 74 |
75 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ | 75 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ |
OLD | NEW |