• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 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_BINDINGS_PIPE_CONTROL_MESSAGE_PROXY_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_PROXY_H_
7 
8 #include "base/macros.h"
9 #include "base/optional.h"
10 #include "mojo/public/cpp/bindings/bindings_export.h"
11 #include "mojo/public/cpp/bindings/disconnect_reason.h"
12 #include "mojo/public/cpp/bindings/interface_id.h"
13 #include "mojo/public/cpp/bindings/lib/serialization_context.h"
14 #include "mojo/public/cpp/bindings/message.h"
15 
16 namespace mojo {
17 
18 class MessageReceiver;
19 
20 // Proxy for request messages defined in pipe_control_messages.mojom.
21 //
22 // NOTE: This object may be used from multiple sequences.
23 class MOJO_CPP_BINDINGS_EXPORT PipeControlMessageProxy {
24  public:
25   // Doesn't take ownership of |receiver|. If This PipeControlMessageProxy will
26   // be used from multiple sequences, |receiver| must be thread-safe.
27   explicit PipeControlMessageProxy(MessageReceiver* receiver);
28 
29   void NotifyPeerEndpointClosed(InterfaceId id,
30                                 const base::Optional<DisconnectReason>& reason);
31 
32   static Message ConstructPeerEndpointClosedMessage(
33       InterfaceId id,
34       const base::Optional<DisconnectReason>& reason);
35 
36  private:
37   // Not owned.
38   MessageReceiver* receiver_;
39 
40   DISALLOW_COPY_AND_ASSIGN(PipeControlMessageProxy);
41 };
42 
43 }  // namespace mojo
44 
45 #endif  // MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_PROXY_H_
46