Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
root_inspect_node.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 FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_ROOT_INSPECT_NODE_H_
6#define FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_ROOT_INSPECT_NODE_H_
7
8#include <lib/inspect/component/cpp/component.h>
9#include <lib/sys/cpp/component_context.h>
10
11#include <memory>
12#include <mutex>
13
14namespace dart_utils {
15
16// This singleton object offers a way to create a new inspect node under the
17// root node in a thread safe way.
18//
19// Usage notes:
20// RootInspectNode::Initialize() must be invoked once in the program's
21// main before trying to obtain a child node.
23 private:
24 RootInspectNode() = default;
25 ~RootInspectNode() = default;
26
27 public:
28 // Initializes the underlying component inspector. Must be invoked at least
29 // once before calling CreateRootChild().
30 static void Initialize(sys::ComponentContext* context);
31
32 // Creates an inspect node which is a child of the component's root inspect
33 // node with the provided |name|.
34 static inspect::Node CreateRootChild(const std::string& name);
35
36 // Gets an instance to the component's inspector.
37 static inspect::Inspector* GetInspector();
38
39 private:
40 static std::unique_ptr<inspect::ComponentInspector> inspector_;
41 static std::mutex mutex_;
42};
43
44} // namespace dart_utils
45
46#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_ROOT_INSPECT_NODE_H_
static inspect::Inspector * GetInspector()
static void Initialize(sys::ComponentContext *context)
static inspect::Node CreateRootChild(const std::string &name)
const char * name
Definition fuchsia.cc:50