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

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

Issue 7867019: Access Session::config() and Session::jid() on the correct thread only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 3 months 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 | Annotate | Revision Log
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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // about proper crash recovery and daemon mode. 440 // about proper crash recovery and daemon mode.
441 // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost. 441 // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost.
442 if (is_it2me_ || enable == is_curtained_) 442 if (is_it2me_ || enable == is_curtained_)
443 return; 443 return;
444 desktop_environment_->curtain()->EnableCurtainMode(enable); 444 desktop_environment_->curtain()->EnableCurtainMode(enable);
445 is_curtained_ = enable; 445 is_curtained_ = enable;
446 } 446 }
447 447
448 void ChromotingHost::LocalLoginSucceeded( 448 void ChromotingHost::LocalLoginSucceeded(
449 scoped_refptr<ConnectionToClient> connection) { 449 scoped_refptr<ConnectionToClient> connection) {
450 if (MessageLoop::current() != context_->main_message_loop()) { 450 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
451 context_->main_message_loop()->PostTask(
452 FROM_HERE, base::Bind(&ChromotingHost::LocalLoginSucceeded, this,
453 connection));
454 return;
455 }
456 451
452 context_->main_message_loop()->PostTask(
453 FROM_HERE, base::Bind(&ChromotingHost::HandleLocalLoginSucceeded,
454 this, connection, connection->session()->config(),
455 connection->session()->jid()));
Wez 2011/09/10 01:10:03 It seems kinda broken that we have to pull these o
456 }
457
458 void ChromotingHost::HandleLocalLoginSucceeded(
459 scoped_refptr<ConnectionToClient> connection,
460 const protocol::SessionConfig& config,
461 const std::string& jid) {
457 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 462 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
458 463
459 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus(); 464 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
460 status->set_success(true); 465 status->set_success(true);
461 connection->client_stub()->BeginSessionResponse( 466 connection->client_stub()->BeginSessionResponse(
462 status, new DeleteTask<protocol::LocalLoginStatus>(status)); 467 status, new DeleteTask<protocol::LocalLoginStatus>(status));
463 468
464 // Disconnect all other clients. 469 // Disconnect all other clients.
465 // Iterate over a copy of the list of clients, to avoid mutating the list 470 // Iterate over a copy of the list of clients, to avoid mutating the list
466 // while iterating over it. 471 // while iterating over it.
467 ClientList clients_copy(clients_); 472 ClientList clients_copy(clients_);
468 for (ClientList::const_iterator client = clients_copy.begin(); 473 for (ClientList::const_iterator client = clients_copy.begin();
469 client != clients_copy.end(); client++) { 474 client != clients_copy.end(); client++) {
470 ConnectionToClient* connection_other = client->get()->connection(); 475 ConnectionToClient* connection_other = client->get()->connection();
471 if (connection_other != connection) { 476 if (connection_other != connection) {
472 OnClientDisconnected(connection_other); 477 OnClientDisconnected(connection_other);
473 } 478 }
474 } 479 }
475 // Those disconnections should have killed the screen recorder. 480 // Those disconnections should have killed the screen recorder.
476 CHECK(recorder_.get() == NULL); 481 CHECK(recorder_.get() == NULL);
477 482
478 // Create a new RecordSession if there was none. 483 // Create a new RecordSession if there was none.
479 if (!recorder_.get()) { 484 if (!recorder_.get()) {
480 // Then we create a ScreenRecorder passing the message loops that 485 // Then we create a ScreenRecorder passing the message loops that
481 // it should run on. 486 // it should run on.
482 Encoder* encoder = CreateEncoder(connection->session()->config()); 487 Encoder* encoder = CreateEncoder(config);
483 488
484 recorder_ = new ScreenRecorder(context_->main_message_loop(), 489 recorder_ = new ScreenRecorder(context_->main_message_loop(),
485 context_->encode_message_loop(), 490 context_->encode_message_loop(),
486 context_->network_message_loop(), 491 context_->network_message_loop(),
487 desktop_environment_->capturer(), 492 desktop_environment_->capturer(),
488 encoder); 493 encoder);
489 } 494 }
490 495
491 // Immediately add the connection and start the session. 496 // Immediately add the connection and start the session.
492 recorder_->AddConnection(connection); 497 recorder_->AddConnection(connection);
493 recorder_->Start(); 498 recorder_->Start();
494 // Notify observers that there is at least one authenticated client. 499 // Notify observers that there is at least one authenticated client.
495 for (StatusObserverList::iterator it = status_observers_.begin(); 500 for (StatusObserverList::iterator it = status_observers_.begin();
496 it != status_observers_.end(); ++it) { 501 it != status_observers_.end(); ++it) {
497 (*it)->OnClientAuthenticated(connection); 502 (*it)->OnClientAuthenticated(connection);
498 } 503 }
499 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect, 504 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect,
500 // including closing the connection on failure of a critical operation. 505 // including closing the connection on failure of a critical operation.
501 EnableCurtainMode(true); 506 EnableCurtainMode(true);
502 if (is_it2me_) { 507 if (is_it2me_) {
503 std::string username = connection->session()->jid(); 508 std::string username = jid;
504 size_t pos = username.find('/'); 509 size_t pos = username.find('/');
505 if (pos != std::string::npos) 510 if (pos != std::string::npos)
506 username.replace(pos, std::string::npos, ""); 511 username.replace(pos, std::string::npos, "");
507 desktop_environment_->OnConnect(username); 512 desktop_environment_->OnConnect(username);
508 } 513 }
509 } 514 }
510 515
511 void ChromotingHost::LocalLoginFailed( 516 void ChromotingHost::LocalLoginFailed(
512 scoped_refptr<ConnectionToClient> connection) { 517 scoped_refptr<ConnectionToClient> connection) {
513 if (MessageLoop::current() != context_->main_message_loop()) { 518 if (MessageLoop::current() != context_->main_message_loop()) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 635
631 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin(); 636 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin();
632 it != shutdown_tasks_.end(); ++it) { 637 it != shutdown_tasks_.end(); ++it) {
633 (*it)->Run(); 638 (*it)->Run();
634 delete *it; 639 delete *it;
635 } 640 }
636 shutdown_tasks_.clear(); 641 shutdown_tasks_.clear();
637 } 642 }
638 643
639 } // namespace remoting 644 } // namespace remoting
OLDNEW
« remoting/host/chromoting_host.h ('K') | « remoting/host/chromoting_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698