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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 base::Bind(&HostMessageDispatcher::OnEventMessageReceived, | 47 base::Bind(&HostMessageDispatcher::OnEventMessageReceived, |
48 base::Unretained(this))); | 48 base::Unretained(this))); |
49 control_message_reader_->Init( | 49 control_message_reader_->Init( |
50 connection->session()->control_channel(), | 50 connection->session()->control_channel(), |
51 base::Bind(&HostMessageDispatcher::OnControlMessageReceived, | 51 base::Bind(&HostMessageDispatcher::OnControlMessageReceived, |
52 base::Unretained(this))); | 52 base::Unretained(this))); |
53 } | 53 } |
54 | 54 |
55 void HostMessageDispatcher::OnControlMessageReceived( | 55 void HostMessageDispatcher::OnControlMessageReceived( |
56 ControlMessage* message, const base::Closure& done_task) { | 56 ControlMessage* message, const base::Closure& done_task) { |
57 if (message->has_begin_session_request()) { | |
58 const BeginSessionRequest& request = message->begin_session_request(); | |
59 if (request.has_credentials() && request.credentials().has_type()) { | |
60 host_stub_->BeginSessionRequest(&request.credentials(), done_task); | |
61 return; | |
62 } | |
63 } | |
64 | |
65 LOG(WARNING) << "Invalid control message received."; | 57 LOG(WARNING) << "Invalid control message received."; |
66 done_task.Run(); | 58 done_task.Run(); |
67 } | 59 } |
68 | 60 |
69 void HostMessageDispatcher::OnEventMessageReceived( | 61 void HostMessageDispatcher::OnEventMessageReceived( |
70 EventMessage* message, const base::Closure& done_task) { | 62 EventMessage* message, const base::Closure& done_task) { |
71 base::ScopedClosureRunner done_runner(done_task); | 63 base::ScopedClosureRunner done_runner(done_task); |
72 | 64 |
73 connection_->UpdateSequenceNumber(message->sequence_number()); | 65 connection_->UpdateSequenceNumber(message->sequence_number()); |
74 | 66 |
75 if (message->has_key_event()) { | 67 if (message->has_key_event()) { |
76 const KeyEvent& event = message->key_event(); | 68 const KeyEvent& event = message->key_event(); |
77 if (event.has_keycode() && event.has_pressed()) { | 69 if (event.has_keycode() && event.has_pressed()) { |
78 input_stub_->InjectKeyEvent(event); | 70 input_stub_->InjectKeyEvent(event); |
79 return; | 71 return; |
80 } | 72 } |
81 } else if (message->has_mouse_event()) { | 73 } else if (message->has_mouse_event()) { |
82 input_stub_->InjectMouseEvent(message->mouse_event()); | 74 input_stub_->InjectMouseEvent(message->mouse_event()); |
83 return; | 75 return; |
84 } | 76 } |
85 | 77 |
86 LOG(WARNING) << "Unknown event message received."; | 78 LOG(WARNING) << "Unknown event message received."; |
87 } | 79 } |
88 | 80 |
89 } // namespace protocol | 81 } // namespace protocol |
90 } // namespace remoting | 82 } // namespace remoting |
OLD | NEW |