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

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

Issue 10981009: Fix ChannelMultiplexer to properly handle base channel creation failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
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>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // FakeSession is a dummy protocol::Session that uses FakeSocket for all 148 // FakeSession is a dummy protocol::Session that uses FakeSocket for all
149 // channels. 149 // channels.
150 class FakeSession : public Session, 150 class FakeSession : public Session,
151 public ChannelFactory { 151 public ChannelFactory {
152 public: 152 public:
153 FakeSession(); 153 FakeSession();
154 virtual ~FakeSession(); 154 virtual ~FakeSession();
155 155
156 EventHandler* event_handler() { return event_handler_; } 156 EventHandler* event_handler() { return event_handler_; }
157 157
158 void set_message_loop(MessageLoop* message_loop) { 158 void set_async_creation(bool async_creation) {
159 message_loop_ = message_loop; 159 async_creation_ = async_creation;
160 } 160 }
161 161
162 void set_error(ErrorCode error) { error_ = error; } 162 void set_error(ErrorCode error) { error_ = error; }
163 163
164 bool is_closed() const { return closed_; } 164 bool is_closed() const { return closed_; }
165 165
166 FakeSocket* GetStreamChannel(const std::string& name); 166 FakeSocket* GetStreamChannel(const std::string& name);
167 FakeUdpSocket* GetDatagramChannel(const std::string& name); 167 FakeUdpSocket* GetDatagramChannel(const std::string& name);
168 168
169 // Session interface. 169 // Session interface.
170 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE; 170 virtual void SetEventHandler(EventHandler* event_handler) OVERRIDE;
171 virtual ErrorCode error() OVERRIDE; 171 virtual ErrorCode error() OVERRIDE;
172 virtual const std::string& jid() OVERRIDE; 172 virtual const std::string& jid() OVERRIDE;
173 virtual const CandidateSessionConfig* candidate_config() OVERRIDE; 173 virtual const CandidateSessionConfig* candidate_config() OVERRIDE;
174 virtual const SessionConfig& config() OVERRIDE; 174 virtual const SessionConfig& config() OVERRIDE;
175 virtual void set_config(const SessionConfig& config) OVERRIDE; 175 virtual void set_config(const SessionConfig& config) OVERRIDE;
176 virtual ChannelFactory* GetTransportChannelFactory() OVERRIDE; 176 virtual ChannelFactory* GetTransportChannelFactory() OVERRIDE;
177 virtual ChannelFactory* GetMultiplexedChannelFactory() OVERRIDE; 177 virtual ChannelFactory* GetMultiplexedChannelFactory() OVERRIDE;
178 virtual void Close() OVERRIDE; 178 virtual void Close() OVERRIDE;
179 179
180 // ChannelFactory interface. 180 // ChannelFactory interface.
181 virtual void CreateStreamChannel( 181 virtual void CreateStreamChannel(
182 const std::string& name, const StreamChannelCallback& callback) OVERRIDE; 182 const std::string& name,
183 const StreamChannelCallback& callback) OVERRIDE;
183 virtual void CreateDatagramChannel( 184 virtual void CreateDatagramChannel(
184 const std::string& name, 185 const std::string& name,
185 const DatagramChannelCallback& callback) OVERRIDE; 186 const DatagramChannelCallback& callback) OVERRIDE;
186 virtual void CancelChannelCreation(const std::string& name) OVERRIDE; 187 virtual void CancelChannelCreation(const std::string& name) OVERRIDE;
187 188
188 public: 189 public:
190 void CallStreamChannelCallback(
Wez 2012/09/25 17:43:58 nit: NotifyStreamChannelConnected/NotifyStreamChan
Sergey Ulanov 2012/09/25 18:59:08 Done.
191 const std::string& name,
192 const StreamChannelCallback& callback);
193 void CallDatagramChannelCallback(
194 const std::string& name,
195 const DatagramChannelCallback& callback);
196
189 EventHandler* event_handler_; 197 EventHandler* event_handler_;
190 scoped_ptr<const CandidateSessionConfig> candidate_config_; 198 scoped_ptr<const CandidateSessionConfig> candidate_config_;
191 SessionConfig config_; 199 SessionConfig config_;
192 MessageLoop* message_loop_; 200 MessageLoop* message_loop_;
193 201
202 bool async_creation_;
203
194 std::map<std::string, FakeSocket*> stream_channels_; 204 std::map<std::string, FakeSocket*> stream_channels_;
195 std::map<std::string, FakeUdpSocket*> datagram_channels_; 205 std::map<std::string, FakeUdpSocket*> datagram_channels_;
196 206
197 std::string jid_; 207 std::string jid_;
198 208
199 ErrorCode error_; 209 ErrorCode error_;
200 bool closed_; 210 bool closed_;
201 211
212 base::WeakPtrFactory<FakeSession> weak_factory_;
213
202 DISALLOW_COPY_AND_ASSIGN(FakeSession); 214 DISALLOW_COPY_AND_ASSIGN(FakeSession);
203 }; 215 };
204 216
205 } // namespace protocol 217 } // namespace protocol
206 } // namespace remoting 218 } // namespace remoting
207 219
208 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ 220 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698