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_SERVER_ENDPOINT_H_
6 #define MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_SERVER_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 server endpoint, i.e. a handle that can be used to send invitations
16 // as |MOJO_INVITATION_TRANSPORT_TYPE_CHANNEL_SERVER| to a remote
17 // PlatformChannelEndpoint.
COMPONENT_EXPORT(MOJO_CPP_PLATFORM)18 class COMPONENT_EXPORT(MOJO_CPP_PLATFORM) PlatformChannelServerEndpoint {
19  public:
20   PlatformChannelServerEndpoint();
21   PlatformChannelServerEndpoint(PlatformChannelServerEndpoint&& other);
22   explicit PlatformChannelServerEndpoint(PlatformHandle handle);
23   ~PlatformChannelServerEndpoint();
24 
25   PlatformChannelServerEndpoint& operator=(
26       PlatformChannelServerEndpoint&& other);
27 
28   bool is_valid() const { return handle_.is_valid(); }
29   void reset();
30   PlatformChannelServerEndpoint Clone() const;
31 
32   const PlatformHandle& platform_handle() const { return handle_; }
33 
34   PlatformHandle TakePlatformHandle() WARN_UNUSED_RESULT {
35     return std::move(handle_);
36   }
37 
38  private:
39   PlatformHandle handle_;
40 
41   DISALLOW_COPY_AND_ASSIGN(PlatformChannelServerEndpoint);
42 };
43 
44 }  // namespace mojo
45 
46 #endif  // MOJO_PUBLIC_CPP_PLATFORM_PLATFORM_CHANNEL_SERVER_ENDPOINT_H_
47