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

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

Issue 8468022: Refactor channel dispatchers on the host side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "google/protobuf/message.h" 10 #include "google/protobuf/message.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "remoting/protocol/client_control_sender.h" 12 #include "remoting/protocol/host_control_dispatcher.h"
13 #include "remoting/protocol/host_message_dispatcher.h" 13 #include "remoting/protocol/host_input_dispatcher.h"
14 #include "remoting/protocol/host_stub.h" 14 #include "remoting/protocol/host_stub.h"
15 #include "remoting/protocol/input_stub.h" 15 #include "remoting/protocol/input_stub.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 namespace protocol { 18 namespace protocol {
19 19
20 ConnectionToClient::ConnectionToClient(protocol::Session* session) 20 ConnectionToClient::ConnectionToClient(protocol::Session* session)
21 : handler_(NULL), 21 : handler_(NULL),
22 host_stub_(NULL), 22 host_stub_(NULL),
23 input_stub_(NULL), 23 input_stub_(NULL),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 VideoStub* ConnectionToClient::video_stub() { 73 VideoStub* ConnectionToClient::video_stub() {
74 DCHECK(CalledOnValidThread()); 74 DCHECK(CalledOnValidThread());
75 return video_writer_.get(); 75 return video_writer_.get();
76 } 76 }
77 77
78 // Return pointer to ClientStub. 78 // Return pointer to ClientStub.
79 ClientStub* ConnectionToClient::client_stub() { 79 ClientStub* ConnectionToClient::client_stub() {
80 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
81 return client_control_sender_.get(); 81 return control_dispatcher_.get();
82 } 82 }
83 83
84 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { 84 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) {
85 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
86 host_stub_ = host_stub; 86 host_stub_ = host_stub;
87 } 87 }
88 88
89 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { 89 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) {
90 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
91 input_stub_ = input_stub; 91 input_stub_ = input_stub;
(...skipping 11 matching lines...) Expand all
103 case protocol::Session::CONNECTED: 103 case protocol::Session::CONNECTED:
104 video_writer_.reset( 104 video_writer_.reset(
105 VideoWriter::Create(base::MessageLoopProxy::current(), 105 VideoWriter::Create(base::MessageLoopProxy::current(),
106 session_->config())); 106 session_->config()));
107 video_writer_->Init( 107 video_writer_->Init(
108 session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized, 108 session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized,
109 base::Unretained(this))); 109 base::Unretained(this)));
110 break; 110 break;
111 111
112 case protocol::Session::CONNECTED_CHANNELS: 112 case protocol::Session::CONNECTED_CHANNELS:
113 client_control_sender_.reset( 113 control_dispatcher_.reset(
114 new ClientControlSender(base::MessageLoopProxy::current(), 114 new HostControlDispatcher(base::MessageLoopProxy::current()));
115 session_->control_channel())); 115 control_dispatcher_->Init(session_.get(), host_stub_);
116 dispatcher_.reset(new HostMessageDispatcher()); 116 input_dispatcher_.reset(new HostInputDispatcher());
117 dispatcher_->Initialize(this, host_stub_, input_stub_); 117 input_dispatcher_->Init(session_.get(), input_stub_, base::Bind(
118 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
118 119
119 control_connected_ = true; 120 control_connected_ = true;
120 input_connected_ = true; 121 input_connected_ = true;
121 NotifyIfChannelsReady(); 122 NotifyIfChannelsReady();
122 break; 123 break;
123 124
124 case protocol::Session::CLOSED: 125 case protocol::Session::CLOSED:
125 CloseChannels(); 126 CloseChannels();
126 handler_->OnConnectionClosed(this); 127 handler_->OnConnectionClosed(this);
127 break; 128 break;
(...skipping 27 matching lines...) Expand all
155 if (control_connected_ && input_connected_ && video_connected_) 156 if (control_connected_ && input_connected_ && video_connected_)
156 handler_->OnConnectionOpened(this); 157 handler_->OnConnectionOpened(this);
157 } 158 }
158 159
159 void ConnectionToClient::CloseOnError() { 160 void ConnectionToClient::CloseOnError() {
160 CloseChannels(); 161 CloseChannels();
161 handler_->OnConnectionFailed(this); 162 handler_->OnConnectionFailed(this);
162 } 163 }
163 164
164 void ConnectionToClient::CloseChannels() { 165 void ConnectionToClient::CloseChannels() {
165 if (video_writer_.get()) 166 control_dispatcher_.reset();
166 video_writer_->Close(); 167 input_dispatcher_.reset();
167 if (client_control_sender_.get()) 168 video_writer_.reset();
168 client_control_sender_->Close();
169 } 169 }
170 170
171 } // namespace protocol 171 } // namespace protocol
172 } // namespace remoting 172 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698