Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 6 #define REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread.h" | |
| 13 #include "base/timer.h" | |
| 10 | 14 |
| 11 namespace remoting { | 15 namespace remoting { |
| 12 | 16 |
| 13 class Capturer; | 17 class Capturer; |
| 18 class ChromotingHost; | |
| 19 class ChromotingHostContext; | |
| 14 class ContinueWindow; | 20 class ContinueWindow; |
| 15 class Curtain; | 21 class Curtain; |
| 16 class DisconnectWindow; | 22 class DisconnectWindow; |
| 17 class EventExecutor; | 23 class EventExecutor; |
| 18 class LocalInputMonitor; | 24 class LocalInputMonitor; |
| 19 | 25 |
| 20 class DesktopEnvironment { | 26 class DesktopEnvironment |
| 27 : public base::RefCountedThreadSafe<DesktopEnvironment> { | |
|
Jamie
2011/07/07 00:26:48
Why does this now need to be refcounted?
Sergey Ulanov
2011/07/07 00:33:17
It's better to avoid making this object refcounted
garykac
2011/07/07 20:38:09
I've disabled refcounting.
| |
| 21 public: | 28 public: |
| 29 static DesktopEnvironment* Create(ChromotingHostContext* context); | |
| 30 | |
| 22 // DesktopEnvironment takes ownership of all the objects passed the ctor. | 31 // DesktopEnvironment takes ownership of all the objects passed the ctor. |
| 23 DesktopEnvironment(Capturer* capturer, EventExecutor* event_executor, | 32 DesktopEnvironment(ChromotingHostContext* context, |
| 24 Curtain* curtain, DisconnectWindow* disconnect_window, | 33 Capturer* capturer, |
| 34 EventExecutor* event_executor, | |
| 35 Curtain* curtain, | |
| 36 DisconnectWindow* disconnect_window, | |
| 25 ContinueWindow* continue_window, | 37 ContinueWindow* continue_window, |
| 26 LocalInputMonitor* monitor); | 38 LocalInputMonitor* monitor); |
| 27 virtual ~DesktopEnvironment(); | 39 virtual ~DesktopEnvironment(); |
| 28 | 40 |
| 41 void set_host(ChromotingHost* host) { host_ = host; } | |
| 42 | |
| 29 Capturer* capturer() const { return capturer_.get(); } | 43 Capturer* capturer() const { return capturer_.get(); } |
| 30 EventExecutor* event_executor() const { return event_executor_.get(); } | 44 EventExecutor* event_executor() const { return event_executor_.get(); } |
| 31 Curtain* curtain() const { return curtain_.get(); } | 45 Curtain* curtain() const { return curtain_.get(); } |
| 32 DisconnectWindow* disconnect_window() { return disconnect_window_.get(); } | 46 |
| 33 ContinueWindow* continue_window() { return continue_window_.get(); } | 47 // Called whenever a new client has connected. |
| 34 LocalInputMonitor* local_input_monitor() { | 48 void OnConnect(const std::string& username); |
| 35 return local_input_monitor_.get(); | 49 |
| 36 } | 50 // Called when the last client has disconnected. |
| 51 void OnLastDisconnect(); | |
| 52 | |
| 53 // Called when the remote connection has been paused/unpaused. | |
| 54 void OnPause(bool pause); | |
| 37 | 55 |
| 38 private: | 56 private: |
| 57 void MonitorLocalInputs(bool enable); | |
| 58 | |
| 59 // Show or hide the Disconnect window on the UI thread. If |show| is false, | |
| 60 // hide the window, ignoring the |username| parameter. | |
| 61 void ShowDisconnectWindow(bool show, const std::string& username); | |
| 62 | |
| 63 // Show or hide the Continue Sharing window on the UI thread. | |
| 64 void ShowContinueWindow(bool show); | |
| 65 | |
| 66 void StartContinueWindowTimer(bool start); | |
| 67 | |
| 68 void ContinueWindowTimerFunc(); | |
| 69 | |
| 70 // The host that owns this DesktopEnvironment. | |
| 71 ChromotingHost* host_; | |
| 72 | |
| 73 // Host context used to make sure operations are run on the correct thread. | |
| 74 // This is owned by the ChromotingHost. | |
| 75 ChromotingHostContext* context_; | |
| 76 | |
| 39 // Capturer to be used by ScreenRecorder. | 77 // Capturer to be used by ScreenRecorder. |
| 40 scoped_ptr<Capturer> capturer_; | 78 scoped_ptr<Capturer> capturer_; |
| 41 | 79 |
| 42 // Executes input events received from the client. | 80 // Executes input events received from the client. |
| 43 scoped_ptr<EventExecutor> event_executor_; | 81 scoped_ptr<EventExecutor> event_executor_; |
| 44 | 82 |
| 45 // Curtain ensures privacy for the remote user. | 83 // Curtain ensures privacy for the remote user. |
| 46 scoped_ptr<Curtain> curtain_; | 84 scoped_ptr<Curtain> curtain_; |
| 47 | 85 |
| 48 // Provide a user interface allowing the host user to close the connection. | 86 // Provide a user interface allowing the host user to close the connection. |
| 49 scoped_ptr<DisconnectWindow> disconnect_window_; | 87 scoped_ptr<DisconnectWindow> disconnect_window_; |
| 50 | 88 |
| 51 // Provide a user interface requiring the user to periodically re-confirm | 89 // Provide a user interface requiring the user to periodically re-confirm |
| 52 // the connection. | 90 // the connection. |
| 53 scoped_ptr<ContinueWindow> continue_window_; | 91 scoped_ptr<ContinueWindow> continue_window_; |
| 54 | 92 |
| 55 // Monitor local inputs to allow remote inputs to be blocked while the local | 93 // Monitor local inputs to allow remote inputs to be blocked while the local |
| 56 // user is trying to do something. | 94 // user is trying to do something. |
| 57 scoped_ptr<LocalInputMonitor> local_input_monitor_; | 95 scoped_ptr<LocalInputMonitor> local_input_monitor_; |
| 58 | 96 |
| 97 bool is_monitoring_local_inputs_; | |
| 98 | |
| 99 // Timer controlling the "continue session" dialog. The timer is started when | |
| 100 // a connection is made or re-confirmed. On expiry, inputs to the host are | |
| 101 // blocked and the dialog is shown. | |
| 102 base::OneShotTimer<DesktopEnvironment> continue_window_timer_; | |
| 103 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); | 104 DISALLOW_COPY_AND_ASSIGN(DesktopEnvironment); |
| 60 }; | 105 }; |
| 61 | 106 |
| 62 } // namespace remoting | 107 } // namespace remoting |
| 63 | 108 |
| 64 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ | 109 #endif // REMOTING_HOST_DESKTOP_ENVIRONMENT_H_ |
| OLD | NEW |