| OLD | NEW |
| 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 "google/protobuf/message.h" | 7 #include "google/protobuf/message.h" |
| 8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
| 9 #include "remoting/protocol/client_control_sender.h" | 9 #include "remoting/protocol/client_control_sender.h" |
| 10 #include "remoting/protocol/host_message_dispatcher.h" | 10 #include "remoting/protocol/host_message_dispatcher.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // If there is a channel then close it and release the reference. | 60 // If there is a channel then close it and release the reference. |
| 61 if (session_) { | 61 if (session_) { |
| 62 session_->Close(NewRunnableMethod(this, &ConnectionToClient::OnClosed)); | 62 session_->Close(NewRunnableMethod(this, &ConnectionToClient::OnClosed)); |
| 63 session_ = NULL; | 63 session_ = NULL; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) { |
| 68 handler_->OnSequenceNumberUpdated(this, sequence_number); |
| 69 } |
| 70 |
| 67 VideoStub* ConnectionToClient::video_stub() { | 71 VideoStub* ConnectionToClient::video_stub() { |
| 68 return video_writer_.get(); | 72 return video_writer_.get(); |
| 69 } | 73 } |
| 70 | 74 |
| 71 // Return pointer to ClientStub. | 75 // Return pointer to ClientStub. |
| 72 ClientStub* ConnectionToClient::client_stub() { | 76 ClientStub* ConnectionToClient::client_stub() { |
| 73 return client_stub_.get(); | 77 return client_stub_.get(); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { | 80 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { |
| 77 host_stub_ = host_stub; | 81 host_stub_ = host_stub; |
| 78 } | 82 } |
| 79 | 83 |
| 80 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { | 84 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { |
| 81 input_stub_ = input_stub; | 85 input_stub_ = input_stub; |
| 82 } | 86 } |
| 83 | 87 |
| 84 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { | 88 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { |
| 85 if (state == protocol::Session::CONNECTED) { | 89 if (state == protocol::Session::CONNECTED) { |
| 86 client_stub_.reset(new ClientControlSender(session_->control_channel())); | 90 client_stub_.reset(new ClientControlSender(session_->control_channel())); |
| 87 video_writer_.reset(VideoWriter::Create(session_->config())); | 91 video_writer_.reset(VideoWriter::Create(session_->config())); |
| 88 video_writer_->Init(session_); | 92 video_writer_->Init(session_); |
| 89 | 93 |
| 90 dispatcher_.reset(new HostMessageDispatcher()); | 94 dispatcher_.reset(new HostMessageDispatcher()); |
| 91 dispatcher_->Initialize(session_.get(), host_stub_, input_stub_); | 95 dispatcher_->Initialize(this, host_stub_, input_stub_); |
| 92 } | 96 } |
| 93 | 97 |
| 94 // This method can be called from main thread so perform threading switching. | 98 // This method can be called from main thread so perform threading switching. |
| 95 if (MessageLoop::current() != loop_) { | 99 if (MessageLoop::current() != loop_) { |
| 96 loop_->PostTask( | 100 loop_->PostTask( |
| 97 FROM_HERE, | 101 FROM_HERE, |
| 98 NewRunnableMethod(this, &ConnectionToClient::StateChangeTask, state)); | 102 NewRunnableMethod(this, &ConnectionToClient::StateChangeTask, state)); |
| 99 } else { | 103 } else { |
| 100 StateChangeTask(state); | 104 StateChangeTask(state); |
| 101 } | 105 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 123 NOTREACHED(); | 127 NOTREACHED(); |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 | 130 |
| 127 // OnClosed() is used as a callback for protocol::Session::Close(). | 131 // OnClosed() is used as a callback for protocol::Session::Close(). |
| 128 void ConnectionToClient::OnClosed() { | 132 void ConnectionToClient::OnClosed() { |
| 129 } | 133 } |
| 130 | 134 |
| 131 } // namespace protocol | 135 } // namespace protocol |
| 132 } // namespace remoting | 136 } // namespace remoting |
| OLD | NEW |