| 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" |
| 13 #include "sky/engine/tonic/dart_isolate_scope.h" |
| 12 #include "sky/engine/wtf/OwnPtr.h" | 14 #include "sky/engine/wtf/OwnPtr.h" |
| 13 #include "sky/engine/wtf/PassRefPtr.h" | 15 #include "sky/engine/wtf/PassRefPtr.h" |
| 14 #include "sky/engine/wtf/RefCounted.h" | 16 #include "sky/engine/wtf/RefCounted.h" |
| 15 | 17 |
| 16 namespace blink { | 18 namespace blink { |
| 17 class DartStringCache; | 19 class DartStringCache; |
| 18 class DartClassLibrary; | 20 class DartClassLibrary; |
| 19 class DartExceptionFactory; | 21 class DartExceptionFactory; |
| 20 | 22 |
| 21 // DartState represents the state associated with a given Dart isolate. The | 23 // DartState represents the state associated with a given Dart isolate. The |
| 22 // lifetime of this object is controlled by the DartVM. If you want to hold a | 24 // lifetime of this object is controlled by the DartVM. If you want to hold a |
| 23 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. | 25 // reference to a DartState instance, please hold a base::WeakPtr<DartState>. |
| 24 // | 26 // |
| 25 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. | 27 // DartState is analogous to gin::PerIsolateData and JSC::ExecState. |
| 26 class DartState : public base::SupportsUserData { | 28 class DartState : public base::SupportsUserData { |
| 27 public: | 29 public: |
| 28 class Scope { | 30 class Scope { |
| 29 public: | 31 public: |
| 30 Scope(DartState* dart_state); | 32 Scope(DartState* dart_state); |
| 31 ~Scope(); | 33 ~Scope(); |
| 34 |
| 35 private: |
| 36 DartIsolateScope scope_; |
| 37 DartApiScope api_scope_; |
| 32 }; | 38 }; |
| 33 | 39 |
| 34 DartState(); | 40 DartState(); |
| 35 virtual ~DartState(); | 41 virtual ~DartState(); |
| 36 | 42 |
| 37 static DartState* From(Dart_Isolate isolate); | 43 static DartState* From(Dart_Isolate isolate); |
| 38 static DartState* Current(); | 44 static DartState* Current(); |
| 39 | 45 |
| 40 base::WeakPtr<DartState> GetWeakPtr(); | 46 base::WeakPtr<DartState> GetWeakPtr(); |
| 41 | 47 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 56 OwnPtr<DartExceptionFactory> exception_factory_; | 62 OwnPtr<DartExceptionFactory> exception_factory_; |
| 57 | 63 |
| 58 base::WeakPtrFactory<DartState> weak_factory_; | 64 base::WeakPtrFactory<DartState> weak_factory_; |
| 59 | 65 |
| 60 DISALLOW_COPY_AND_ASSIGN(DartState); | 66 DISALLOW_COPY_AND_ASSIGN(DartState); |
| 61 }; | 67 }; |
| 62 | 68 |
| 63 } // namespace blink | 69 } // namespace blink |
| 64 | 70 |
| 65 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ | 71 #endif // SKY_ENGINE_TONIC_DART_STATE_H_ |
| OLD | NEW |