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

Unified Diff: remoting/host/client_connection.cc

Issue 2829018: Fix thread usage in chromoting host (Closed)
Patch Set: removed useless test Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/client_connection.h ('k') | remoting/host/client_connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/client_connection.cc
diff --git a/remoting/host/client_connection.cc b/remoting/host/client_connection.cc
index d2c0df0102216732cc012eb66cf7dbaad3321e3f..d69a326efde08d41c105ff7426ad4c1aff496bb1 100644
--- a/remoting/host/client_connection.cc
+++ b/remoting/host/client_connection.cc
@@ -38,7 +38,10 @@ ClientConnection::~ClientConnection() {
void ClientConnection::SendInitClientMessage(int width, int height) {
DCHECK_EQ(loop_, MessageLoop::current());
DCHECK(!update_stream_size_);
- DCHECK(channel_.get());
+
+ // If we are disconnected then return.
+ if (!channel_)
+ return;
HostMessage msg;
msg.mutable_init_client()->set_width(width);
@@ -49,7 +52,10 @@ void ClientConnection::SendInitClientMessage(int width, int height) {
void ClientConnection::SendBeginUpdateStreamMessage() {
DCHECK_EQ(loop_, MessageLoop::current());
- DCHECK(channel_.get());
+
+ // If we are disconnected then return.
+ if (!channel_)
+ return;
HostMessage msg;
msg.mutable_begin_update_stream();
@@ -65,7 +71,10 @@ void ClientConnection::SendUpdateStreamPacketMessage(
const UpdateStreamPacketHeader* header,
scoped_refptr<DataBuffer> data) {
DCHECK_EQ(loop_, MessageLoop::current());
- DCHECK(channel_.get());
+
+ // If we are disconnected then return.
+ if (!channel_)
+ return;
HostMessage msg;
msg.mutable_update_stream_packet()->mutable_header()->CopyFrom(*header);
@@ -81,7 +90,10 @@ void ClientConnection::SendUpdateStreamPacketMessage(
void ClientConnection::SendEndUpdateStreamMessage() {
DCHECK_EQ(loop_, MessageLoop::current());
- DCHECK(channel_.get());
+
+ // If we are disconnected then return.
+ if (!channel_)
+ return;
HostMessage msg;
msg.mutable_end_update_stream();
@@ -116,8 +128,11 @@ int ClientConnection::GetPendingUpdateStreamMessages() {
void ClientConnection::Disconnect() {
DCHECK_EQ(loop_, MessageLoop::current());
- DCHECK(channel_.get());
- channel_->Close();
+ // If there is a channel then close it and release the reference.
+ if (channel_) {
+ channel_->Close();
+ channel_ = NULL;
+ }
}
void ClientConnection::OnStateChange(JingleChannel* channel,
« no previous file with comments | « remoting/host/client_connection.h ('k') | remoting/host/client_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698