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" |
11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
12 #include "remoting/protocol/buffered_socket_writer.h" | 12 #include "remoting/protocol/buffered_socket_writer.h" |
13 #include "remoting/protocol/session_config.h" | 13 #include "remoting/protocol/session_config.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
| 16 class IPEndPoint; |
16 class Socket; | 17 class Socket; |
17 class StreamSocket; | 18 class StreamSocket; |
18 } // namespace net | 19 } // namespace net |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 namespace protocol { | 22 namespace protocol { |
22 | 23 |
23 // Generic interface for Chromotocol connection used by both client and host. | 24 // Generic interface for Chromotocol connection used by both client and host. |
24 // Provides access to the connection channels, but doesn't depend on the | 25 // Provides access to the connection channels, but doesn't depend on the |
25 // protocol used for each channel. | 26 // protocol used for each channel. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 AUTHENTICATION_FAILED, | 62 AUTHENTICATION_FAILED, |
62 CHANNEL_CONNECTION_ERROR, | 63 CHANNEL_CONNECTION_ERROR, |
63 UNKNOWN_ERROR, | 64 UNKNOWN_ERROR, |
64 }; | 65 }; |
65 | 66 |
66 // State change callbacks are called after session state has | 67 // State change callbacks are called after session state has |
67 // changed. It is not safe to destroy the session from within the | 68 // changed. It is not safe to destroy the session from within the |
68 // handler unless |state| is CLOSED or FAILED. | 69 // handler unless |state| is CLOSED or FAILED. |
69 typedef base::Callback<void(State state)> StateChangeCallback; | 70 typedef base::Callback<void(State state)> StateChangeCallback; |
70 | 71 |
| 72 // TODO(lambroslambrou): Merge this together with StateChangeCallback into a |
| 73 // single interface. |
| 74 typedef base::Callback<void( |
| 75 const std::string& channel_name, |
| 76 const net::IPEndPoint& end_point)> RouteChangeCallback; |
| 77 |
71 // TODO(sergeyu): Specify connection error code when channel | 78 // TODO(sergeyu): Specify connection error code when channel |
72 // connection fails. | 79 // connection fails. |
73 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; | 80 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; |
74 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; | 81 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; |
75 | 82 |
76 Session() { } | 83 Session() { } |
77 virtual ~Session() { } | 84 virtual ~Session() { } |
78 | 85 |
79 // Set callback that is called when state of the connection is changed. | 86 // Set callback that is called when state of the connection is changed. |
80 // Must be called on the jingle thread only. | |
81 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; | 87 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; |
82 | 88 |
| 89 // Set callback that is called when the route for a channel is changed. |
| 90 // The callback must be registered immediately after |
| 91 // JingleSessionManager::Connect() or from OnIncomingSession() callback. |
| 92 virtual void SetRouteChangeCallback(const RouteChangeCallback& callback) = 0; |
| 93 |
83 // Returns error code for a failed session. | 94 // Returns error code for a failed session. |
84 virtual Error error() = 0; | 95 virtual Error error() = 0; |
85 | 96 |
86 // Creates new channels for this connection. The specified callback | 97 // Creates new channels for this connection. The specified callback |
87 // is called when then new channel is created and connected. The | 98 // is called when then new channel is created and connected. The |
88 // callback is called with NULL if connection failed for any reason. | 99 // callback is called with NULL if connection failed for any reason. |
89 // Ownership of the channel socket is given to the caller when the | 100 // Ownership of the channel socket is given to the caller when the |
90 // callback is called. All channels must be destroyed before the | 101 // callback is called. All channels must be destroyed before the |
91 // session is destroyed. Can be called only when in CONNECTING, | 102 // session is destroyed. Can be called only when in CONNECTING, |
92 // CONNECTED or AUTHENTICATED states. | 103 // CONNECTED or AUTHENTICATED states. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 virtual void Close() = 0; | 135 virtual void Close() = 0; |
125 | 136 |
126 private: | 137 private: |
127 DISALLOW_COPY_AND_ASSIGN(Session); | 138 DISALLOW_COPY_AND_ASSIGN(Session); |
128 }; | 139 }; |
129 | 140 |
130 } // namespace protocol | 141 } // namespace protocol |
131 } // namespace remoting | 142 } // namespace remoting |
132 | 143 |
133 #endif // REMOTING_PROTOCOL_SESSION_H_ | 144 #endif // REMOTING_PROTOCOL_SESSION_H_ |
OLD | NEW |