| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_PROTOCOL_MESSAGE_PIPE_H_ | 5 #ifndef REMOTING_PROTOCOL_MESSAGE_PIPE_H_ |
| 6 #define REMOTING_PROTOCOL_MESSAGE_PIPE_H_ | 6 #define REMOTING_PROTOCOL_MESSAGE_PIPE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 | 11 |
| 11 namespace google { | 12 namespace google { |
| 12 namespace protobuf { | 13 namespace protobuf { |
| 13 class MessageLite; | 14 class MessageLite; |
| 14 } // namespace protobuf | 15 } // namespace protobuf |
| 15 } // namespace google | 16 } // namespace google |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 class CompoundBuffer; | 20 class CompoundBuffer; |
| 20 | 21 |
| 21 namespace protocol { | 22 namespace protocol { |
| 22 | 23 |
| 23 // Represents a bi-directional pipe that allows to send and receive messages. | 24 // Represents a bi-directional pipe that allows to send and receive messages. |
| 24 class MessagePipe { | 25 class MessagePipe { |
| 25 public: | 26 public: |
| 26 typedef base::Callback<void(scoped_ptr<CompoundBuffer> message)> | 27 typedef base::Callback<void(std::unique_ptr<CompoundBuffer> message)> |
| 27 MessageReceivedCallback; | 28 MessageReceivedCallback; |
| 28 | 29 |
| 29 virtual ~MessagePipe() {} | 30 virtual ~MessagePipe() {} |
| 30 | 31 |
| 31 // Starts receiving incoming messages and calls |callback| for each message. | 32 // Starts receiving incoming messages and calls |callback| for each message. |
| 32 virtual void StartReceiving(const MessageReceivedCallback& callback) = 0; | 33 virtual void StartReceiving(const MessageReceivedCallback& callback) = 0; |
| 33 | 34 |
| 34 // Sends a message. |done| is called when the message has been sent to the | 35 // Sends a message. |done| is called when the message has been sent to the |
| 35 // client, but it doesn't mean that the client has received it. |done| is | 36 // client, but it doesn't mean that the client has received it. |done| is |
| 36 // never called if the message is never sent (e.g. if the pipe is destroyed | 37 // never called if the message is never sent (e.g. if the pipe is destroyed |
| 37 // before the message is sent). | 38 // before the message is sent). |
| 38 virtual void Send(google::protobuf::MessageLite* message, | 39 virtual void Send(google::protobuf::MessageLite* message, |
| 39 const base::Closure& done) = 0; | 40 const base::Closure& done) = 0; |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 } // namespace protocol | 43 } // namespace protocol |
| 43 } // namespace remoting | 44 } // namespace remoting |
| 44 | 45 |
| 45 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_ | 46 #endif // REMOTING_PROTOCOL_MESSAGE_PIPE_H_ |
| OLD | NEW |