diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 22:12:33 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-30 22:12:33 +0000 |
commit | 28876a7113e313be07102bd26bf0ef693b84c9c9 (patch) | |
tree | 52dc2fbda74d981fb913c40b983c231614a0c699 /remoting/protocol | |
parent | d7ff359b4a7851a1e3da81b66c2b76ea7286d885 (diff) | |
download | chromium_src-28876a7113e313be07102bd26bf0ef693b84c9c9.zip chromium_src-28876a7113e313be07102bd26bf0ef693b84c9c9.tar.gz chromium_src-28876a7113e313be07102bd26bf0ef693b84c9c9.tar.bz2 |
Fix threading problem caught by DCHECKs in ChromotingHost
Post tasks to the right message loop.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/5096009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/connection_to_client.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc index 7d9fb17..3b4bd3f 100644 --- a/remoting/protocol/connection_to_client.cc +++ b/remoting/protocol/connection_to_client.cc @@ -49,7 +49,13 @@ protocol::Session* ConnectionToClient::session() { } void ConnectionToClient::Disconnect() { - DCHECK_EQ(loop_, MessageLoop::current()); + // This method can be called from main thread so perform threading switching. + if (MessageLoop::current() != loop_) { + loop_->PostTask( + FROM_HERE, + NewRunnableMethod(this, &ConnectionToClient::Disconnect)); + return; + } // If there is a channel then close it and release the reference. if (session_) { @@ -80,8 +86,14 @@ void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { dispatcher_->Initialize(session_.get(), host_stub_, input_stub_); } - loop_->PostTask(FROM_HERE, - NewRunnableMethod(this, &ConnectionToClient::StateChangeTask, state)); + // This method can be called from main thread so perform threading switching. + if (MessageLoop::current() != loop_) { + loop_->PostTask( + FROM_HERE, + NewRunnableMethod(this, &ConnectionToClient::StateChangeTask, state)); + } else { + StateChangeTask(state); + } } void ConnectionToClient::StateChangeTask(protocol::Session::State state) { |