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

Unified Diff: remoting/protocol/connection_to_client.cc

Issue 8495024: Access ChromotingHost::clients_ only on network thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_to_client.cc
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
index 6b2bbd11a124a5028cc9928c822ca38249fef476..5e3c4114f2cba99db467b3a0ebe590977b17b4eb 100644
--- a/remoting/protocol/connection_to_client.cc
+++ b/remoting/protocol/connection_to_client.cc
@@ -34,8 +34,8 @@ ConnectionToClient::ConnectionToClient(base::MessageLoopProxy* message_loop,
}
ConnectionToClient::~ConnectionToClient() {
- // TODO(hclam): When we shut down the viewer we may have to close the
- // connection.
+ if (session_.get())
+ message_loop_->DeleteSoon(FROM_HERE, session_.release());
}
void ConnectionToClient::SetEventHandler(EventHandler* event_handler) {
@@ -48,18 +48,21 @@ protocol::Session* ConnectionToClient::session() {
}
void ConnectionToClient::Disconnect() {
- // This method can be called from main thread so perform threading switching.
- if (!message_loop_->BelongsToCurrentThread()) {
- message_loop_->PostTask(
- FROM_HERE, base::Bind(&ConnectionToClient::Disconnect, this));
- return;
- }
+ DCHECK(message_loop_->BelongsToCurrentThread());
CloseChannels();
- // If there is a session then release it, causing it to close.
- if (session_.get())
- session_.reset();
+ DCHECK(session_.get());
+ Session* session = session_.release();
+
+ // It may not be safe to delete |session_| here becase this method
+ // may be invoked in resonse to a libjingle event and libjingle's
+ // sigslot doesn't handle it properly, so postpone the deletion.
+ message_loop_->DeleteSoon(FROM_HERE, session);
+
+ // This should trigger OnConnectionClosed() event and this object
+ // may be destroyed as the result.
+ session->Close();
}
void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698