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

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

Issue 10823323: Add support for multiplexed channels in remoting::protocol::Session interface. (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_to_host.cc ('k') | remoting/protocol/fake_session.cc » ('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_FAKE_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_
6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/socket/socket.h" 15 #include "net/socket/socket.h"
16 #include "net/socket/stream_socket.h" 16 #include "net/socket/stream_socket.h"
17 #include "remoting/protocol/channel_factory.h"
17 #include "remoting/protocol/session.h" 18 #include "remoting/protocol/session.h"
18 19
19 class MessageLoop; 20 class MessageLoop;
20 21
21 namespace remoting { 22 namespace remoting {
22 namespace protocol { 23 namespace protocol {
23 24
24 extern const char kTestJid[]; 25 extern const char kTestJid[];
25 26
26 // FakeSocket implement net::Socket interface for FakeConnection. All data 27 // FakeSocket implement net::Socket interface for FakeConnection. All data
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 std::vector<std::string> input_packets_; 140 std::vector<std::string> input_packets_;
140 int input_pos_; 141 int input_pos_;
141 142
142 MessageLoop* message_loop_; 143 MessageLoop* message_loop_;
143 144
144 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket); 145 DISALLOW_COPY_AND_ASSIGN(FakeUdpSocket);
145 }; 146 };
146 147
147 // FakeSession is a dummy protocol::Session that uses FakeSocket for all 148 // FakeSession is a dummy protocol::Session that uses FakeSocket for all
148 // channels. 149 // channels.
149 class FakeSession : public Session { 150 class FakeSession : public Session,
151 public ChannelFactory {
150 public: 152 public:
151 FakeSession(); 153 FakeSession();
152 virtual ~FakeSession(); 154 virtual ~FakeSession();
153 155
154 EventHandler* event_handler() { return event_handler_; } 156 EventHandler* event_handler() { return event_handler_; }
155 157
156 void set_message_loop(MessageLoop* message_loop) { 158 void set_message_loop(MessageLoop* message_loop) {
157 message_loop_ = message_loop; 159 message_loop_ = message_loop;
158 } 160 }
159 161
160 void set_error(ErrorCode error) { error_ = error; } 162 void set_error(ErrorCode error) { error_ = error; }
161 163
162 bool is_closed() const { return closed_; } 164 bool is_closed() const { return closed_; }
163 165
164 FakeSocket* GetStreamChannel(const std::string& name); 166 FakeSocket* GetStreamChannel(const std::string& name);
165 FakeUdpSocket* GetDatagramChannel(const std::string& name); 167 FakeUdpSocket* GetDatagramChannel(const std::string& name);
166 168
167 // Session implementation. 169 // Session interface.
168 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE; 170 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE;
171 virtual ErrorCode error() OVERRIDE;
172 virtual const std::string& jid() OVERRIDE;
173 virtual const CandidateSessionConfig* candidate_config() OVERRIDE;
174 virtual const SessionConfig& config() OVERRIDE;
175 virtual void set_config(const SessionConfig& config) OVERRIDE;
176 virtual ChannelFactory* GetTransportChannelFactory() OVERRIDE;
177 virtual ChannelFactory* GetMultiplexedChannelFactory() OVERRIDE;
178 virtual void Close() OVERRIDE;
169 179
170 virtual ErrorCode error() OVERRIDE; 180 // ChannelFactory interface.
171
172 virtual void CreateStreamChannel( 181 virtual void CreateStreamChannel(
173 const std::string& name, const StreamChannelCallback& callback) OVERRIDE; 182 const std::string& name, const StreamChannelCallback& callback) OVERRIDE;
174 virtual void CreateDatagramChannel( 183 virtual void CreateDatagramChannel(
175 const std::string& name, 184 const std::string& name,
176 const DatagramChannelCallback& callback) OVERRIDE; 185 const DatagramChannelCallback& callback) OVERRIDE;
177 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; 186 virtual void CancelChannelCreation(const std::string& name) OVERRIDE;
178 187
179 virtual const std::string& jid() OVERRIDE;
180
181 virtual const CandidateSessionConfig* candidate_config() OVERRIDE;
182 virtual const SessionConfig& config() OVERRIDE;
183 virtual void set_config(const SessionConfig& config) OVERRIDE;
184
185 virtual void Close() OVERRIDE;
186
187 public: 188 public:
188 EventHandler* event_handler_; 189 EventHandler* event_handler_;
189 scoped_ptr<const CandidateSessionConfig> candidate_config_; 190 scoped_ptr<const CandidateSessionConfig> candidate_config_;
190 SessionConfig config_; 191 SessionConfig config_;
191 MessageLoop* message_loop_; 192 MessageLoop* message_loop_;
192 193
193 std::map<std::string, FakeSocket*> stream_channels_; 194 std::map<std::string, FakeSocket*> stream_channels_;
194 std::map<std::string, FakeUdpSocket*> datagram_channels_; 195 std::map<std::string, FakeUdpSocket*> datagram_channels_;
195 196
196 std::string jid_; 197 std::string jid_;
197 198
198 ErrorCode error_; 199 ErrorCode error_;
199 bool closed_; 200 bool closed_;
200 201
201 DISALLOW_COPY_AND_ASSIGN(FakeSession); 202 DISALLOW_COPY_AND_ASSIGN(FakeSession);
202 }; 203 };
203 204
204 } // namespace protocol 205 } // namespace protocol
205 } // namespace remoting 206 } // namespace remoting
206 207
207 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ 208 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/connection_to_host.cc ('k') | remoting/protocol/fake_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698