summaryrefslogtreecommitdiff
path: root/chromium/base/fuchsia/test_component_controller.h
blob: b13cc3296205a67ffe2f5c74c72dda9f04723593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_FUCHSIA_TEST_COMPONENT_CONTROLLER_H_
#define BASE_FUCHSIA_TEST_COMPONENT_CONTROLLER_H_

#include <fuchsia/sys/cpp/fidl.h>

#include "base/base_export.h"

namespace base {

// fuchsia.sys.ComponentController that requests the component to teardown
// gracefully, and waits for it to do so, when destroyed.
class BASE_EXPORT TestComponentController {
 public:
  TestComponentController();
  ~TestComponentController();

  TestComponentController(TestComponentController&&);
  TestComponentController& operator=(TestComponentController&&);

  explicit operator bool() const { return ptr_.is_bound(); }

  ::fuchsia::sys::ComponentControllerPtr& ptr() { return ptr_; }

  void KillAndRunUntilDisconnect();

 private:
  ::fuchsia::sys::ComponentControllerPtr ptr_;
};

}  // namespace base

#endif  // BASE_FUCHSIA_TEST_COMPONENT_CONTROLLER_H_