| 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "net/base/io_buffer.h" | 6 #include "net/base/io_buffer.h" |
| 7 #include "remoting/proto/control.pb.h" | 7 #include "remoting/proto/control.pb.h" |
| 8 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
| 9 #include "remoting/proto/internal.pb.h" | 9 #include "remoting/proto/internal.pb.h" |
| 10 #include "remoting/protocol/connection_to_client.h" | 10 #include "remoting/protocol/connection_to_client.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); | 38 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); |
| 39 event_message_reader_.reset(new ProtobufMessageReader<EventMessage>()); | 39 event_message_reader_.reset(new ProtobufMessageReader<EventMessage>()); |
| 40 connection_ = connection; | 40 connection_ = connection; |
| 41 host_stub_ = host_stub; | 41 host_stub_ = host_stub; |
| 42 input_stub_ = input_stub; | 42 input_stub_ = input_stub; |
| 43 | 43 |
| 44 // Initialize the readers on the sockets provided by channels. | 44 // Initialize the readers on the sockets provided by channels. |
| 45 event_message_reader_->Init( | 45 event_message_reader_->Init( |
| 46 connection->session()->event_channel(), | 46 connection->session()->event_channel(), |
| 47 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); | 47 base::Bind(&HostMessageDispatcher::OnEventMessageReceived, |
| 48 base::Unretained(this))); |
| 48 control_message_reader_->Init( | 49 control_message_reader_->Init( |
| 49 connection->session()->control_channel(), | 50 connection->session()->control_channel(), |
| 50 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); | 51 base::Bind(&HostMessageDispatcher::OnControlMessageReceived, |
| 52 base::Unretained(this))); |
| 51 } | 53 } |
| 52 | 54 |
| 53 void HostMessageDispatcher::OnControlMessageReceived( | 55 void HostMessageDispatcher::OnControlMessageReceived( |
| 54 ControlMessage* message, Task* done_task) { | 56 ControlMessage* message, const base::Closure& done_task) { |
| 55 if (message->has_begin_session_request()) { | 57 if (message->has_begin_session_request()) { |
| 56 const BeginSessionRequest& request = message->begin_session_request(); | 58 const BeginSessionRequest& request = message->begin_session_request(); |
| 57 if (request.has_credentials() && request.credentials().has_type()) { | 59 if (request.has_credentials() && request.credentials().has_type()) { |
| 58 host_stub_->BeginSessionRequest(&request.credentials(), done_task); | 60 host_stub_->BeginSessionRequest(&request.credentials(), done_task); |
| 59 return; | 61 return; |
| 60 } | 62 } |
| 61 } | 63 } |
| 62 | 64 |
| 63 LOG(WARNING) << "Invalid control message received."; | 65 LOG(WARNING) << "Invalid control message received."; |
| 64 done_task->Run(); | 66 done_task.Run(); |
| 65 delete done_task; | |
| 66 } | 67 } |
| 67 | 68 |
| 68 void HostMessageDispatcher::OnEventMessageReceived( | 69 void HostMessageDispatcher::OnEventMessageReceived( |
| 69 EventMessage* message, Task* done_task) { | 70 EventMessage* message, const base::Closure& done_task) { |
| 70 base::ScopedTaskRunner done_runner(done_task); | 71 base::ScopedClosureRunner done_runner(done_task); |
| 71 | 72 |
| 72 connection_->UpdateSequenceNumber(message->sequence_number()); | 73 connection_->UpdateSequenceNumber(message->sequence_number()); |
| 73 | 74 |
| 74 if (message->has_key_event()) { | 75 if (message->has_key_event()) { |
| 75 const KeyEvent& event = message->key_event(); | 76 const KeyEvent& event = message->key_event(); |
| 76 if (event.has_keycode() && event.has_pressed()) { | 77 if (event.has_keycode() && event.has_pressed()) { |
| 77 input_stub_->InjectKeyEvent(event); | 78 input_stub_->InjectKeyEvent(event); |
| 78 return; | 79 return; |
| 79 } | 80 } |
| 80 } else if (message->has_mouse_event()) { | 81 } else if (message->has_mouse_event()) { |
| 81 input_stub_->InjectMouseEvent(message->mouse_event()); | 82 input_stub_->InjectMouseEvent(message->mouse_event()); |
| 82 return; | 83 return; |
| 83 } | 84 } |
| 84 | 85 |
| 85 LOG(WARNING) << "Unknown event message received."; | 86 LOG(WARNING) << "Unknown event message received."; |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace protocol | 89 } // namespace protocol |
| 89 } // namespace remoting | 90 } // namespace remoting |
| OLD | NEW |