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/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); | 141 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); |
142 } | 142 } |
143 | 143 |
144 void ChromotingHost::SetMaximumSessionDuration( | 144 void ChromotingHost::SetMaximumSessionDuration( |
145 const base::TimeDelta& max_session_duration) { | 145 const base::TimeDelta& max_session_duration) { |
146 max_session_duration_ = max_session_duration; | 146 max_session_duration_ = max_session_duration; |
147 } | 147 } |
148 | 148 |
149 //////////////////////////////////////////////////////////////////////////// | 149 //////////////////////////////////////////////////////////////////////////// |
150 // protocol::ClientSession::EventHandler implementation. | 150 // protocol::ClientSession::EventHandler implementation. |
151 void ChromotingHost::OnSessionAuthenticated(ClientSession* client) { | 151 bool ChromotingHost::OnSessionAuthenticated(ClientSession* client) { |
152 DCHECK(CalledOnValidThread()); | 152 DCHECK(CalledOnValidThread()); |
153 | 153 |
154 login_backoff_.Reset(); | 154 login_backoff_.Reset(); |
155 | 155 |
156 // Disconnect all other clients. |it| should be advanced before Disconnect() | 156 // Disconnect all other clients. |it| should be advanced before Disconnect() |
157 // is called to avoid it becoming invalid when the client is removed from | 157 // is called to avoid it becoming invalid when the client is removed from |
158 // the list. | 158 // the list. |
159 ClientList::iterator it = clients_.begin(); | 159 ClientList::iterator it = clients_.begin(); |
160 while (it != clients_.end()) { | 160 while (it != clients_.end()) { |
161 ClientSession* other_client = *it++; | 161 ClientSession* other_client = *it++; |
162 if (other_client != client) | 162 if (other_client != client) |
163 other_client->DisconnectSession(); | 163 other_client->DisconnectSession(); |
164 } | 164 } |
165 | 165 |
166 // Disconnects above must have destroyed all other clients. | 166 // Disconnects above must have destroyed all other clients. |
167 DCHECK_EQ(clients_.size(), 1U); | 167 DCHECK_EQ(clients_.size(), 1U); |
168 | 168 |
169 // Notify observers that there is at least one authenticated client. | 169 // Notify observers that there is at least one authenticated client. |
170 const std::string& jid = client->client_jid(); | 170 const std::string& jid = client->client_jid(); |
171 | 171 |
172 reject_authenticating_client_ = false; | 172 reject_authenticating_client_ = false; |
173 | 173 |
174 authenticating_client_ = true; | 174 authenticating_client_ = true; |
175 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 175 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
176 OnClientAuthenticated(jid)); | 176 OnClientAuthenticated(jid)); |
177 authenticating_client_ = false; | 177 authenticating_client_ = false; |
178 | 178 |
179 if (reject_authenticating_client_) { | 179 return !reject_authenticating_client_; |
180 client->DisconnectSession(); | |
181 } | |
182 } | 180 } |
183 | 181 |
184 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { | 182 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { |
185 DCHECK(CalledOnValidThread()); | 183 DCHECK(CalledOnValidThread()); |
186 | 184 |
187 // Notify observers. | 185 // Notify observers. |
188 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 186 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
189 OnClientConnected(client->client_jid())); | 187 OnClientConnected(client->client_jid())); |
190 } | 188 } |
191 | 189 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 DCHECK(CalledOnValidThread()); | 295 DCHECK(CalledOnValidThread()); |
298 | 296 |
299 while (!clients_.empty()) { | 297 while (!clients_.empty()) { |
300 size_t size = clients_.size(); | 298 size_t size = clients_.size(); |
301 clients_.front()->DisconnectSession(); | 299 clients_.front()->DisconnectSession(); |
302 CHECK_EQ(clients_.size(), size - 1); | 300 CHECK_EQ(clients_.size(), size - 1); |
303 } | 301 } |
304 } | 302 } |
305 | 303 |
306 } // namespace remoting | 304 } // namespace remoting |
OLD | NEW |