Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: remoting/protocol/session.h

Issue 10830046: Implement ChannelMultiplexer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/connection_tester.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/protocol/channel_factory.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "remoting/protocol/buffered_socket_writer.h"
13 #include "remoting/protocol/errors.h" 11 #include "remoting/protocol/errors.h"
14 #include "remoting/protocol/session_config.h" 12 #include "remoting/protocol/session_config.h"
15 13
16 namespace net { 14 namespace net {
17 class IPEndPoint; 15 class IPEndPoint;
18 class Socket;
19 class StreamSocket;
20 } // namespace net 16 } // namespace net
21 17
22 namespace remoting { 18 namespace remoting {
23 namespace protocol { 19 namespace protocol {
24 20
25 struct TransportRoute; 21 struct TransportRoute;
26 22
27 // Generic interface for Chromotocol connection used by both client and host. 23 // Generic interface for Chromotocol connection used by both client and host.
28 // Provides access to the connection channels, but doesn't depend on the 24 // Provides access to the connection channels, but doesn't depend on the
29 // protocol used for each channel. 25 // protocol used for each channel.
30 class Session : public base::NonThreadSafe { 26 class Session : public ChannelFactory {
31 public: 27 public:
32 enum State { 28 enum State {
33 // Created, but not connecting yet. 29 // Created, but not connecting yet.
34 INITIALIZING, 30 INITIALIZING,
35 31
36 // Sent or received session-initiate, but haven't sent or received 32 // Sent or received session-initiate, but haven't sent or received
37 // session-accept. 33 // session-accept.
38 // TODO(sergeyu): Do we really need this state? 34 // TODO(sergeyu): Do we really need this state?
39 CONNECTING, 35 CONNECTING,
40 36
(...skipping 26 matching lines...) Expand all
67 virtual void OnSessionRouteChange(const std::string& channel_name, 63 virtual void OnSessionRouteChange(const std::string& channel_name,
68 const TransportRoute& route) = 0; 64 const TransportRoute& route) = 0;
69 65
70 // Called when ready state on one of the channels changes. See 66 // Called when ready state on one of the channels changes. See
71 // comments in transport.h for explanation on what this state 67 // comments in transport.h for explanation on what this state
72 // means and how it can used. 68 // means and how it can used.
73 virtual void OnSessionChannelReady(const std::string& channel_name, 69 virtual void OnSessionChannelReady(const std::string& channel_name,
74 bool ready) {} 70 bool ready) {}
75 }; 71 };
76 72
77 // TODO(sergeyu): Specify connection error code when channel
78 // connection fails.
79 typedef base::Callback<void(scoped_ptr<net::StreamSocket>)>
80 StreamChannelCallback;
81 typedef base::Callback<void(scoped_ptr<net::Socket>)>
82 DatagramChannelCallback;
83 73
84 Session() {} 74 Session() {}
85 virtual ~Session() {} 75 virtual ~Session() {}
86 76
87 // Set event handler for this session. |event_handler| must outlive 77 // Set event handler for this session. |event_handler| must outlive
88 // this object. 78 // this object.
89 virtual void SetEventHandler(EventHandler* event_handler) = 0; 79 virtual void SetEventHandler(EventHandler* event_handler) = 0;
90 80
91 // Returns error code for a failed session. 81 // Returns error code for a failed session.
92 virtual ErrorCode error() = 0; 82 virtual ErrorCode error() = 0;
93 83
94 // Creates new channels for this connection. The specified callback
95 // is called when then new channel is created and connected. The
96 // callback is called with NULL if connection failed for any reason.
97 // All channels must be destroyed before the session is
98 // destroyed. Can be called only when in CONNECTING, CONNECTED or
99 // AUTHENTICATED states.
100 virtual void CreateStreamChannel(
101 const std::string& name, const StreamChannelCallback& callback) = 0;
102 virtual void CreateDatagramChannel(
103 const std::string& name, const DatagramChannelCallback& callback) = 0;
104
105 // Cancels a pending CreateStreamChannel() or CreateDatagramChannel()
106 // operation for the named channel. If the channel creation already
107 // completed then cancelling it has no effect. When shutting down
108 // this method must be called for each channel pending creation.
109 virtual void CancelChannelCreation(const std::string& name) = 0;
110
111 // JID of the other side. 84 // JID of the other side.
112 virtual const std::string& jid() = 0; 85 virtual const std::string& jid() = 0;
113 86
114 // Configuration of the protocol that was sent or received in the 87 // Configuration of the protocol that was sent or received in the
115 // session-initiate jingle message. Returned pointer is valid until 88 // session-initiate jingle message. Returned pointer is valid until
116 // connection is closed. 89 // connection is closed.
117 virtual const CandidateSessionConfig* candidate_config() = 0; 90 virtual const CandidateSessionConfig* candidate_config() = 0;
118 91
119 // Protocol configuration. Can be called only after session has been accepted. 92 // Protocol configuration. Can be called only after session has been accepted.
120 // Returned pointer is valid until connection is closed. 93 // Returned pointer is valid until connection is closed.
(...skipping 10 matching lines...) Expand all
131 virtual void Close() = 0; 104 virtual void Close() = 0;
132 105
133 private: 106 private:
134 DISALLOW_COPY_AND_ASSIGN(Session); 107 DISALLOW_COPY_AND_ASSIGN(Session);
135 }; 108 };
136 109
137 } // namespace protocol 110 } // namespace protocol
138 } // namespace remoting 111 } // namespace remoting
139 112
140 #endif // REMOTING_PROTOCOL_SESSION_H_ 113 #endif // REMOTING_PROTOCOL_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/connection_tester.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698