Chromium Code Reviews| 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 typedef base::Callback<void( | |
|
Sergey Ulanov
2012/01/23 20:33:37
maybe add TODO to merge these two callbacks to a s
Lambros
2012/01/24 19:50:50
Done.
| |
| 73 const std::string& channel_name, | |
| 74 const net::IPEndPoint& end_point)> RouteChangeCallback; | |
| 75 | |
| 71 // TODO(sergeyu): Specify connection error code when channel | 76 // TODO(sergeyu): Specify connection error code when channel |
| 72 // connection fails. | 77 // connection fails. |
| 73 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; | 78 typedef base::Callback<void(net::StreamSocket*)> StreamChannelCallback; |
| 74 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; | 79 typedef base::Callback<void(net::Socket*)> DatagramChannelCallback; |
| 75 | 80 |
| 76 Session() { } | 81 Session() { } |
| 77 virtual ~Session() { } | 82 virtual ~Session() { } |
| 78 | 83 |
| 79 // Set callback that is called when state of the connection is changed. | 84 // Set callback that is called when state of the connection is changed. |
| 80 // Must be called on the jingle thread only. | 85 // Must be called on the jingle thread only. |
|
Sergey Ulanov
2012/01/23 20:33:37
This comment is not necessary anymore, Session int
Lambros
2012/01/24 19:50:50
Done.
| |
| 81 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; | 86 virtual void SetStateChangeCallback(const StateChangeCallback& callback) = 0; |
| 82 | 87 |
| 88 // Set callback that is called when the route for a channel is changed. | |
|
Sergey Ulanov
2012/01/23 20:33:37
It's also worth mentioning that the callback must
Lambros
2012/01/24 19:50:50
Done.
| |
| 89 // Must be called on the jingle thread only. | |
|
Sergey Ulanov
2012/01/23 20:33:37
remove this comments
Lambros
2012/01/24 19:50:50
Done.
| |
| 90 virtual void SetRouteChangeCallback(const RouteChangeCallback& callback) = 0; | |
| 91 | |
| 83 // Returns error code for a failed session. | 92 // Returns error code for a failed session. |
| 84 virtual Error error() = 0; | 93 virtual Error error() = 0; |
| 85 | 94 |
| 86 // Creates new channels for this connection. The specified callback | 95 // Creates new channels for this connection. The specified callback |
| 87 // is called when then new channel is created and connected. The | 96 // is called when then new channel is created and connected. The |
| 88 // callback is called with NULL if connection failed for any reason. | 97 // callback is called with NULL if connection failed for any reason. |
| 89 // Ownership of the channel socket is given to the caller when the | 98 // Ownership of the channel socket is given to the caller when the |
| 90 // callback is called. All channels must be destroyed before the | 99 // callback is called. All channels must be destroyed before the |
| 91 // session is destroyed. Can be called only when in CONNECTING, | 100 // session is destroyed. Can be called only when in CONNECTING, |
| 92 // CONNECTED or AUTHENTICATED states. | 101 // CONNECTED or AUTHENTICATED states. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 virtual void Close() = 0; | 133 virtual void Close() = 0; |
| 125 | 134 |
| 126 private: | 135 private: |
| 127 DISALLOW_COPY_AND_ASSIGN(Session); | 136 DISALLOW_COPY_AND_ASSIGN(Session); |
| 128 }; | 137 }; |
| 129 | 138 |
| 130 } // namespace protocol | 139 } // namespace protocol |
| 131 } // namespace remoting | 140 } // namespace remoting |
| 132 | 141 |
| 133 #endif // REMOTING_PROTOCOL_SESSION_H_ | 142 #endif // REMOTING_PROTOCOL_SESSION_H_ |
| OLD | NEW |