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_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/errors.h" |
13 #include "remoting/protocol/session_config.h" | 14 #include "remoting/protocol/session_config.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class IPEndPoint; | 17 class IPEndPoint; |
17 class Socket; | 18 class Socket; |
18 class StreamSocket; | 19 class StreamSocket; |
19 } // namespace net | 20 } // namespace net |
20 | 21 |
21 namespace remoting { | 22 namespace remoting { |
22 namespace protocol { | 23 namespace protocol { |
(...skipping 23 matching lines...) Expand all Loading... |
46 // Session has been connected and authenticated. | 47 // Session has been connected and authenticated. |
47 AUTHENTICATED, | 48 AUTHENTICATED, |
48 | 49 |
49 // Session has been closed. | 50 // Session has been closed. |
50 CLOSED, | 51 CLOSED, |
51 | 52 |
52 // Connection has failed. | 53 // Connection has failed. |
53 FAILED, | 54 FAILED, |
54 }; | 55 }; |
55 | 56 |
56 // TODO(sergeyu): Move error codes to a separate file. | |
57 enum Error { | |
58 OK = 0, | |
59 PEER_IS_OFFLINE, | |
60 SESSION_REJECTED, | |
61 INCOMPATIBLE_PROTOCOL, | |
62 AUTHENTICATION_FAILED, | |
63 CHANNEL_CONNECTION_ERROR, | |
64 UNKNOWN_ERROR, | |
65 }; | |
66 | |
67 // State change callbacks are called after session state has | 57 // State change callbacks are called after session state has |
68 // changed. It is not safe to destroy the session from within the | 58 // changed. It is not safe to destroy the session from within the |
69 // handler unless |state| is CLOSED or FAILED. | 59 // handler unless |state| is CLOSED or FAILED. |
70 typedef base::Callback<void(State state)> StateChangeCallback; | 60 typedef base::Callback<void(State state)> StateChangeCallback; |
71 | 61 |
72 // TODO(lambroslambrou): Merge this together with StateChangeCallback into a | 62 // TODO(lambroslambrou): Merge this together with StateChangeCallback into a |
73 // single interface. | 63 // single interface. |
74 typedef base::Callback<void( | 64 typedef base::Callback<void( |
75 const std::string& channel_name, | 65 const std::string& channel_name, |
76 const net::IPEndPoint& remote_end_point, | 66 const net::IPEndPoint& remote_end_point, |
(...skipping 11 matching lines...) Expand all Loading... |
88 | 78 |
89 // Set callback that is called when state of the connection is changed. | 79 // Set callback that is called when state of the connection is changed. |
90 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; | 80 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; |
91 | 81 |
92 // Set callback that is called when the route for a channel is changed. | 82 // Set callback that is called when the route for a channel is changed. |
93 // The callback must be registered immediately after | 83 // The callback must be registered immediately after |
94 // JingleSessionManager::Connect() or from OnIncomingSession() callback. | 84 // JingleSessionManager::Connect() or from OnIncomingSession() callback. |
95 virtual void SetRouteChangeCallback(const RouteChangeCallback& callback) = 0; | 85 virtual void SetRouteChangeCallback(const RouteChangeCallback& callback) = 0; |
96 | 86 |
97 // Returns error code for a failed session. | 87 // Returns error code for a failed session. |
98 virtual Error error() = 0; | 88 virtual ErrorCode error() = 0; |
99 | 89 |
100 // Creates new channels for this connection. The specified callback | 90 // Creates new channels for this connection. The specified callback |
101 // is called when then new channel is created and connected. The | 91 // is called when then new channel is created and connected. The |
102 // callback is called with NULL if connection failed for any reason. | 92 // callback is called with NULL if connection failed for any reason. |
103 // All channels must be destroyed before the session is | 93 // All channels must be destroyed before the session is |
104 // destroyed. Can be called only when in CONNECTING, CONNECTED or | 94 // destroyed. Can be called only when in CONNECTING, CONNECTED or |
105 // AUTHENTICATED states. | 95 // AUTHENTICATED states. |
106 virtual void CreateStreamChannel( | 96 virtual void CreateStreamChannel( |
107 const std::string& name, const StreamChannelCallback& callback) = 0; | 97 const std::string& name, const StreamChannelCallback& callback) = 0; |
108 virtual void CreateDatagramChannel( | 98 virtual void CreateDatagramChannel( |
(...skipping 28 matching lines...) Expand all Loading... |
137 virtual void Close() = 0; | 127 virtual void Close() = 0; |
138 | 128 |
139 private: | 129 private: |
140 DISALLOW_COPY_AND_ASSIGN(Session); | 130 DISALLOW_COPY_AND_ASSIGN(Session); |
141 }; | 131 }; |
142 | 132 |
143 } // namespace protocol | 133 } // namespace protocol |
144 } // namespace remoting | 134 } // namespace remoting |
145 | 135 |
146 #endif // REMOTING_PROTOCOL_SESSION_H_ | 136 #endif // REMOTING_PROTOCOL_SESSION_H_ |
OLD | NEW |