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

Side by Side Diff: sky/engine/tonic/dart_value.h

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_string_cache.cc ('k') | sky/engine/tonic/dart_value.cc » ('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 #ifndef SKY_ENGINE_TONIC_DART_VALUE_H_
6 #define SKY_ENGINE_TONIC_DART_VALUE_H_
7
8 #include "base/logging.h"
9 #include "dart/runtime/include/dart_api.h"
10 #include "sky/engine/tonic/dart_persistent_value.h"
11 #include "sky/engine/tonic/dart_state.h"
12 #include "sky/engine/wtf/RefPtr.h"
13
14 namespace blink {
15
16 // DartValue is a convience wrapper around DartPersistentValue that lets clients
17 // use RefPtr to keep track of the number of references to the underlying Dart
18 // object. Be careful when retaining RefPtr<DartValue> in the heap because the
19 // VM's garbage collector cannot break cycles that involve the C++ heap, which
20 // can lead to memory leaks.
21 class DartValue : public RefCounted<DartValue> {
22 public:
23 static PassRefPtr<DartValue> Create(DartState* dart_state,
24 Dart_Handle value) {
25 return adoptRef(new DartValue(dart_state, value));
26 }
27
28 static PassRefPtr<DartValue> Create() { return adoptRef(new DartValue()); }
29
30 ~DartValue();
31
32 Dart_Handle dart_value() const { return dart_value_.value(); }
33 bool is_empty() const { return !dart_value(); }
34
35 bool is_null() const {
36 DCHECK(!is_empty());
37 return Dart_IsNull(dart_value());
38 }
39
40 bool is_function() const {
41 DCHECK(!is_empty());
42 return Dart_IsClosure(dart_value());
43 }
44
45 bool Equals(DartValue* other) const;
46 void Clear();
47
48 private:
49 DartValue();
50 DartValue(DartState* dart_state, Dart_Handle value);
51
52 DartPersistentValue dart_value_;
53
54 DISALLOW_COPY_AND_ASSIGN(DartValue);
55 };
56
57 } // namespace blink
58
59 #endif // SKY_ENGINE_TONIC_DART_VALUE_H_
OLDNEW
« no previous file with comments | « sky/engine/tonic/dart_string_cache.cc ('k') | sky/engine/tonic/dart_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698