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

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

Issue 10048003: The Chromoting service should not start automatically unless it was configured from the webapp to d… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements the Windows service controlling Me2Me host processes 5 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions. 6 // running within user sessions.
7 7
8 #include "remoting/host/host_service_win.h" 8 #include "remoting/host/host_service_win.h"
9 9
10 #include <windows.h> 10 #include <windows.h>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 HostService::~HostService() { 111 HostService::~HostService() {
112 } 112 }
113 113
114 void HostService::AddWtsConsoleObserver(WtsConsoleObserver* observer) { 114 void HostService::AddWtsConsoleObserver(WtsConsoleObserver* observer) {
115 console_observers_.AddObserver(observer); 115 console_observers_.AddObserver(observer);
116 } 116 }
117 117
118 void HostService::RemoveWtsConsoleObserver(WtsConsoleObserver* observer) { 118 void HostService::RemoveWtsConsoleObserver(WtsConsoleObserver* observer) {
119 console_observers_.RemoveObserver(observer); 119 console_observers_.RemoveObserver(observer);
120
121 // Stop the service if there is no more observers.
Wez 2012/04/10 21:26:20 typo: is -> are
alexeypa (please no reviews) 2012/04/10 22:18:16 Done.
122 if (!console_observers_.might_have_observers()) {
Wez 2012/04/10 21:26:20 might_have_observers is reliable because our obser
alexeypa (please no reviews) 2012/04/10 22:18:16 I added a DCHECK.
123 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
124 }
120 } 125 }
121 126
122 void HostService::OnSessionChange() { 127 void HostService::OnSessionChange() {
123 // WTSGetActiveConsoleSessionId is a very cheap API. It basically reads 128 // WTSGetActiveConsoleSessionId is a very cheap API. It basically reads
124 // a single value from shared memory. Therefore it is better to check if 129 // a single value from shared memory. Therefore it is better to check if
125 // the console session is still the same every time a session change 130 // the console session is still the same every time a session change
126 // notification event is posted. This also takes care of coalescing multiple 131 // notification event is posted. This also takes care of coalescing multiple
127 // events into one since we look at the latest state. 132 // events into one since we look at the latest state.
128 uint32 console_session_id = kInvalidSession; 133 uint32 console_session_id = kInvalidSession;
129 if (!shutting_down_) { 134 if (!shutting_down_) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 355
351 int HostService::Run() { 356 int HostService::Run() {
352 return (this->*run_routine_)(); 357 return (this->*run_routine_)();
353 } 358 }
354 359
355 void HostService::RunMessageLoop() { 360 void HostService::RunMessageLoop() {
356 // Launch the I/O thread. 361 // Launch the I/O thread.
357 base::Thread io_thread(kIoThreadName); 362 base::Thread io_thread(kIoThreadName);
358 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0); 363 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
359 if (!io_thread.StartWithOptions(io_thread_options)) { 364 if (!io_thread.StartWithOptions(io_thread_options)) {
365 LOG(FATAL) << "Failed to start the I/O thread";
360 shutting_down_ = true; 366 shutting_down_ = true;
361 stopped_event_.Signal(); 367 stopped_event_.Signal();
362 return; 368 return;
363 } 369 }
364 370
365 WtsSessionProcessLauncher launcher(this, host_binary_, &io_thread); 371 WtsSessionProcessLauncher launcher(this, host_binary_,
372 message_loop_->message_loop_proxy(),
373 io_thread.message_loop_proxy());
Wez 2012/04/10 21:26:20 Are these related to this CL? If so then mention
alexeypa (please no reviews) 2012/04/10 22:18:16 It is already mentioned. I have to pass message_lo
366 374
367 // Run the service. 375 // Run the service.
368 message_loop_->Run(); 376 message_loop_->Run();
369 377
370 // Clean up the observers by emulating detaching from the console. 378 // Clean up the observers by emulating detaching from the console.
371 shutting_down_ = true; 379 shutting_down_ = true;
372 OnSessionChange(); 380 OnSessionChange();
373 381
374 // Release the control handler. 382 // Release the control handler.
375 stopped_event_.Signal(); 383 stopped_event_.Signal();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 595 }
588 596
589 remoting::HostService* service = remoting::HostService::GetInstance(); 597 remoting::HostService* service = remoting::HostService::GetInstance();
590 if (!service->InitWithCommandLine(command_line)) { 598 if (!service->InitWithCommandLine(command_line)) {
591 usage(argv[0]); 599 usage(argv[0]);
592 return kUsageExitCode; 600 return kUsageExitCode;
593 } 601 }
594 602
595 return service->Run(); 603 return service->Run();
596 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698