| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // TODO(sergeyu): Move error codes to a separate file. | 52 // TODO(sergeyu): Move error codes to a separate file. |
| 53 enum Error { | 53 enum Error { |
| 54 OK = 0, | 54 OK = 0, |
| 55 PEER_IS_OFFLINE, | 55 PEER_IS_OFFLINE, |
| 56 SESSION_REJECTED, | 56 SESSION_REJECTED, |
| 57 INCOMPATIBLE_PROTOCOL, | 57 INCOMPATIBLE_PROTOCOL, |
| 58 CHANNEL_CONNECTION_ERROR, | 58 CHANNEL_CONNECTION_ERROR, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 typedef Callback1<State>::Type StateChangeCallback; | 61 typedef base::Callback<void(State)> StateChangeCallback; |
| 62 | 62 |
| 63 // TODO(sergeyu): Specify connection error code when channel | 63 // TODO(sergeyu): Specify connection error code when channel |
| 64 // connection fails. | 64 // connection fails. |
| 65 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; | 65 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; |
| 66 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; | 66 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; |
| 67 | 67 |
| 68 Session() { } | 68 Session() { } |
| 69 virtual ~Session() { } | 69 virtual ~Session() { } |
| 70 | 70 |
| 71 // Set callback that is called when state of the connection is changed. | 71 // Set callback that is called when state of the connection is changed. |
| 72 // Must be called on the jingle thread only. | 72 // Must be called on the jingle thread only. |
| 73 virtual void SetStateChangeCallback(StateChangeCallback* callback) = 0; | 73 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; |
| 74 | 74 |
| 75 // Returns error code for a failed session. | 75 // Returns error code for a failed session. |
| 76 virtual Error error() = 0; | 76 virtual Error error() = 0; |
| 77 | 77 |
| 78 // Creates new channels for this connection. The specified callback | 78 // Creates new channels for this connection. The specified callback |
| 79 // is called when then new channel is created and connected. The | 79 // is called when then new channel is created and connected. The |
| 80 // callback is called with NULL if connection failed for any reason. | 80 // callback is called with NULL if connection failed for any reason. |
| 81 // Ownership of the channel socket is given to the caller when the | 81 // Ownership of the channel socket is given to the caller when the |
| 82 // callback is called. All channels must be destroyed before the | 82 // callback is called. All channels must be destroyed before the |
| 83 // session is destroyed. Can be called only when in CONNECTING or | 83 // session is destroyed. Can be called only when in CONNECTING or |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 virtual void Close() = 0; | 125 virtual void Close() = 0; |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 DISALLOW_COPY_AND_ASSIGN(Session); | 128 DISALLOW_COPY_AND_ASSIGN(Session); |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 } // namespace protocol | 131 } // namespace protocol |
| 132 } // namespace remoting | 132 } // namespace remoting |
| 133 | 133 |
| 134 #endif // REMOTING_PROTOCOL_SESSION_H_ | 134 #endif // REMOTING_PROTOCOL_SESSION_H_ |
| OLD | NEW |