summaryrefslogtreecommitdiffstats
path: root/remoting/host/ipc_desktop_environment.h
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 17:23:53 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 17:23:53 +0000
commitce404cae8c35d9c39b328e2f7207b852f482a15f (patch)
tree99624ecd8daa98c28eb35323aa465ca8819fd480 /remoting/host/ipc_desktop_environment.h
parente921967a10108d9751709ff4f35abd67b49103f8 (diff)
downloadchromium_src-ce404cae8c35d9c39b328e2f7207b852f482a15f.zip
chromium_src-ce404cae8c35d9c39b328e2f7207b852f482a15f.tar.gz
chromium_src-ce404cae8c35d9c39b328e2f7207b852f482a15f.tar.bz2
Making DesktopEnvironment a factory class used by ClientSession to create audio/video capturers and event executor for a pacticular desktop environment.
Other related changes: - AudioCapturer and VideoFrameCapturer are owned by AudioScheduler and VideoScheduler correspondingly. - Both AudioScheduler and VideoScheduler can now be stopped completely asynchronously. - AudioScheduler::SetEnabled() changed to Pause() to match the corresponding method provided by VideoScheduler. - ClientSession::Stop() is synchronous now. BUG=104544 Review URL: https://chromiumcodereview.appspot.com/11778049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/ipc_desktop_environment.h')
-rw-r--r--remoting/host/ipc_desktop_environment.h108
1 files changed, 88 insertions, 20 deletions
diff --git a/remoting/host/ipc_desktop_environment.h b/remoting/host/ipc_desktop_environment.h
index 53b5c0f..c851221 100644
--- a/remoting/host/ipc_desktop_environment.h
+++ b/remoting/host/ipc_desktop_environment.h
@@ -5,55 +5,123 @@
#ifndef REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_
#define REMOTING_HOST_IPC_DESKTOP_ENVIRONMENT_H_
+#include <map>
+#include <string>
+
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "ipc/ipc_platform_file.h"
+#include "base/memory/weak_ptr.h"
#include "remoting/host/desktop_environment.h"
+#include "remoting/host/desktop_session_connector.h"
namespace base {
class SingleThreadTaskRunner;
} // base
+namespace IPC {
+class ChannelProxy;
+} // namespace IPC
+
namespace remoting {
-class DesktopSessionConnector;
class DesktopSessionProxy;
// A variant of desktop environment integrating with the desktop by means of
// a helper process and talking to that process via IPC.
class IpcDesktopEnvironment : public DesktopEnvironment {
public:
- // |desktop_session_connector| is used to bind the IpcDesktopEnvironment to
- // a desktop session, to be notified with a new IPC channel every time
- // the desktop process is changed. |desktop_session_connector| must outlive
- // |this|. |client| specifies the client session owning |this|.
+ // |desktop_session_connector| is used to bind DesktopSessionProxy to
+ // a desktop session, to be notified every time the desktop process is
+ // restarted.
IpcDesktopEnvironment(
- scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- DesktopSessionConnector* desktop_session_connector,
- scoped_refptr<DesktopSessionProxy> desktop_session_proxy);
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
+ const std::string& client_jid,
+ const base::Closure& disconnect_callback,
+ base::WeakPtr<DesktopSessionConnector> desktop_session_connector);
virtual ~IpcDesktopEnvironment();
- virtual void Start(
- scoped_ptr<protocol::ClipboardStub> client_clipboard,
+ // DesktopEnvironment implementation.
+ virtual scoped_ptr<AudioCapturer> CreateAudioCapturer(
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner) OVERRIDE;
+ virtual scoped_ptr<EventExecutor> CreateEventExecutor(
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) OVERRIDE;
+ virtual scoped_ptr<VideoFrameCapturer> CreateVideoCapturer(
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) OVERRIDE;
+
+ private:
+ // Binds DesktopSessionProxy to a desktop session if it is not bound already.
+ void ConnectToDesktopSession();
+
+ // Task runner on which public methods of this class should be called.
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
+
+ // True if |desktop_session_proxy_| is connected to a desktop session.
+ bool connected_;
+
+ // Used to bind to a desktop session and receive notifications every time
+ // the desktop process is replaced.
+ base::WeakPtr<DesktopSessionConnector> desktop_session_connector_;
+
+ scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment);
+};
+
+// Used to create IpcDesktopEnvironment objects integrating with the desktop via
+// a helper process and talking to that process via IPC.
+class IpcDesktopEnvironmentFactory
+ : public DesktopEnvironmentFactory,
+ public DesktopSessionConnector {
+ public:
+ // Passes a reference to the IPC channel connected to the daemon process and
+ // relevant task runners. |daemon_channel| must outlive this object.
+ IpcDesktopEnvironmentFactory(
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
+ IPC::ChannelProxy* daemon_channel);
+ virtual ~IpcDesktopEnvironmentFactory();
+
+ // DesktopEnvironmentFactory implementation.
+ virtual scoped_ptr<DesktopEnvironment> Create(
const std::string& client_jid,
const base::Closure& disconnect_callback) OVERRIDE;
+ virtual bool SupportsAudioCapture() const OVERRIDE;
+
+ // DesktopSessionConnector implementation.
+ virtual void ConnectTerminal(
+ scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE;
+ virtual void DisconnectTerminal(
+ scoped_refptr<DesktopSessionProxy> desktop_session_proxy) OVERRIDE;
+ virtual void OnDesktopSessionAgentAttached(
+ int terminal_id,
+ IPC::PlatformFileForTransit desktop_process,
+ IPC::PlatformFileForTransit desktop_pipe) OVERRIDE;
+ virtual void OnTerminalDisconnected(int terminal_id) OVERRIDE;
private:
- // Used for IPC I/O.
- scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+ // Task runner on which public methods of this class should be called.
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
- DesktopSessionConnector* desktop_session_connector_;
+ // IPC channel connected to the daemon process.
+ IPC::ChannelProxy* daemon_channel_;
- scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
+ // List of DesktopEnvironment instances we've told the daemon process about.
+ typedef std::map<int, scoped_refptr<DesktopSessionProxy> >
+ ActiveConnectionsList;
+ ActiveConnectionsList active_connections_;
- // True if |this| has been connected to a desktop session.
- bool connected_;
+ // Factory for weak pointers to DesktopSessionConnector interface.
+ base::WeakPtrFactory<DesktopSessionConnector> connector_factory_;
- DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironment);
+ // Next desktop session ID. IDs are allocated sequentially starting from 0.
+ // This gives us more than 67 years of unique IDs assuming a new ID is
+ // allocated every second.
+ int next_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(IpcDesktopEnvironmentFactory);
};
} // namespace remoting