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

Side by Side Diff: tonic/dart_value.h

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

Powered by Google App Engine
This is Rietveld 408576698