Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: remoting/host/chromoting_host.cc

Issue 8493020: Move code in src/remoting to the new callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: - Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromoting_host.h" 5 #include "remoting/host/chromoting_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 signal_strategy_.reset( 99 signal_strategy_.reset(
100 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login, 100 new XmppSignalStrategy(context_->jingle_thread(), xmpp_login,
101 xmpp_auth_token, 101 xmpp_auth_token,
102 xmpp_auth_service)); 102 xmpp_auth_service));
103 signal_strategy_->Init(this); 103 signal_strategy_->Init(this);
104 } 104 }
105 105
106 // This method is called when we need to destroy the host process. 106 // This method is called when we need to destroy the host process.
107 void ChromotingHost::Shutdown(Task* shutdown_task) { 107 void ChromotingHost::Shutdown(const base::Closure& shutdown_task) {
108 if (MessageLoop::current() != context_->main_message_loop()) { 108 if (MessageLoop::current() != context_->main_message_loop()) {
109 context_->main_message_loop()->PostTask( 109 context_->main_message_loop()->PostTask(
110 FROM_HERE, 110 FROM_HERE,
111 base::Bind(&ChromotingHost::Shutdown, this, shutdown_task)); 111 base::Bind(&ChromotingHost::Shutdown, this, shutdown_task));
112 return; 112 return;
113 } 113 }
114 114
115 // No-op if this object is not started yet. 115 // No-op if this object is not started yet.
116 { 116 {
117 base::AutoLock auto_lock(lock_); 117 base::AutoLock auto_lock(lock_);
118 if (state_ == kInitial || state_ == kStopped) { 118 if (state_ == kInitial || state_ == kStopped) {
119 // Nothing to do if we are not started. 119 // Nothing to do if we are not started.
120 state_ = kStopped; 120 state_ = kStopped;
121 context_->main_message_loop()->PostTask(FROM_HERE, shutdown_task); 121 context_->main_message_loop()->PostTask(FROM_HERE, shutdown_task);
122 return; 122 return;
123 } 123 }
124 if (shutdown_task) 124 if (!shutdown_task.is_null())
125 shutdown_tasks_.push_back(shutdown_task); 125 shutdown_tasks_.push_back(shutdown_task);
126 if (state_ == kStopping) 126 if (state_ == kStopping)
127 return; 127 return;
128 state_ = kStopping; 128 state_ = kStopping;
129 } 129 }
130 130
131 // Disconnect all of the clients, implicitly stopping the ScreenRecorder. 131 // Disconnect all of the clients, implicitly stopping the ScreenRecorder.
132 while (!clients_.empty()) { 132 while (!clients_.empty()) {
133 OnClientDisconnected(clients_.front()->connection()); 133 OnClientDisconnected(clients_.front()->connection());
134 } 134 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 return; 257 return;
258 } 258 }
259 259
260 // If we are running Me2Mom and already have an authenticated client then 260 // If we are running Me2Mom and already have an authenticated client then
261 // one of the connections may be an attacker, so both are suspect. 261 // one of the connections may be an attacker, so both are suspect.
262 if (is_it2me_ && AuthenticatedClientsCount() > 0) { 262 if (is_it2me_ && AuthenticatedClientsCount() > 0) {
263 *response = protocol::SessionManager::DECLINE; 263 *response = protocol::SessionManager::DECLINE;
264 264
265 // Close existing sessions and shutdown the host. 265 // Close existing sessions and shutdown the host.
266 Shutdown(NULL); 266 Shutdown(base::Closure());
267 return; 267 return;
268 } 268 }
269 269
270 // TODO(simonmorris): The resolution is set in the video stream now, 270 // TODO(simonmorris): The resolution is set in the video stream now,
271 // so it doesn't need to be set here. 271 // so it doesn't need to be set here.
272 *protocol_config_->mutable_initial_resolution() = 272 *protocol_config_->mutable_initial_resolution() =
273 protocol::ScreenResolution(2048, 2048); 273 protocol::ScreenResolution(2048, 2048);
274 // TODO(sergeyu): Respect resolution requested by the client if supported. 274 // TODO(sergeyu): Respect resolution requested by the client if supported.
275 protocol::SessionConfig config; 275 protocol::SessionConfig config;
276 if (!protocol_config_->Select(session->candidate_config(), 276 if (!protocol_config_->Select(session->candidate_config(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 ClientList::iterator client; 325 ClientList::iterator client;
326 for (client = clients_.begin(); client != clients_.end(); ++client) { 326 for (client = clients_.begin(); client != clients_.end(); ++client) {
327 client->get()->LocalMouseMoved(new_pos); 327 client->get()->LocalMouseMoved(new_pos);
328 } 328 }
329 } 329 }
330 330
331 void ChromotingHost::PauseSession(bool pause) { 331 void ChromotingHost::PauseSession(bool pause) {
332 if (context_->main_message_loop() != MessageLoop::current()) { 332 if (context_->main_message_loop() != MessageLoop::current()) {
333 context_->main_message_loop()->PostTask( 333 context_->main_message_loop()->PostTask(
334 FROM_HERE, 334 FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause));
335 NewRunnableMethod(this,
336 &ChromotingHost::PauseSession,
337 pause));
338 return; 335 return;
339 } 336 }
340 ClientList::iterator client; 337 ClientList::iterator client;
341 for (client = clients_.begin(); client != clients_.end(); ++client) { 338 for (client = clients_.begin(); client != clients_.end(); ++client) {
342 client->get()->set_awaiting_continue_approval(pause); 339 client->get()->set_awaiting_continue_approval(pause);
343 } 340 }
344 desktop_environment_->OnPause(pause); 341 desktop_environment_->OnPause(pause);
345 } 342 }
346 343
347 void ChromotingHost::SetUiStrings(const UiStrings& ui_strings) { 344 void ChromotingHost::SetUiStrings(const UiStrings& ui_strings) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // Keep reference to |this|, so that we don't get destroyed while 600 // Keep reference to |this|, so that we don't get destroyed while
604 // sending notifications. 601 // sending notifications.
605 scoped_refptr<ChromotingHost> self(this); 602 scoped_refptr<ChromotingHost> self(this);
606 603
607 // Notify observers. 604 // Notify observers.
608 for (StatusObserverList::iterator it = status_observers_.begin(); 605 for (StatusObserverList::iterator it = status_observers_.begin();
609 it != status_observers_.end(); ++it) { 606 it != status_observers_.end(); ++it) {
610 (*it)->OnShutdown(); 607 (*it)->OnShutdown();
611 } 608 }
612 609
613 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin(); 610 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin();
614 it != shutdown_tasks_.end(); ++it) { 611 it != shutdown_tasks_.end(); ++it) {
615 (*it)->Run(); 612 it->Run();
616 delete *it;
617 } 613 }
618 shutdown_tasks_.clear(); 614 shutdown_tasks_.clear();
619 } 615 }
620 616
621 } // namespace remoting 617 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698