OLD | NEW |
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/resizing_host_observer.h" | 5 #include "remoting/host/resizing_host_observer.h" |
6 #include "remoting/host/desktop_resizer.h" | |
7 | 6 |
8 #include <set> | 7 #include <set> |
9 | 8 |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "remoting/host/desktop_resizer.h" |
| 11 #include "remoting/host/host_status_monitor.h" |
11 | 12 |
12 namespace remoting { | 13 namespace remoting { |
13 | 14 |
14 ResizingHostObserver::ResizingHostObserver( | 15 ResizingHostObserver::ResizingHostObserver( |
15 DesktopResizer* desktop_resizer, ChromotingHost* host) | 16 DesktopResizer* desktop_resizer, |
| 17 base::WeakPtr<HostStatusMonitor> monitor) |
16 : desktop_resizer_(desktop_resizer), | 18 : desktop_resizer_(desktop_resizer), |
17 host_(host), | 19 monitor_(monitor), |
18 original_size_(SkISize::Make(0, 0)) { | 20 original_size_(SkISize::Make(0, 0)) { |
19 if (host_ != NULL) { | 21 monitor_->AddStatusObserver(this); |
20 host_->AddStatusObserver(this); | |
21 } | |
22 } | 22 } |
23 | 23 |
24 ResizingHostObserver::~ResizingHostObserver() { | 24 ResizingHostObserver::~ResizingHostObserver() { |
25 if (host_ != NULL) { | 25 if (monitor_) |
26 host_->RemoveStatusObserver(this); | 26 monitor_->RemoveStatusObserver(this); |
27 } | |
28 } | 27 } |
29 | 28 |
30 void ResizingHostObserver::OnClientAuthenticated(const std::string& jid) { | 29 void ResizingHostObserver::OnClientAuthenticated(const std::string& jid) { |
31 // This implementation assumes a single connected client, which is what the | 30 // This implementation assumes a single connected client, which is what the |
32 // host currently supports | 31 // host currently supports |
33 DCHECK(client_jid_.empty()); | 32 DCHECK(client_jid_.empty()); |
34 original_size_ = desktop_resizer_->GetCurrentSize(); | 33 original_size_ = desktop_resizer_->GetCurrentSize(); |
35 } | 34 } |
36 | 35 |
37 void ResizingHostObserver::OnClientDisconnected(const std::string& jid) { | 36 void ResizingHostObserver::OnClientDisconnected(const std::string& jid) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if (candidate_size.IsBetterThan(best_size)) { | 145 if (candidate_size.IsBetterThan(best_size)) { |
147 best_size = candidate_size; | 146 best_size = candidate_size; |
148 } | 147 } |
149 } | 148 } |
150 SkISize current_size = desktop_resizer_->GetCurrentSize(); | 149 SkISize current_size = desktop_resizer_->GetCurrentSize(); |
151 if (best_size.size() != current_size) | 150 if (best_size.size() != current_size) |
152 desktop_resizer_->SetSize(best_size.size()); | 151 desktop_resizer_->SetSize(best_size.size()); |
153 } | 152 } |
154 | 153 |
155 } // namespace remoting | 154 } // namespace remoting |
OLD | NEW |