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

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

Issue 3320003: Allows chromoting host to be connected again after connection drops. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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
« no previous file with comments | « no previous file | remoting/host/session_manager.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // it should run on. 63 // it should run on.
64 DCHECK(capturer_.get()); 64 DCHECK(capturer_.get());
65 DCHECK(encoder_.get()); 65 DCHECK(encoder_.get());
66 session_ = new SessionManager(context_->capture_message_loop(), 66 session_ = new SessionManager(context_->capture_message_loop(),
67 context_->encode_message_loop(), 67 context_->encode_message_loop(),
68 context_->main_message_loop(), 68 context_->main_message_loop(),
69 capturer_.get(), 69 capturer_.get(),
70 encoder_.get()); 70 encoder_.get());
71 71
72 // Immediately add the client and start the session. 72 // Immediately add the client and start the session.
73 session_->AddClient(client); 73 session_->AddClient(client);
Sergey Ulanov 2010/09/02 01:20:24 This code is duplicated below. Move this out of th
74 session_->Start(); 74 session_->Start();
75 LOG(INFO) << "Session manager started"; 75 LOG(INFO) << "Session manager started";
76 } else { 76 } else {
77 // If a session manager already exists we simply add the new client. 77 // If a session manager already exists we simply add the new client.
78 session_->AddClient(client); 78 session_->AddClient(client);
79 session_->Start();
79 } 80 }
80 } 81 }
81 82
82 void ChromotingHost::OnClientDisconnected(ClientConnection* client) { 83 void ChromotingHost::OnClientDisconnected(ClientConnection* client) {
83 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 84 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
84 85
85 // Remove the client from the session manager and pause the session. 86 // Remove the client from the session manager and pause the session.
86 // TODO(hclam): Pause only if the last client disconnected. 87 // TODO(hclam): Pause only if the last client disconnected.
87 if (session_.get()) { 88 if (session_.get()) {
88 session_->RemoveClient(client); 89 session_->RemoveClient(client);
89 session_->Pause(); 90 session_->Pause();
90 } 91 }
91 92
93 // Close the connection to client just to be safe.
94 client->Disconnect();
95
92 // Also remove reference to ClientConnection from this object. 96 // Also remove reference to ClientConnection from this object.
93 client_ = NULL; 97 client_ = NULL;
94 } 98 }
95 99
96 //////////////////////////////////////////////////////////////////////////// 100 ////////////////////////////////////////////////////////////////////////////
97 // ClientConnection::EventHandler implementations 101 // ClientConnection::EventHandler implementations
98 void ChromotingHost::HandleMessages(ClientConnection* client, 102 void ChromotingHost::HandleMessages(ClientConnection* client,
99 ClientMessageList* messages) { 103 ClientMessageList* messages) {
100 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 104 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
101 105
102 // Delegate the messages to EventExecutor and delete the unhandled 106 // Delegate the messages to EventExecutor and delete the unhandled
103 // messages. 107 // messages.
104 DCHECK(executor_.get()); 108 DCHECK(executor_.get());
105 executor_->HandleInputEvents(messages); 109 executor_->HandleInputEvents(messages);
106 STLDeleteElements<ClientMessageList>(messages); 110 STLDeleteElements<ClientMessageList>(messages);
107 } 111 }
108 112
109 void ChromotingHost::OnConnectionOpened(ClientConnection* client) { 113 void ChromotingHost::OnConnectionOpened(ClientConnection* client) {
110 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 114 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
111 115
112 // Completes the client connection. 116 // Completes the client connection.
113 LOG(INFO) << "Connection to client established."; 117 LOG(INFO) << "Connection to client established.";
114 OnClientConnected(client_.get()); 118 OnClientConnected(client_.get());
115 } 119 }
116 120
117 void ChromotingHost::OnConnectionClosed(ClientConnection* client) { 121 void ChromotingHost::OnConnectionClosed(ClientConnection* client) {
118 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 122 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
119 123
120 // Completes the client connection.
121 LOG(INFO) << "Connection to client closed."; 124 LOG(INFO) << "Connection to client closed.";
122 OnClientDisconnected(client_.get()); 125 OnClientDisconnected(client_.get());
123 } 126 }
124 127
125 void ChromotingHost::OnConnectionFailed(ClientConnection* client) { 128 void ChromotingHost::OnConnectionFailed(ClientConnection* client) {
126 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 129 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
127 130
128 // The client has disconnected.
129 LOG(ERROR) << "Connection failed unexpectedly."; 131 LOG(ERROR) << "Connection failed unexpectedly.";
130 OnClientDisconnected(client_.get()); 132 OnClientDisconnected(client_.get());
131 } 133 }
132 134
133 //////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////
134 // JingleClient::Callback implementations 136 // JingleClient::Callback implementations
135 void ChromotingHost::OnStateChange(JingleClient* jingle_client, 137 void ChromotingHost::OnStateChange(JingleClient* jingle_client,
136 JingleClient::State state) { 138 JingleClient::State state) {
137 if (state == JingleClient::CONNECTED) { 139 if (state == JingleClient::CONNECTED) {
138 DCHECK_EQ(jingle_client_.get(), jingle_client); 140 DCHECK_EQ(jingle_client_.get(), jingle_client);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 heartbeat_sender_->Stop(); 262 heartbeat_sender_->Stop();
261 } 263 }
262 264
263 // Lastly call the shutdown task. 265 // Lastly call the shutdown task.
264 if (shutdown_task_.get()) { 266 if (shutdown_task_.get()) {
265 shutdown_task_->Run(); 267 shutdown_task_->Run();
266 } 268 }
267 } 269 }
268 270
269 } // namespace remoting 271 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698