| 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 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/tonic/dart_state.h" | 6 #include "sky/engine/tonic/dart_state.h" |
| 7 | 7 |
| 8 #include "sky/engine/tonic/dart_class_library.h" | 8 #include "sky/engine/tonic/dart_class_library.h" |
| 9 #include "sky/engine/tonic/dart_converter.h" | 9 #include "sky/engine/tonic/dart_converter.h" |
| 10 #include "sky/engine/tonic/dart_exception_factory.h" | 10 #include "sky/engine/tonic/dart_exception_factory.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 string_cache_(adoptPtr(new DartStringCache)), | 26 string_cache_(adoptPtr(new DartStringCache)), |
| 27 exception_factory_(adoptPtr(new DartExceptionFactory(this))), | 27 exception_factory_(adoptPtr(new DartExceptionFactory(this))), |
| 28 timer_heap_(adoptPtr(new DartTimerHeap())), | 28 timer_heap_(adoptPtr(new DartTimerHeap())), |
| 29 weak_factory_(this) { | 29 weak_factory_(this) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 DartState::~DartState() { | 32 DartState::~DartState() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 void DartState::SetIsolate(Dart_Isolate isolate) { | 35 void DartState::SetIsolate(Dart_Isolate isolate) { |
| 36 CHECK(!isolate_); | |
| 37 isolate_ = isolate; | 36 isolate_ = isolate; |
| 38 if (!isolate_) | 37 if (!isolate_) |
| 39 return; | 38 return; |
| 40 | 39 |
| 41 { | 40 { |
| 42 Scope dart_scope(this); | 41 Scope dart_scope(this); |
| 43 index_handle_.Set(this, ToDart("index")); | 42 index_handle_.Set(this, ToDart("index")); |
| 44 } | 43 } |
| 45 | 44 |
| 46 DidSetIsolate(); | 45 DidSetIsolate(); |
| 47 } | 46 } |
| 48 | 47 |
| 49 DartState* DartState::From(Dart_Isolate isolate) { | 48 DartState* DartState::From(Dart_Isolate isolate) { |
| 50 return static_cast<DartState*>(Dart_IsolateData(isolate)); | 49 return static_cast<DartState*>(Dart_IsolateData(isolate)); |
| 51 } | 50 } |
| 52 | 51 |
| 53 DartState* DartState::Current() { | 52 DartState* DartState::Current() { |
| 54 return static_cast<DartState*>(Dart_CurrentIsolateData()); | 53 return static_cast<DartState*>(Dart_CurrentIsolateData()); |
| 55 } | 54 } |
| 56 | 55 |
| 57 base::WeakPtr<DartState> DartState::GetWeakPtr() { | 56 base::WeakPtr<DartState> DartState::GetWeakPtr() { |
| 58 return weak_factory_.GetWeakPtr(); | 57 return weak_factory_.GetWeakPtr(); |
| 59 } | 58 } |
| 60 | 59 |
| 61 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |