Flutter Engine
unique_fdio_ns.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 #pragma once
6 
7 #include "flutter/fml/logging.h"
8 #include "flutter/fml/unique_object.h"
9 #include "lib/fdio/namespace.h"
10 
11 namespace flutter_runner {
12 
14  static fdio_ns_t* InvalidValue() { return nullptr; }
15 
16  static bool IsValid(fdio_ns_t* ns) { return ns != InvalidValue(); }
17 
18  static void Free(fdio_ns_t* ns) {
19  auto status = fdio_ns_destroy(ns);
20  FML_DCHECK(status == ZX_OK);
21  }
22 };
23 
25 
27  fdio_ns_t* ns = nullptr;
28  if (fdio_ns_create(&ns) == ZX_OK) {
29  return UniqueFDIONS{ns};
30  }
31  return UniqueFDIONS{nullptr};
32 }
33 
34 } // namespace flutter_runner
static void Free(fdio_ns_t *ns)
#define FML_DCHECK(condition)
Definition: logging.h:86
static bool IsValid(fdio_ns_t *ns)
UniqueFDIONS UniqueFDIONSCreate()
static fdio_ns_t * InvalidValue()