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

Unified Diff: remoting/host/it2me_observer.h

Issue 8725016: Refactor IT2Me-specific functions into a HostObserver subclass. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused header Created 9 years, 1 month 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/it2me_observer.h
diff --git a/remoting/host/desktop_environment.h b/remoting/host/it2me_observer.h
similarity index 53%
copy from remoting/host/desktop_environment.h
copy to remoting/host/it2me_observer.h
index 28da047e1f227931e2598eb3284cd55ca3763aaf..27aa9fb28b967d8a20987b26b66e3f519b094239 100644
--- a/remoting/host/desktop_environment.h
+++ b/remoting/host/it2me_observer.h
@@ -2,64 +2,74 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_
-#define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_
+#ifndef REMOTING_HOST_IT2ME_OBSERVER_H_
+#define REMOTING_HOST_IT2ME_OBSERVER_H_
#include <string>
#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
+#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
-#include "base/time.h"
+
#include "remoting/base/scoped_thread_proxy.h"
+#include "remoting/host/host_status_observer.h"
+
+// Milliseconds before the continue window is shown.
+static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000;
+
+// Milliseconds before the continue window is automatically dismissed and
+// the connection is closed.
+static const int kContinueWindowHideTimeoutMs = 60 * 1000;
namespace remoting {
-class Capturer;
class ChromotingHost;
class ChromotingHostContext;
class ContinueWindow;
-class Curtain;
class DisconnectWindow;
-class EventExecutor;
class LocalInputMonitor;
+class SignalStrategy;
-class DesktopEnvironment {
+// This class implements the IT2Me-specific parts of the ChromotingHost:
+// Disconnect and Continue window popups.
+// IT2Me-specific handling of multiple connection attempts.
+class It2MeObserver : public HostStatusObserver {
Sergey Ulanov 2011/11/29 20:18:00 I don't think this is a good name for this class -
Lambros 2011/11/30 20:47:02 Done.
public:
- static DesktopEnvironment* Create(ChromotingHostContext* context);
-
- // DesktopEnvironment takes ownership of all the objects passed in.
- DesktopEnvironment(ChromotingHostContext* context,
- Capturer* capturer,
- EventExecutor* event_executor,
- Curtain* curtain,
- DisconnectWindow* disconnect_window,
- ContinueWindow* continue_window,
- LocalInputMonitor* monitor);
- virtual ~DesktopEnvironment();
+ It2MeObserver(ChromotingHost* host, ChromotingHostContext* context);
+ virtual ~It2MeObserver();
+
+ void Init();
+
+ // HostStatusObserver implementation. These methods will be called from the
+ // network thread.
+ virtual void OnSignallingConnected(SignalStrategy* signal_strategy,
+ const std::string& full_jid) OVERRIDE;
+ virtual void OnSignallingDisconnected() OVERRIDE;
+ virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
+ virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
+ virtual void OnAccessDenied() OVERRIDE;
+ virtual void OnShutdown() OVERRIDE;
// Shuts down the object and all its resources synchronously. Must
// be called on the UI thread.
void Shutdown();
- void set_host(ChromotingHost* host) { host_ = host; }
+ private:
+ class TimerTask;
- Capturer* capturer() const { return capturer_.get(); }
- EventExecutor* event_executor() const { return event_executor_.get(); }
- Curtain* curtain() const { return curtain_.get(); }
+ // Allow ChromotingHostTest::SetUp() to call InitFrom().
+ friend class ChromotingHostTest;
- // Called whenever a new client has connected.
- void OnConnect(const std::string& username);
+ // Used by unit-tests as an alternative to Init() so that mock versions of
+ // internal objects can be used. This takes ownership of all objects passed
+ // in.
+ void InitFrom(DisconnectWindow* disconnect_window,
+ ContinueWindow* continue_window,
+ LocalInputMonitor* monitor);
- // Called when the last client has disconnected.
+ void OnConnect(const std::string& username);
void OnLastDisconnect();
- // Called when the remote connection has been paused/unpaused.
- void OnPause(bool pause);
-
- private:
- class TimerTask;
-
void ProcessOnConnect(const std::string& username);
void ProcessOnLastDisconnect();
@@ -74,8 +84,6 @@ class DesktopEnvironment {
// Called by the ContinueWindow implementation (on the UI thread) when the
// user dismisses the Continue prompt.
- // TODO(lambroslambrou): Move this method to the (to be written)
- // It2MeObserver class.
void ContinueSession(bool continue_session);
void StartContinueWindowTimer(bool start);
@@ -83,22 +91,12 @@ class DesktopEnvironment {
void OnContinueWindowTimer();
void OnShutdownHostTimer();
- // The host that owns this DesktopEnvironment.
ChromotingHost* host_;
// Host context used to make sure operations are run on the correct thread.
// This is owned by the ChromotingHost.
ChromotingHostContext* context_;
- // Capturer to be used by ScreenRecorder.
- scoped_ptr<Capturer> capturer_;
-
- // Executes input events received from the client.
- scoped_ptr<EventExecutor> event_executor_;
-
- // Curtain ensures privacy for the remote user.
- scoped_ptr<Curtain> curtain_;
-
// Provide a user interface allowing the host user to close the connection.
scoped_ptr<DisconnectWindow> disconnect_window_;
@@ -117,9 +115,13 @@ class DesktopEnvironment {
ScopedThreadProxy ui_thread_proxy_;
- DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment);
+ // The JID of the currently-authenticated user (or an empty string if no user
+ // is connected).
+ std::string authenticated_jid_;
+
+ DISALLOW_COPY_AND_ASSIGN(It2MeObserver);
};
} // namespace remoting
-#endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_
+#endif // REMOTING_HOST_IT2ME_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698