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

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

Issue 12386035: Moving host status events monitoring to a separate interface (HostStatusMonitor). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 9 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
« no previous file with comments | « remoting/host/curtaining_host_observer.h ('k') | remoting/host/host_event_logger.h » ('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) 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 #include "remoting/host/curtaining_host_observer.h" 5 #include "remoting/host/curtaining_host_observer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "remoting/host/curtain_mode.h" 8 #include "remoting/host/curtain_mode.h"
9 #include "remoting/host/chromoting_host.h" 9 #include "remoting/host/host_status_monitor.h"
10 10
11 namespace remoting { 11 namespace remoting {
12 12
13 CurtainingHostObserver::CurtainingHostObserver( 13 CurtainingHostObserver::CurtainingHostObserver(
14 CurtainMode *curtain, scoped_refptr<ChromotingHost> host) 14 CurtainMode *curtain, base::WeakPtr<HostStatusMonitor> monitor)
15 : curtain_(curtain), host_(host) { 15 : curtain_(curtain), monitor_(monitor) {
16 host_->AddStatusObserver(this); 16 monitor_->AddStatusObserver(this);
17 } 17 }
18 18
19 CurtainingHostObserver::~CurtainingHostObserver() { 19 CurtainingHostObserver::~CurtainingHostObserver() {
20 host_->RemoveStatusObserver(this); 20 if (monitor_)
21 monitor_->RemoveStatusObserver(this);
21 curtain_->SetActivated(false); 22 curtain_->SetActivated(false);
22 } 23 }
23 24
24 void CurtainingHostObserver::SetEnableCurtaining(bool enable) { 25 void CurtainingHostObserver::SetEnableCurtaining(bool enable) {
25 enable_curtaining_ = enable; 26 enable_curtaining_ = enable;
26 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); 27 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty());
27 } 28 }
28 29
29 void CurtainingHostObserver::OnClientAuthenticated(const std::string& jid) { 30 void CurtainingHostObserver::OnClientAuthenticated(const std::string& jid) {
30 active_clients_.insert(jid); 31 active_clients_.insert(jid);
31 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); 32 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty());
32 } 33 }
33 34
34 void CurtainingHostObserver::OnClientDisconnected(const std::string& jid) { 35 void CurtainingHostObserver::OnClientDisconnected(const std::string& jid) {
35 active_clients_.erase(jid); 36 active_clients_.erase(jid);
36 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty()); 37 curtain_->SetActivated(enable_curtaining_ && !active_clients_.empty());
37 } 38 }
38 39
39 } // namespace remoting 40 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/curtaining_host_observer.h ('k') | remoting/host/host_event_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698