Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: sky/engine/tonic/dart_persistent_value.cc

Issue 924593002: Merge the tonic layer from skydart branch back to master (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/tonic/dart_persistent_value.h ('k') | sky/engine/tonic/dart_state.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "sky/engine/config.h"
6 #include "sky/engine/tonic/dart_persistent_value.h"
7
8 #include "sky/engine/tonic/dart_isolate_scope.h"
9 #include "sky/engine/tonic/dart_state.h"
10
11 namespace blink {
12
13 DartPersistentValue::DartPersistentValue() : value_(nullptr) {
14 }
15
16 DartPersistentValue::DartPersistentValue(DartState* dart_state,
17 Dart_Handle value)
18 : value_(nullptr) {
19 Set(dart_state, value);
20 }
21
22 DartPersistentValue::~DartPersistentValue() {
23 Clear();
24 }
25
26 void DartPersistentValue::Set(DartState* dart_state, Dart_Handle value) {
27 DCHECK(is_empty());
28 dart_state_ = dart_state->GetWeakPtr();
29 value_ = Dart_NewPersistentHandle(value);
30 }
31
32 void DartPersistentValue::Clear() {
33 if (!value_ || !dart_state_.get())
34 return;
35
36 DartIsolateScope scope(dart_state_->isolate());
37 Dart_DeletePersistentHandle(value_);
38 dart_state_ = base::WeakPtr<DartState>();
39 value_ = nullptr;
40 }
41
42 Dart_Handle DartPersistentValue::Release() {
43 if (!value_)
44 return nullptr;
45 Dart_Handle local = Dart_HandleFromPersistent(value_);
46 Clear();
47 return local;
48 }
49 }
OLDNEW
« no previous file with comments | « sky/engine/tonic/dart_persistent_value.h ('k') | sky/engine/tonic/dart_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698