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

Unified Diff: remoting/host/resizing_host_observer.cc

Issue 12545026: ResizingHostObserver is created by the desktop environment together with other stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/resizing_host_observer.cc
diff --git a/remoting/host/resizing_host_observer.cc b/remoting/host/resizing_host_observer.cc
index e1c96b5470093f6906d64ec075d718e1c10f6d14..7491eea6f759651f3b1565e048f98e5a0736b733 100644
--- a/remoting/host/resizing_host_observer.cc
+++ b/remoting/host/resizing_host_observer.cc
@@ -4,42 +4,12 @@
#include "remoting/host/resizing_host_observer.h"
-#include <set>
+#include <list>
#include "base/logging.h"
#include "remoting/host/desktop_resizer.h"
-#include "remoting/host/host_status_monitor.h"
-namespace remoting {
-
-ResizingHostObserver::ResizingHostObserver(
- DesktopResizer* desktop_resizer,
- base::WeakPtr<HostStatusMonitor> monitor)
- : desktop_resizer_(desktop_resizer),
- monitor_(monitor),
- original_size_(SkISize::Make(0, 0)) {
- monitor_->AddStatusObserver(this);
-}
-
-ResizingHostObserver::~ResizingHostObserver() {
- if (monitor_)
- monitor_->RemoveStatusObserver(this);
-}
-
-void ResizingHostObserver::OnClientAuthenticated(const std::string& jid) {
- // This implementation assumes a single connected client, which is what the
- // host currently supports
- DCHECK(client_jid_.empty());
- original_size_ = desktop_resizer_->GetCurrentSize();
-}
-
-void ResizingHostObserver::OnClientDisconnected(const std::string& jid) {
- if (!original_size_.isZero()) {
- desktop_resizer_->RestoreSize(original_size_);
- original_size_.set(0, 0);
- }
- client_jid_.clear();
-}
+namespace {
class CandidateSize {
public:
@@ -123,25 +93,39 @@ class CandidateSize {
SkISize size_;
};
+} // namespace
+
+namespace remoting {
+
+ResizingHostObserver::ResizingHostObserver(
+ scoped_ptr<DesktopResizer> desktop_resizer)
+ : desktop_resizer_(desktop_resizer.Pass()),
+ original_size_(desktop_resizer_->GetCurrentSize()) {
+}
+
+ResizingHostObserver::~ResizingHostObserver() {
+ if (!original_size_.isZero())
+ desktop_resizer_->RestoreSize(original_size_);
+}
+
void ResizingHostObserver::OnClientResolutionChanged(
- const std::string& jid,
- const SkISize& preferred_size,
- const SkIPoint& dpi) {
- if (preferred_size.isEmpty()) {
+ const SkIPoint& client_dpi,
+ const SkISize& client_size) {
+ if (client_size.isEmpty()) {
return;
}
// If the implementation returns any sizes, pick the best one according to
// the algorithm described in CandidateSize::IsBetterThen.
std::list<SkISize> sizes =
- desktop_resizer_->GetSupportedSizes(preferred_size);
+ desktop_resizer_->GetSupportedSizes(client_size);
if (sizes.empty()) {
return;
}
- CandidateSize best_size(sizes.front(), preferred_size);
+ CandidateSize best_size(sizes.front(), client_size);
for (std::list<SkISize>::const_iterator i = ++sizes.begin();
i != sizes.end(); ++i) {
- CandidateSize candidate_size(*i, preferred_size);
+ CandidateSize candidate_size(*i, client_size);
if (candidate_size.IsBetterThan(best_size)) {
best_size = candidate_size;
}

Powered by Google App Engine
This is Rietveld 408576698