| 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/wtf/OwnPtr.h" | 14 #include "sky/engine/wtf/OwnPtr.h" |
| 15 #include "sky/engine/wtf/PassRefPtr.h" | 15 #include "sky/engine/wtf/PassRefPtr.h" |
| 16 #include "sky/engine/wtf/RefCounted.h" | 16 #include "sky/engine/wtf/RefCounted.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 class DartStringCache; | |
| 20 class DartClassLibrary; | 19 class DartClassLibrary; |
| 21 class DartExceptionFactory; | 20 class DartExceptionFactory; |
| 21 class DartStringCache; |
| 22 class DartTimerHeap; |
| 22 | 23 |
| 23 // DartState represents the state associated with a given Dart isolate. The | 24 // DartState represents the state associated with a given Dart isolate. The |
| 24 // lifetime of this object is controlled by the DartVM. If you want to hold a | 25 // lifetime of this object is controlled by the DartVM. If you want to hold a |
| 25 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. | 26 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. |
| 26 // | 27 // |
| 27 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. | 28 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. |
| 28 class DartState : public base::SupportsUserData { | 29 class DartState : public base::SupportsUserData { |
| 29 public: | 30 public: |
| 30 class Scope { | 31 class Scope { |
| 31 public: | 32 public: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 | 48 |
| 48 Dart_Isolate isolate() { return isolate_; } | 49 Dart_Isolate isolate() { return isolate_; } |
| 49 void set_isolate(Dart_Isolate isolate) { | 50 void set_isolate(Dart_Isolate isolate) { |
| 50 CHECK(!isolate_); | 51 CHECK(!isolate_); |
| 51 isolate_ = isolate; | 52 isolate_ = isolate; |
| 52 } | 53 } |
| 53 | 54 |
| 54 DartClassLibrary& class_library() { return *class_library_; } | 55 DartClassLibrary& class_library() { return *class_library_; } |
| 55 DartStringCache& string_cache() { return *string_cache_; } | 56 DartStringCache& string_cache() { return *string_cache_; } |
| 56 DartExceptionFactory& exception_factory() { return *exception_factory_; } | 57 DartExceptionFactory& exception_factory() { return *exception_factory_; } |
| 58 DartTimerHeap& timer_heap() { return *timer_heap_; } |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 Dart_Isolate isolate_; | 61 Dart_Isolate isolate_; |
| 60 OwnPtr<DartClassLibrary> class_library_; | 62 OwnPtr<DartClassLibrary> class_library_; |
| 61 OwnPtr<DartStringCache> string_cache_; | 63 OwnPtr<DartStringCache> string_cache_; |
| 62 OwnPtr<DartExceptionFactory> exception_factory_; | 64 OwnPtr<DartExceptionFactory> exception_factory_; |
| 65 OwnPtr<DartTimerHeap> timer_heap_; |
| 63 | 66 |
| 64 base::WeakPtrFactory<DartState> weak_factory_; | 67 base::WeakPtrFactory<DartState> weak_factory_; |
| 65 | 68 |
| 66 DISALLOW_COPY_AND_ASSIGN(DartState); | 69 DISALLOW_COPY_AND_ASSIGN(DartState); |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 } // namespace blink | 72 } // namespace blink |
| 70 | 73 |
| 71 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ | 74 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ |
| OLD | NEW |