summaryrefslogtreecommitdiff
path: root/mojo/public/cpp/system/watcher.h
blob: d0a257814d74bfe4c618ed4371d35a22e4ff9e27 (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
37
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_
#define MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_

#include "mojo/public/c/system/types.h"
#include "mojo/public/c/system/watcher.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/cpp/system/system_export.h"

namespace mojo {

// A strongly-typed representation of a |MojoHandle| for a watcher.
class WatcherHandle : public Handle {
 public:
  WatcherHandle() = default;
  explicit WatcherHandle(MojoHandle value) : Handle(value) {}

  // Copying and assignment allowed.
};

static_assert(sizeof(WatcherHandle) == sizeof(Handle),
              "Bad size for C++ WatcherHandle");

typedef ScopedHandleBase<WatcherHandle> ScopedWatcherHandle;
static_assert(sizeof(ScopedWatcherHandle) == sizeof(WatcherHandle),
              "Bad size for C++ ScopedWatcherHandle");

MOJO_CPP_SYSTEM_EXPORT MojoResult
CreateWatcher(MojoWatcherCallback callback,
              ScopedWatcherHandle* watcher_handle);

}  // namespace mojo

#endif  // MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_