• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium 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 MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_ENDPOINT_H_
6 #define MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_ENDPOINT_H_
7 
8 #include "base/component_export.h"
9 #include "base/macros.h"
10 #include "mojo/public/cpp/platform/platform_handle.h"
11 
12 namespace mojo {
13 
14 // A PlatformHandle with a little extra type information to convey that it's
15 // a channel endpoint, i.e. a handle that can be used to send or receive
16 // invitations as |MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL| to a remote
17 // PlatformChannelEndpoint.
COMPONENT_EXPORT(MOJO_CPP_PLATFORM)18 class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformChannelEndpoint {
19  public:
20   PlatformChannelEndpoint();
21   PlatformChannelEndpoint(PlatformChannelEndpoint&& other);
22   explicit PlatformChannelEndpoint(PlatformHandle handle);
23   ~PlatformChannelEndpoint();
24 
25   PlatformChannelEndpoint& operator=(PlatformChannelEndpoint&& other);
26 
27   bool is_valid() const { return handle_.is_valid(); }
28   void reset();
29   PlatformChannelEndpoint Clone() const;
30 
31   const PlatformHandle& platform_handle() const { return handle_; }
32 
33   PlatformHandle TakePlatformHandle() WARN_UNUSED_RESULT {
34     return std::move(handle_);
35   }
36 
37  private:
38   PlatformHandle handle_;
39 
40   DISALLOW_COPY_AND_ASSIGN(PlatformChannelEndpoint);
41 };
42 
43 }  // namespace mojo
44 
45 #endif  // MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_ENDPOINT_H_
46