| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 const std::string& channel_name() { return channel_name_; } | 49 const std::string& channel_name() { return channel_name_; } |
| 50 | 50 |
| 51 // Returns true if the channel is currently connected. | 51 // Returns true if the channel is currently connected. |
| 52 bool is_connected() { return channel_ != nullptr; } | 52 bool is_connected() { return channel_ != nullptr; } |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 explicit ChannelDispatcherBase(const char* channel_name); | 55 explicit ChannelDispatcherBase(const char* channel_name); |
| 56 | 56 |
| 57 BufferedSocketWriter* writer() { return &writer_; } | 57 BufferedSocketWriter* writer() { return &writer_; } |
| 58 MessageReader* reader() { return &reader_; } | 58 |
| 59 // Child classes must override this method to handle incoming messages. |
| 60 virtual void OnIncomingMessage(scoped_ptr<CompoundBuffer> message) = 0; |
| 59 | 61 |
| 60 private: | 62 private: |
| 61 void OnChannelReady(scoped_ptr<P2PStreamSocket> socket); | 63 void OnChannelReady(scoped_ptr<P2PStreamSocket> socket); |
| 62 void OnReadWriteFailed(int error); | 64 void OnReadWriteFailed(int error); |
| 63 | 65 |
| 64 std::string channel_name_; | 66 std::string channel_name_; |
| 65 StreamChannelFactory* channel_factory_; | 67 StreamChannelFactory* channel_factory_; |
| 66 EventHandler* event_handler_; | 68 EventHandler* event_handler_; |
| 67 scoped_ptr<P2PStreamSocket> channel_; | 69 scoped_ptr<P2PStreamSocket> channel_; |
| 68 | 70 |
| 69 BufferedSocketWriter writer_; | 71 BufferedSocketWriter writer_; |
| 70 MessageReader reader_; | 72 MessageReader reader_; |
| 71 | 73 |
| 72 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); | 74 DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 } // namespace protocol | 77 } // namespace protocol |
| 76 } // namespace remoting | 78 } // namespace remoting |
| 77 | 79 |
| 78 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ | 80 #endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |
| OLD | NEW |