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

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

Issue 8624009: Refactor ContinueWindow::Show() to accept a callback parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac compile 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 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/desktop_environment.h" 5 #include "remoting/host/desktop_environment.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "remoting/host/capturer.h" 9 #include "remoting/host/capturer.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( 101 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
102 &DesktopEnvironment::ProcessOnConnect, base::Unretained(this), username)); 102 &DesktopEnvironment::ProcessOnConnect, base::Unretained(this), username));
103 } 103 }
104 104
105 void DesktopEnvironment::OnLastDisconnect() { 105 void DesktopEnvironment::OnLastDisconnect() {
106 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind( 106 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
107 &DesktopEnvironment::ProcessOnLastDisconnect, base::Unretained(this))); 107 &DesktopEnvironment::ProcessOnLastDisconnect, base::Unretained(this)));
108 } 108 }
109 109
110 void DesktopEnvironment::OnPause(bool pause) { 110 void DesktopEnvironment::OnPause(bool pause) {
111 ui_thread_proxy_.PostTask(FROM_HERE, base::Bind(
112 &DesktopEnvironment::ProcessOnPause, base::Unretained(this), pause));
113 } 111 }
114 112
115 void DesktopEnvironment::ProcessOnConnect(const std::string& username) { 113 void DesktopEnvironment::ProcessOnConnect(const std::string& username) {
116 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 114 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
117 115
118 MonitorLocalInputs(true); 116 MonitorLocalInputs(true);
119 ShowDisconnectWindow(true, username); 117 ShowDisconnectWindow(true, username);
120 StartContinueWindowTimer(true); 118 StartContinueWindowTimer(true);
121 } 119 }
122 120
123 void DesktopEnvironment::ProcessOnLastDisconnect() { 121 void DesktopEnvironment::ProcessOnLastDisconnect() {
124 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 122 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
125 123
126 MonitorLocalInputs(false); 124 MonitorLocalInputs(false);
127 ShowDisconnectWindow(false, std::string()); 125 ShowDisconnectWindow(false, std::string());
128 ShowContinueWindow(false); 126 ShowContinueWindow(false);
129 StartContinueWindowTimer(false); 127 StartContinueWindowTimer(false);
130 } 128 }
131 129
132 void DesktopEnvironment::ProcessOnPause(bool pause) {
133 if (!pause) {
134 timer_task_.reset();
135 StartContinueWindowTimer(true);
136 }
137 }
138
139 void DesktopEnvironment::MonitorLocalInputs(bool enable) { 130 void DesktopEnvironment::MonitorLocalInputs(bool enable) {
140 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 131 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
141 132
142 if (enable == is_monitoring_local_inputs_) 133 if (enable == is_monitoring_local_inputs_)
143 return; 134 return;
144 if (enable) { 135 if (enable) {
145 local_input_monitor_->Start(host_); 136 local_input_monitor_->Start(host_);
146 } else { 137 } else {
147 local_input_monitor_->Stop(); 138 local_input_monitor_->Stop();
148 } 139 }
149 is_monitoring_local_inputs_ = enable; 140 is_monitoring_local_inputs_ = enable;
150 } 141 }
151 142
152 void DesktopEnvironment::ShowDisconnectWindow(bool show, 143 void DesktopEnvironment::ShowDisconnectWindow(bool show,
153 const std::string& username) { 144 const std::string& username) {
154 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 145 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
155 146
156 if (show) { 147 if (show) {
157 disconnect_window_->Show(host_, username); 148 disconnect_window_->Show(host_, username);
158 } else { 149 } else {
159 disconnect_window_->Hide(); 150 disconnect_window_->Hide();
160 } 151 }
161 } 152 }
162 153
163 void DesktopEnvironment::ShowContinueWindow(bool show) { 154 void DesktopEnvironment::ShowContinueWindow(bool show) {
164 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 155 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
165 156
166 if (show) { 157 if (show) {
167 continue_window_->Show(host_); 158 continue_window_->Show(host_, base::Bind(
159 &DesktopEnvironment::ContinueSession, base::Unretained(this)));
Wez 2011/11/23 18:26:02 The intent is for ShowContinueWindow() and Continu
Lambros 2011/11/23 19:39:28 Yep.
168 } else { 160 } else {
169 continue_window_->Hide(); 161 continue_window_->Hide();
170 } 162 }
171 } 163 }
172 164
165 void DesktopEnvironment::ContinueSession(bool continue_session) {
166 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
167
168 if (continue_session) {
169 host_->PauseSession(false);
170 timer_task_.reset();
171 StartContinueWindowTimer(true);
172 } else {
173 host_->Shutdown(base::Closure());
Wez 2011/11/23 18:26:02 Shouldn't this be a call to OnShutdownHostTimer(),
Lambros 2011/11/23 19:39:28 It could be. I simply copied the implementation s
174 }
175 }
176
173 void DesktopEnvironment::StartContinueWindowTimer(bool start) { 177 void DesktopEnvironment::StartContinueWindowTimer(bool start) {
174 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 178 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
175 179
176 if (start) { 180 if (start) {
177 timer_task_.reset(new TimerTask( 181 timer_task_.reset(new TimerTask(
178 context_->ui_message_loop(), 182 context_->ui_message_loop(),
179 base::Bind(&DesktopEnvironment::OnContinueWindowTimer, 183 base::Bind(&DesktopEnvironment::OnContinueWindowTimer,
180 base::Unretained(this)), 184 base::Unretained(this)),
181 kContinueWindowShowTimeoutMs)); 185 kContinueWindowShowTimeoutMs));
182 } else if (!start) { 186 } else if (!start) {
(...skipping 16 matching lines...) Expand all
199 } 203 }
200 204
201 void DesktopEnvironment::OnShutdownHostTimer() { 205 void DesktopEnvironment::OnShutdownHostTimer() {
202 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread()); 206 DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
203 207
204 ShowContinueWindow(false); 208 ShowContinueWindow(false);
205 host_->Shutdown(base::Closure()); 209 host_->Shutdown(base::Closure());
206 } 210 }
207 211
208 } // namespace remoting 212 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698