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/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 DCHECK_EQ(connection_.get(), connection); | 94 DCHECK_EQ(connection_.get(), connection); |
95 authenticated_ = true; | 95 authenticated_ = true; |
96 event_handler_->OnSessionAuthenticated(this); | 96 event_handler_->OnSessionAuthenticated(this); |
97 } | 97 } |
98 | 98 |
99 void ClientSession::OnConnectionClosed( | 99 void ClientSession::OnConnectionClosed( |
100 protocol::ConnectionToClient* connection) { | 100 protocol::ConnectionToClient* connection) { |
101 DCHECK_EQ(connection_.get(), connection); | 101 DCHECK_EQ(connection_.get(), connection); |
102 scoped_refptr<ClientSession> self = this; | 102 scoped_refptr<ClientSession> self = this; |
103 event_handler_->OnSessionClosed(this); | 103 event_handler_->OnSessionClosed(this); |
104 Disconnect(); | |
105 } | 104 } |
106 | 105 |
107 void ClientSession::OnConnectionFailed( | 106 void ClientSession::OnConnectionFailed( |
108 protocol::ConnectionToClient* connection) { | 107 protocol::ConnectionToClient* connection) { |
109 DCHECK_EQ(connection_.get(), connection); | 108 DCHECK_EQ(connection_.get(), connection); |
110 // TODO(sergeyu): Log failure reason? | 109 // TODO(sergeyu): Log failure reason? |
111 scoped_refptr<ClientSession> self = this; | 110 scoped_refptr<ClientSession> self = this; |
112 event_handler_->OnSessionClosed(this); | 111 event_handler_->OnSessionClosed(this); |
113 Disconnect(); | |
114 } | 112 } |
115 | 113 |
116 void ClientSession::OnSequenceNumberUpdated( | 114 void ClientSession::OnSequenceNumberUpdated( |
117 protocol::ConnectionToClient* connection, int64 sequence_number) { | 115 protocol::ConnectionToClient* connection, int64 sequence_number) { |
118 DCHECK_EQ(connection_.get(), connection); | 116 DCHECK_EQ(connection_.get(), connection); |
119 event_handler_->OnSessionSequenceNumber(this, sequence_number); | 117 event_handler_->OnSessionSequenceNumber(this, sequence_number); |
120 } | 118 } |
121 | 119 |
122 void ClientSession::Disconnect() { | 120 void ClientSession::Disconnect() { |
123 connection_->Disconnect(); | 121 DCHECK(connection_); |
124 authenticated_ = false; | 122 authenticated_ = false; |
125 RestoreEventState(); | 123 RestoreEventState(); |
| 124 |
| 125 // This triggers OnSessionClosed() and the session may be destroyed |
| 126 // as the result, so this call must be the last in this method. |
| 127 connection_->Disconnect(); |
126 } | 128 } |
127 | 129 |
128 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { | 130 void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
129 // If this is a genuine local input event (rather than an echo of a remote | 131 // If this is a genuine local input event (rather than an echo of a remote |
130 // input event that we've just injected), then ignore remote inputs for a | 132 // input event that we've just injected), then ignore remote inputs for a |
131 // short time. | 133 // short time. |
132 std::list<SkIPoint>::iterator found_position = | 134 std::list<SkIPoint>::iterator found_position = |
133 std::find(injected_mouse_positions_.begin(), | 135 std::find(injected_mouse_positions_.begin(), |
134 injected_mouse_positions_.end(), mouse_pos); | 136 injected_mouse_positions_.end(), mouse_pos); |
135 if (found_position != injected_mouse_positions_.end()) { | 137 if (found_position != injected_mouse_positions_.end()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 mouse.set_y(remote_mouse_pos_.y()); | 222 mouse.set_y(remote_mouse_pos_.y()); |
221 mouse.set_button((MouseEvent::MouseButton)i); | 223 mouse.set_button((MouseEvent::MouseButton)i); |
222 mouse.set_button_down(false); | 224 mouse.set_button_down(false); |
223 input_stub_->InjectMouseEvent(mouse); | 225 input_stub_->InjectMouseEvent(mouse); |
224 } | 226 } |
225 } | 227 } |
226 remote_mouse_button_state_ = 0; | 228 remote_mouse_button_state_ = 0; |
227 } | 229 } |
228 | 230 |
229 } // namespace remoting | 231 } // namespace remoting |
OLD | NEW |