| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SESSION_H_ | 5 #ifndef REMOTING_PROTOCOL_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_SESSION_H_ | 6 #define REMOTING_PROTOCOL_SESSION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // TODO(sergeyu): Remove this state. | 42 // TODO(sergeyu): Remove this state. |
| 43 CONNECTED_CHANNELS, | 43 CONNECTED_CHANNELS, |
| 44 | 44 |
| 45 // Session has been closed. | 45 // Session has been closed. |
| 46 CLOSED, | 46 CLOSED, |
| 47 | 47 |
| 48 // Connection has failed. | 48 // Connection has failed. |
| 49 FAILED, | 49 FAILED, |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 enum Error { |
| 53 OK = 0, |
| 54 PEER_IS_OFFLINE, |
| 55 SESSION_REJECTED, |
| 56 INCOMPATIBLE_PROTOCOL, |
| 57 CHANNEL_CONNECTION_ERROR, |
| 58 }; |
| 59 |
| 52 typedef Callback1<State>::Type StateChangeCallback; | 60 typedef Callback1<State>::Type StateChangeCallback; |
| 53 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; | 61 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; |
| 54 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; | 62 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; |
| 55 | 63 |
| 56 Session() { } | 64 Session() { } |
| 57 virtual ~Session() { } | 65 virtual ~Session() { } |
| 58 | 66 |
| 59 // Set callback that is called when state of the connection is changed. | 67 // Set callback that is called when state of the connection is changed. |
| 60 // Must be called on the jingle thread only. | 68 // Must be called on the jingle thread only. |
| 61 virtual void SetStateChangeCallback(StateChangeCallback* callback) = 0; | 69 virtual void SetStateChangeCallback(StateChangeCallback* callback) = 0; |
| 62 | 70 |
| 71 // Returns error code for a failed session. |
| 72 virtual Error error() = 0; |
| 73 |
| 63 // Creates new channels for this connection. The specified callback | 74 // Creates new channels for this connection. The specified callback |
| 64 // is called when then new channel is created and connected. The | 75 // is called when then new channel is created and connected. The |
| 65 // callback is called with NULL if connection failed for any reason. | 76 // callback is called with NULL if connection failed for any reason. |
| 66 // Ownership of the channel socket is given to the caller when the | 77 // Ownership of the channel socket is given to the caller when the |
| 67 // callback is called. All channels must be destroyed before the | 78 // callback is called. All channels must be destroyed before the |
| 68 // session is destroyed. Can be called only when in CONNECTING or | 79 // session is destroyed. Can be called only when in CONNECTING or |
| 69 // CONNECTED state. | 80 // CONNECTED state. |
| 70 virtual void CreateStreamChannel( | 81 virtual void CreateStreamChannel( |
| 71 const std::string& name, const StreamChannelCallback& callback) = 0; | 82 const std::string& name, const StreamChannelCallback& callback) = 0; |
| 72 virtual void CreateDatagramChannel( | 83 virtual void CreateDatagramChannel( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 virtual void Close() = 0; | 121 virtual void Close() = 0; |
| 111 | 122 |
| 112 private: | 123 private: |
| 113 DISALLOW_COPY_AND_ASSIGN(Session); | 124 DISALLOW_COPY_AND_ASSIGN(Session); |
| 114 }; | 125 }; |
| 115 | 126 |
| 116 } // namespace protocol | 127 } // namespace protocol |
| 117 } // namespace remoting | 128 } // namespace remoting |
| 118 | 129 |
| 119 #endif // REMOTING_PROTOCOL_SESSION_H_ | 130 #endif // REMOTING_PROTOCOL_SESSION_H_ |
| OLD | NEW |