| 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/wtf/OwnPtr.h" | 15 #include "sky/engine/wtf/OwnPtr.h" |
| 15 #include "sky/engine/wtf/PassRefPtr.h" | 16 #include "sky/engine/wtf/PassRefPtr.h" |
| 16 #include "sky/engine/wtf/RefCounted.h" | 17 #include "sky/engine/wtf/RefCounted.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 class DartClassLibrary; | 20 class DartClassLibrary; |
| 20 class DartExceptionFactory; | 21 class DartExceptionFactory; |
| 21 class DartStringCache; | 22 class DartStringCache; |
| 22 class DartTimerHeap; | 23 class DartTimerHeap; |
| 23 | 24 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 static DartState* From(Dart_Isolate isolate); | 45 static DartState* From(Dart_Isolate isolate); |
| 45 static DartState* Current(); | 46 static DartState* Current(); |
| 46 | 47 |
| 47 base::WeakPtr<DartState> GetWeakPtr(); | 48 base::WeakPtr<DartState> GetWeakPtr(); |
| 48 | 49 |
| 49 Dart_Isolate isolate() { return isolate_; } | 50 Dart_Isolate isolate() { return isolate_; } |
| 50 void set_isolate(Dart_Isolate isolate) { | 51 void set_isolate(Dart_Isolate isolate) { |
| 51 CHECK(!isolate_); | 52 CHECK(!isolate_); |
| 52 isolate_ = isolate; | 53 isolate_ = isolate; |
| 53 DidSetIsolate(); | 54 DidSetIsolateInternal(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 DartClassLibrary& class_library() { return *class_library_; } | 57 DartClassLibrary& class_library() { return *class_library_; } |
| 57 DartStringCache& string_cache() { return *string_cache_; } | 58 DartStringCache& string_cache() { return *string_cache_; } |
| 58 DartExceptionFactory& exception_factory() { return *exception_factory_; } | 59 DartExceptionFactory& exception_factory() { return *exception_factory_; } |
| 59 DartTimerHeap& timer_heap() { return *timer_heap_; } | 60 DartTimerHeap& timer_heap() { return *timer_heap_; } |
| 60 | 61 |
| 62 Dart_Handle index_handle() { return index_handle_.value(); } |
| 63 |
| 61 virtual void DidSetIsolate() {} | 64 virtual void DidSetIsolate() {} |
| 62 | 65 |
| 63 private: | 66 private: |
| 67 void DidSetIsolateInternal(); |
| 68 |
| 64 Dart_Isolate isolate_; | 69 Dart_Isolate isolate_; |
| 65 OwnPtr<DartClassLibrary> class_library_; | 70 OwnPtr<DartClassLibrary> class_library_; |
| 66 OwnPtr<DartStringCache> string_cache_; | 71 OwnPtr<DartStringCache> string_cache_; |
| 67 OwnPtr<DartExceptionFactory> exception_factory_; | 72 OwnPtr<DartExceptionFactory> exception_factory_; |
| 68 OwnPtr<DartTimerHeap> timer_heap_; | 73 OwnPtr<DartTimerHeap> timer_heap_; |
| 69 | 74 |
| 70 base::WeakPtrFactory<DartState> weak_factory_; | 75 base::WeakPtrFactory<DartState> weak_factory_; |
| 76 DartPersistentValue index_handle_; |
| 71 | 77 |
| 72 DISALLOW_COPY_AND_ASSIGN(DartState); | 78 DISALLOW_COPY_AND_ASSIGN(DartState); |
| 73 }; | 79 }; |
| 74 | 80 |
| 75 } // namespace blink | 81 } // namespace blink |
| 76 | 82 |
| 77 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ | 83 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ |
| OLD | NEW |