Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
dart_persistent_value.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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 LIB_TONIC_DART_PERSISTENT_VALUE_H_
6#define LIB_TONIC_DART_PERSISTENT_VALUE_H_
7
8#include <memory>
9
10#include "third_party/dart/runtime/include/dart_api.h"
11#include "tonic/common/macros.h"
12
13namespace tonic {
14class DartState;
15
16// DartPersistentValue is a bookkeeping class to help pair calls to
17// Dart_NewPersistentHandle with Dart_DeletePersistentHandle. Consider using
18// this class instead of holding a Dart_PersistentHandle directly so that you
19// don't leak the Dart_PersistentHandle.
21 public:
26
27 Dart_PersistentHandle value() const { return value_; }
28 bool is_empty() const { return !value_; }
29
31 void Clear();
34
35 const std::weak_ptr<DartState>& dart_state() const { return dart_state_; }
36
37 private:
38 std::weak_ptr<DartState> dart_state_;
40
42};
43
44} // namespace tonic
45
46#endif // LIB_TONIC_DART_PERSISTENT_VALUE_H_
const std::weak_ptr< DartState > & dart_state() const
Dart_PersistentHandle value() const
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
Dart_Handle Dart_PersistentHandle
Definition dart_api.h:259
#define TONIC_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:19