OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "tonic/dart_state.h" |
| 6 |
| 7 #include "tonic/dart_class_library.h" |
| 8 #include "tonic/dart_converter.h" |
| 9 #include "tonic/dart_exception_factory.h" |
| 10 #include "tonic/dart_library_loader.h" |
| 11 #include "tonic/dart_string_cache.h" |
| 12 #include "tonic/dart_timer_heap.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 DartState::Scope::Scope(DartState* dart_state) : scope_(dart_state->isolate()) { |
| 17 } |
| 18 |
| 19 DartState::Scope::~Scope() { |
| 20 } |
| 21 |
| 22 DartState::DartState() |
| 23 : isolate_(NULL), |
| 24 class_library_(std::unique_ptr<DartClassLibrary>(new DartClassLibrary)), |
| 25 exception_factory_(std::unique_ptr<DartExceptionFactory>( |
| 26 new DartExceptionFactory(this))), |
| 27 library_loader_(std::unique_ptr<DartLibraryLoader>( |
| 28 new DartLibraryLoader(this))), |
| 29 string_cache_(std::unique_ptr<DartStringCache>( |
| 30 new DartStringCache)), |
| 31 timer_heap_(std::unique_ptr<DartTimerHeap>( |
| 32 new DartTimerHeap())), |
| 33 weak_factory_(this) { |
| 34 } |
| 35 |
| 36 DartState::~DartState() { |
| 37 } |
| 38 |
| 39 void DartState::SetIsolate(Dart_Isolate isolate) { |
| 40 isolate_ = isolate; |
| 41 if (!isolate_) |
| 42 return; |
| 43 |
| 44 { |
| 45 Scope dart_scope(this); |
| 46 index_handle_.Set(this, ToDart("index")); |
| 47 } |
| 48 |
| 49 DidSetIsolate(); |
| 50 } |
| 51 |
| 52 DartState* DartState::From(Dart_Isolate isolate) { |
| 53 return static_cast<DartState*>(Dart_IsolateData(isolate)); |
| 54 } |
| 55 |
| 56 DartState* DartState::Current() { |
| 57 return static_cast<DartState*>(Dart_CurrentIsolateData()); |
| 58 } |
| 59 |
| 60 base::WeakPtr<DartState> DartState::GetWeakPtr() { |
| 61 return weak_factory_.GetWeakPtr(); |
| 62 } |
| 63 |
| 64 } // namespace blink |
OLD | NEW |