| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHANNEL_DISPATCHER_BASE_H_ | 5 #ifndef REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
| 6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 6 #define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "remoting/protocol/errors.h" | 13 #include "remoting/protocol/errors.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 class CompoundBuffer; | 17 class CompoundBuffer; |
| 18 | 18 |
| 19 namespace protocol { | 19 namespace protocol { |
| 20 | 20 |
| 21 class MessageChannelFactory; | 21 class MessageChannelFactory; |
| 22 class MessagePipe; | 22 class MessagePipe; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 // Returns true if the channel is currently connected. | 52 // Returns true if the channel is currently connected. |
| 53 bool is_connected() { return message_pipe() != nullptr; } | 53 bool is_connected() { return message_pipe() != nullptr; } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 explicit ChannelDispatcherBase(const char* channel_name); | 56 explicit ChannelDispatcherBase(const char* channel_name); |
| 57 | 57 |
| 58 MessagePipe* message_pipe() { return message_pipe_.get(); } | 58 MessagePipe* message_pipe() { return message_pipe_.get(); } |
| 59 | 59 |
| 60 // Child classes must override this method to handle incoming messages. | 60 // Child classes must override this method to handle incoming messages. |
| 61 virtual void OnIncomingMessage(scoped_ptr<CompoundBuffer> message) = 0; | 61 virtual void OnIncomingMessage(std::unique_ptr<CompoundBuffer> message) = 0; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void OnChannelReady(scoped_ptr<MessagePipe> message_pipe); | 64 void OnChannelReady(std::unique_ptr<MessagePipe> message_pipe); |
| 65 void OnPipeError(int error); | 65 void OnPipeError(int error); |
| 66 | 66 |
| 67 std::string channel_name_; | 67 std::string channel_name_; |
| 68 MessageChannelFactory* channel_factory_ = nullptr; | 68 MessageChannelFactory* channel_factory_ = nullptr; |
| 69 EventHandler* event_handler_ = nullptr; | 69 EventHandler* event_handler_ = nullptr; |
| 70 | 70 |
| 71 scoped_ptr<MessagePipe> message_pipe_; | 71 std::unique_ptr<MessagePipe> message_pipe_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); | 73 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace protocol | 76 } // namespace protocol |
| 77 } // namespace remoting | 77 } // namespace remoting |
| 78 | 78 |
| 79 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 79 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
| OLD | NEW |