1 // Copyright 2017 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 REMOTING_PROTOCOL_FAKE_MESSAGE_PIPE_WRAPPER_H_
6 #define REMOTING_PROTOCOL_FAKE_MESSAGE_PIPE_WRAPPER_H_
7 
8 #include <memory>
9 
10 #include "remoting/protocol/message_pipe.h"
11 
12 namespace google {
13 namespace protobuf {
14 class MessageLite;
15 }  // namespace protobuf
16 }  // namespace google
17 
18 namespace remoting {
19 namespace protocol {
20 
21 class FakeMessagePipe;
22 
23 // This class should not be used explicitly: use FakeMessagePipe::Wrap().
24 class FakeMessagePipeWrapper final : public MessagePipe {
25  public:
26   // |pipe| must outlive this instance.
27   explicit FakeMessagePipeWrapper(FakeMessagePipe* pipe);
28   ~FakeMessagePipeWrapper() override;
29 
30   // MessagePipe implementation.
31   void Start(EventHandler* event_handler) override;
32   void Send(google::protobuf::MessageLite* message,
33             base::OnceClosure done) override;
34 
35   void Receive(std::unique_ptr<CompoundBuffer> message);
36   void OpenPipe();
37   void ClosePipe();
38 
39  private:
40   FakeMessagePipe* const pipe_;
41 };
42 
43 }  // namespace protocol
44 }  // namespace remoting
45 
46 #endif  // REMOTING_PROTOCOL_FAKE_MESSAGE_PIPE_WRAPPER_H_
47