| OLD | NEW |
| 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 #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/clipboard_stub.h" |
| 12 #include "remoting/protocol/host_control_dispatcher.h" | 13 #include "remoting/protocol/host_control_dispatcher.h" |
| 13 #include "remoting/protocol/host_event_dispatcher.h" | 14 #include "remoting/protocol/host_event_dispatcher.h" |
| 14 #include "remoting/protocol/host_stub.h" | 15 #include "remoting/protocol/host_stub.h" |
| 15 #include "remoting/protocol/input_stub.h" | 16 #include "remoting/protocol/input_stub.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 namespace protocol { | 19 namespace protocol { |
| 19 | 20 |
| 20 ConnectionToClient::ConnectionToClient(protocol::Session* session) | 21 ConnectionToClient::ConnectionToClient(protocol::Session* session) |
| 21 : handler_(NULL), | 22 : handler_(NULL), |
| 23 clipboard_stub_(NULL), |
| 22 host_stub_(NULL), | 24 host_stub_(NULL), |
| 23 input_stub_(NULL), | 25 input_stub_(NULL), |
| 24 session_(session) { | 26 session_(session) { |
| 25 session_->SetStateChangeCallback( | 27 session_->SetStateChangeCallback( |
| 26 base::Bind(&ConnectionToClient::OnSessionStateChange, | 28 base::Bind(&ConnectionToClient::OnSessionStateChange, |
| 27 base::Unretained(this))); | 29 base::Unretained(this))); |
| 28 session_->SetRouteChangeCallback( | 30 session_->SetRouteChangeCallback( |
| 29 base::Bind(&ConnectionToClient::OnSessionRouteChange, | 31 base::Bind(&ConnectionToClient::OnSessionRouteChange, |
| 30 base::Unretained(this))); | 32 base::Unretained(this))); |
| 31 } | 33 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 DCHECK(CalledOnValidThread()); | 67 DCHECK(CalledOnValidThread()); |
| 66 return video_writer_.get(); | 68 return video_writer_.get(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 // Return pointer to ClientStub. | 71 // Return pointer to ClientStub. |
| 70 ClientStub* ConnectionToClient::client_stub() { | 72 ClientStub* ConnectionToClient::client_stub() { |
| 71 DCHECK(CalledOnValidThread()); | 73 DCHECK(CalledOnValidThread()); |
| 72 return control_dispatcher_.get(); | 74 return control_dispatcher_.get(); |
| 73 } | 75 } |
| 74 | 76 |
| 77 void ConnectionToClient::set_clipboard_stub( |
| 78 protocol::ClipboardStub* clipboard_stub) { |
| 79 DCHECK(CalledOnValidThread()); |
| 80 clipboard_stub_ = clipboard_stub; |
| 81 } |
| 82 |
| 75 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { | 83 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { |
| 76 DCHECK(CalledOnValidThread()); | 84 DCHECK(CalledOnValidThread()); |
| 77 host_stub_ = host_stub; | 85 host_stub_ = host_stub; |
| 78 } | 86 } |
| 79 | 87 |
| 80 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { | 88 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { |
| 81 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
| 82 input_stub_ = input_stub; | 90 input_stub_ = input_stub; |
| 83 } | 91 } |
| 84 | 92 |
| 85 void ConnectionToClient::OnSessionStateChange(Session::State state) { | 93 void ConnectionToClient::OnSessionStateChange(Session::State state) { |
| 86 DCHECK(CalledOnValidThread()); | 94 DCHECK(CalledOnValidThread()); |
| 87 | 95 |
| 88 DCHECK(handler_); | 96 DCHECK(handler_); |
| 89 switch(state) { | 97 switch(state) { |
| 90 case Session::INITIALIZING: | 98 case Session::INITIALIZING: |
| 91 case Session::CONNECTING: | 99 case Session::CONNECTING: |
| 92 case Session::CONNECTED: | 100 case Session::CONNECTED: |
| 93 // Don't care about these events. | 101 // Don't care about these events. |
| 94 break; | 102 break; |
| 95 | 103 |
| 96 case Session::AUTHENTICATED: | 104 case Session::AUTHENTICATED: |
| 97 // Initialize channels. | 105 // Initialize channels. |
| 98 control_dispatcher_.reset(new HostControlDispatcher()); | 106 control_dispatcher_.reset(new HostControlDispatcher()); |
| 99 control_dispatcher_->Init(session_.get(), base::Bind( | 107 control_dispatcher_->Init(session_.get(), base::Bind( |
| 100 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); | 108 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); |
| 109 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
| 101 control_dispatcher_->set_host_stub(host_stub_); | 110 control_dispatcher_->set_host_stub(host_stub_); |
| 102 | 111 |
| 103 event_dispatcher_.reset(new HostEventDispatcher()); | 112 event_dispatcher_.reset(new HostEventDispatcher()); |
| 104 event_dispatcher_->Init(session_.get(), base::Bind( | 113 event_dispatcher_->Init(session_.get(), base::Bind( |
| 105 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); | 114 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); |
| 106 event_dispatcher_->set_input_stub(input_stub_); | 115 event_dispatcher_->set_input_stub(input_stub_); |
| 107 event_dispatcher_->set_sequence_number_callback(base::Bind( | 116 event_dispatcher_->set_sequence_number_callback(base::Bind( |
| 108 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); | 117 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); |
| 109 | 118 |
| 110 video_writer_.reset(VideoWriter::Create( | 119 video_writer_.reset(VideoWriter::Create( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 170 } |
| 162 | 171 |
| 163 void ConnectionToClient::CloseChannels() { | 172 void ConnectionToClient::CloseChannels() { |
| 164 control_dispatcher_.reset(); | 173 control_dispatcher_.reset(); |
| 165 event_dispatcher_.reset(); | 174 event_dispatcher_.reset(); |
| 166 video_writer_.reset(); | 175 video_writer_.reset(); |
| 167 } | 176 } |
| 168 | 177 |
| 169 } // namespace protocol | 178 } // namespace protocol |
| 170 } // namespace remoting | 179 } // namespace remoting |
| OLD | NEW |