| 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 if (monitor_) |
| 20 host_->AddStatusObserver(this); | 22 monitor_->AddStatusObserver(this); |
| 21 } | |
| 22 } | 23 } |
| 23 | 24 |
| 24 ResizingHostObserver::~ResizingHostObserver() { | 25 ResizingHostObserver::~ResizingHostObserver() { |
| 25 if (host_ != NULL) { | 26 if (monitor_) |
| 26 host_->RemoveStatusObserver(this); | 27 monitor_->RemoveStatusObserver(this); |
| 27 } | |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ResizingHostObserver::OnClientAuthenticated(const std::string& jid) { | 30 void ResizingHostObserver::OnClientAuthenticated(const std::string& jid) { |
| 31 // This implementation assumes a single connected client, which is what the | 31 // This implementation assumes a single connected client, which is what the |
| 32 // host currently supports | 32 // host currently supports |
| 33 DCHECK(client_jid_.empty()); | 33 DCHECK(client_jid_.empty()); |
| 34 original_size_ = desktop_resizer_->GetCurrentSize(); | 34 original_size_ = desktop_resizer_->GetCurrentSize(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ResizingHostObserver::OnClientDisconnected(const std::string& jid) { | 37 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)) { | 146 if (candidate_size.IsBetterThan(best_size)) { |
| 147 best_size = candidate_size; | 147 best_size = candidate_size; |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 SkISize current_size = desktop_resizer_->GetCurrentSize(); | 150 SkISize current_size = desktop_resizer_->GetCurrentSize(); |
| 151 if (best_size.size() != current_size) | 151 if (best_size.size() != current_size) |
| 152 desktop_resizer_->SetSize(best_size.size()); | 152 desktop_resizer_->SetSize(best_size.size()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace remoting | 155 } // namespace remoting |
| OLD | NEW |