Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: remoting/protocol/fake_message_pipe.h

Issue 2907073003: [Chromoting] Add DataChannelManager to manage optional incoming data channels (Closed)
Patch Set: Fix test failure without DCHECK Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_H_
6 #define REMOTING_PROTOCOL_FAKE_MESSAGE_PIPE_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 FakeMessagePipeWrapper;
22
23 class FakeMessagePipe final : public MessagePipe {
24 public:
25 explicit FakeMessagePipe(bool asynchronous);
26 ~FakeMessagePipe() override;
27
28 // Creates an std::unique_ptr<FakeMessagePipeWrapper> instance to wrap |this|.
29 // All operations will be forwarded to |this| except for the destructor.
30 //
31 // Most of the components take ownership of std::unique_ptr<MessagePipe>,
32 // which makes the test cases hard to maintain the lifetime of a
33 // FakeMessagePipe. So this function creates a "weak" unique_ptr of this
34 // instance to let the test case decide the lifetime of a FakeMessagePipe.
35 std::unique_ptr<FakeMessagePipeWrapper> Wrap();
36
37 // MessagePipe implementation.
38 void Start(EventHandler* event_handler) override;
39 void Send(google::protobuf::MessageLite* message,
40 const base::Closure& done) override;
41
42 // Forwards |message| to EventHandler.
43 void Receive(std::unique_ptr<CompoundBuffer> message);
44
45 // Simulates the operation to open the pipe.
46 void OpenPipe();
47
48 // Simulates the operation to close the pipe.
49 void ClosePipe();
50
51 private:
52 void SendImpl(google::protobuf::MessageLite* message,
53 const base::Closure& done);
54 void ReceiveImpl(std::unique_ptr<CompoundBuffer> message);
55 void OpenPipeImpl();
56 void ClosePipeImpl();
57
58 const bool asynchronous_;
59 bool pipe_opened_ = false;
60 EventHandler* event_handler_ = nullptr;
61 };
62
63 } // namespace protocol
64 } // namespace remoting
65
66 #endif // REMOTING_PROTOCOL_FAKE_MESSAGE_PIPE_H_
OLDNEW
« no previous file with comments | « remoting/protocol/data_channel_manager_unittest.cc ('k') | remoting/protocol/fake_message_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698