| 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 "sky/engine/tonic/dart_api_scope.h" | 12 #include "sky/engine/tonic/dart_api_scope.h" |
| 13 #include "sky/engine/tonic/dart_isolate_scope.h" | 13 #include "sky/engine/tonic/dart_isolate_scope.h" |
| 14 #include "sky/engine/tonic/dart_persistent_value.h" | 14 #include "sky/engine/tonic/dart_persistent_value.h" |
| 15 #include "sky/engine/wtf/OwnPtr.h" | 15 #include "sky/engine/wtf/OwnPtr.h" |
| 16 #include "sky/engine/wtf/PassRefPtr.h" | 16 #include "sky/engine/wtf/PassRefPtr.h" |
| 17 #include "sky/engine/wtf/RefCounted.h" | 17 #include "sky/engine/wtf/RefCounted.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 class DartClassLibrary; | 20 class DartClassLibrary; |
| 21 class DartExceptionFactory; | 21 class DartExceptionFactory; |
| 22 class DartLibraryLoader; |
| 22 class DartStringCache; | 23 class DartStringCache; |
| 23 class DartTimerHeap; | 24 class DartTimerHeap; |
| 24 | 25 |
| 25 // DartState represents the state associated with a given Dart isolate. The | 26 // DartState represents the state associated with a given Dart isolate. The |
| 26 // lifetime of this object is controlled by the DartVM. If you want to hold a | 27 // lifetime of this object is controlled by the DartVM. If you want to hold a |
| 27 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. | 28 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. |
| 28 // | 29 // |
| 29 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. | 30 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. |
| 30 class DartState : public base::SupportsUserData { | 31 class DartState : public base::SupportsUserData { |
| 31 public: | 32 public: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 static DartState* From(Dart_Isolate isolate); | 46 static DartState* From(Dart_Isolate isolate); |
| 46 static DartState* Current(); | 47 static DartState* Current(); |
| 47 | 48 |
| 48 base::WeakPtr<DartState> GetWeakPtr(); | 49 base::WeakPtr<DartState> GetWeakPtr(); |
| 49 | 50 |
| 50 Dart_Isolate isolate() { return isolate_; } | 51 Dart_Isolate isolate() { return isolate_; } |
| 51 void SetIsolate(Dart_Isolate isolate); | 52 void SetIsolate(Dart_Isolate isolate); |
| 52 | 53 |
| 53 DartClassLibrary& class_library() { return *class_library_; } | 54 DartClassLibrary& class_library() { return *class_library_; } |
| 55 DartExceptionFactory& exception_factory() { return *exception_factory_; } |
| 56 DartLibraryLoader& library_loader() { return *library_loader_; } |
| 54 DartStringCache& string_cache() { return *string_cache_; } | 57 DartStringCache& string_cache() { return *string_cache_; } |
| 55 DartExceptionFactory& exception_factory() { return *exception_factory_; } | |
| 56 DartTimerHeap& timer_heap() { return *timer_heap_; } | 58 DartTimerHeap& timer_heap() { return *timer_heap_; } |
| 57 | 59 |
| 58 Dart_Handle index_handle() { return index_handle_.value(); } | 60 Dart_Handle index_handle() { return index_handle_.value(); } |
| 59 | 61 |
| 60 virtual void DidSetIsolate() {} | 62 virtual void DidSetIsolate() {} |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 Dart_Isolate isolate_; | 65 Dart_Isolate isolate_; |
| 64 OwnPtr<DartClassLibrary> class_library_; | 66 OwnPtr<DartClassLibrary> class_library_; |
| 67 OwnPtr<DartExceptionFactory> exception_factory_; |
| 68 OwnPtr<DartLibraryLoader> library_loader_; |
| 65 OwnPtr<DartStringCache> string_cache_; | 69 OwnPtr<DartStringCache> string_cache_; |
| 66 OwnPtr<DartExceptionFactory> exception_factory_; | |
| 67 OwnPtr<DartTimerHeap> timer_heap_; | 70 OwnPtr<DartTimerHeap> timer_heap_; |
| 68 DartPersistentValue index_handle_; | 71 DartPersistentValue index_handle_; |
| 69 | 72 |
| 70 protected: | 73 protected: |
| 71 base::WeakPtrFactory<DartState> weak_factory_; | 74 base::WeakPtrFactory<DartState> weak_factory_; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(DartState); | 76 DISALLOW_COPY_AND_ASSIGN(DartState); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace blink | 79 } // namespace blink |
| 77 | 80 |
| 78 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ | 81 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ |
| OLD | NEW |