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

Side by Side Diff: remoting/protocol/connection_to_host.cc

Issue 7218061: Close all writers before JingleSession is destroyed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 5 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) 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 #include "remoting/protocol/connection_to_host.h" 5 #include "remoting/protocol/connection_to_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
(...skipping 26 matching lines...) Expand all
37 event_callback_(NULL), 37 event_callback_(NULL),
38 dispatcher_(new ClientMessageDispatcher()), 38 dispatcher_(new ClientMessageDispatcher()),
39 client_stub_(NULL), 39 client_stub_(NULL),
40 video_stub_(NULL) { 40 video_stub_(NULL) {
41 } 41 }
42 42
43 ConnectionToHost::~ConnectionToHost() { 43 ConnectionToHost::~ConnectionToHost() {
44 } 44 }
45 45
46 InputStub* ConnectionToHost::input_stub() { 46 InputStub* ConnectionToHost::input_stub() {
47 return input_stub_.get(); 47 return input_sender_.get();
48 } 48 }
49 49
50 HostStub* ConnectionToHost::host_stub() { 50 HostStub* ConnectionToHost::host_stub() {
51 return host_stub_.get(); 51 return host_control_sender_.get();
52 } 52 }
53 53
54 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, 54 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy,
55 const std::string& your_jid, 55 const std::string& your_jid,
56 const std::string& host_jid, 56 const std::string& host_jid,
57 const std::string& host_public_key, 57 const std::string& host_public_key,
58 const std::string& access_code, 58 const std::string& access_code,
59 HostEventCallback* event_callback, 59 HostEventCallback* event_callback,
60 ClientStub* client_stub, 60 ClientStub* client_stub,
61 VideoStub* video_stub) { 61 VideoStub* video_stub) {
(...skipping 15 matching lines...) Expand all
77 } 77 }
78 78
79 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) { 79 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) {
80 if (MessageLoop::current() != message_loop_) { 80 if (MessageLoop::current() != message_loop_) {
81 message_loop_->PostTask( 81 message_loop_->PostTask(
82 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect, 82 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect,
83 base::Unretained(this), shutdown_task)); 83 base::Unretained(this), shutdown_task));
84 return; 84 return;
85 } 85 }
86 86
87 if (input_sender_.get())
88 input_sender_->Close();
89
90 if (host_control_sender_.get())
91 host_control_sender_->Close();
Wez 2011/06/30 18:27:31 Same as ConnectionToClient.
Sergey Ulanov 2011/06/30 20:55:24 Done.
92
87 if (session_) { 93 if (session_) {
88 session_->Close( 94 session_->Close(
89 NewRunnableMethod(this, &ConnectionToHost::OnDisconnected, 95 NewRunnableMethod(this, &ConnectionToHost::OnDisconnected,
90 shutdown_task)); 96 shutdown_task));
91 } else { 97 } else {
92 OnDisconnected(shutdown_task); 98 OnDisconnected(shutdown_task);
93 } 99 }
94 } 100 }
95 101
96 void ConnectionToHost::InitSession() { 102 void ConnectionToHost::InitSession() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 case Session::CLOSED: 199 case Session::CLOSED:
194 state_ = STATE_CLOSED; 200 state_ = STATE_CLOSED;
195 event_callback_->OnConnectionClosed(this); 201 event_callback_->OnConnectionClosed(this);
196 break; 202 break;
197 203
198 case Session::CONNECTED: 204 case Session::CONNECTED:
199 state_ = STATE_CONNECTED; 205 state_ = STATE_CONNECTED;
200 // Initialize reader and writer. 206 // Initialize reader and writer.
201 video_reader_.reset(VideoReader::Create(session_->config())); 207 video_reader_.reset(VideoReader::Create(session_->config()));
202 video_reader_->Init(session_, video_stub_); 208 video_reader_->Init(session_, video_stub_);
203 host_stub_.reset(new HostControlSender(session_->control_channel())); 209 host_control_sender_.reset(
210 new HostControlSender(session_->control_channel()));
204 dispatcher_->Initialize(session_.get(), client_stub_); 211 dispatcher_->Initialize(session_.get(), client_stub_);
205 event_callback_->OnConnectionOpened(this); 212 event_callback_->OnConnectionOpened(this);
206 break; 213 break;
207 214
208 default: 215 default:
209 // Ignore the other states by default. 216 // Ignore the other states by default.
210 break; 217 break;
211 } 218 }
212 } 219 }
213 220
214 void ConnectionToHost::OnClientAuthenticated() { 221 void ConnectionToHost::OnClientAuthenticated() {
215 // TODO(hclam): Don't send anything except authentication request if it is 222 // TODO(hclam): Don't send anything except authentication request if it is
216 // not authenticated. 223 // not authenticated.
217 state_ = STATE_AUTHENTICATED; 224 state_ = STATE_AUTHENTICATED;
218 225
219 // Create and enable the input stub now that we're authenticated. 226 // Create and enable the input stub now that we're authenticated.
220 input_stub_.reset(new InputSender(session_->event_channel())); 227 input_sender_.reset(new InputSender(session_->event_channel()));
221 } 228 }
222 229
223 ConnectionToHost::State ConnectionToHost::state() const { 230 ConnectionToHost::State ConnectionToHost::state() const {
224 return state_; 231 return state_;
225 } 232 }
226 233
227 } // namespace protocol 234 } // namespace protocol
228 } // namespace remoting 235 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698