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

Unified Diff: remoting/host/client_session.h

Issue 10915206: [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased to enable try jobs. Created 8 years, 3 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/client_session.h
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index 109e180cfb0234fe01ec3579fbc9e8e9223221d4..af788779d1df2c58583c1c9cbed86496047aa5d6 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -7,6 +7,8 @@
#include <list>
+#include "base/memory/ref_counted.h"
+#include "base/sequenced_task_runner_helpers.h"
#include "base/time.h"
#include "base/timer.h"
#include "base/threading/non_thread_safe.h"
@@ -22,15 +24,27 @@
#include "remoting/protocol/input_stub.h"
#include "third_party/skia/include/core/SkPoint.h"
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
namespace remoting {
+class AudioEncoder;
+class AudioScheduler;
+struct ClientSessionTraits;
+class DesktopEnvironment;
+class ScreenRecorder;
+class VideoEncoder;
class VideoFrameCapturer;
// A ClientSession keeps a reference to a connection to a client, and maintains
// per-client state.
-class ClientSession : public protocol::HostStub,
- public protocol::ConnectionToClient::EventHandler,
- public base::NonThreadSafe {
+class ClientSession
+ : public base::RefCountedThreadSafe<ClientSession, ClientSessionTraits>,
+ public protocol::HostStub,
+ public protocol::ConnectionToClient::EventHandler,
+ public base::NonThreadSafe {
public:
// Callback interface for passing events to the ChromotingHost.
class EventHandler {
@@ -66,12 +80,12 @@ class ClientSession : public protocol::HostStub,
};
ClientSession(EventHandler* event_handler,
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_ptr<protocol::ConnectionToClient> connection,
- protocol::ClipboardStub* host_clipboard_stub,
- protocol::InputStub* host_input_stub,
- VideoFrameCapturer* capturer,
+ scoped_ptr<DesktopEnvironment> desktop_environment,
const base::TimeDelta& max_duration);
- virtual ~ClientSession();
// protocol::HostStub interface.
virtual void NotifyClientDimensions(
@@ -94,15 +108,22 @@ class ClientSession : public protocol::HostStub,
const protocol::TransportRoute& route) OVERRIDE;
// Disconnects the session and destroys the transport. Event handler
- // is guaranteed not to be called after this method is called. Can
- // be called multiple times. The object should not be used after
- // this method returns.
+ // is guaranteed not to be called after this method is called. The object
+ // should not be used after this method returns.
void Disconnect();
+ // Stop all recorders asynchronously. |done_task| is executed when the session
+ // is completely stopped.
+ void Stop(const base::Closure& done_task);
+
protocol::ConnectionToClient* connection() const {
return connection_.get();
}
+ DesktopEnvironment* desktop_environment() const {
+ return desktop_environment_.get();
+ }
+
const std::string& client_jid() { return client_jid_; }
bool is_authenticated() { return auth_input_filter_.enabled(); }
@@ -116,15 +137,32 @@ class ClientSession : public protocol::HostStub,
// keys or mouse buttons pressed then these will be released.
void SetDisableInputs(bool disable_inputs);
+ private:
+ friend class base::DeleteHelper<ClientSession>;
+ friend struct ClientSessionTraits;
+ virtual ~ClientSession();
+
// Creates a proxy for sending clipboard events to the client.
scoped_ptr<protocol::ClipboardStub> CreateClipboardProxy();
- private:
+ void OnRecorderStopped();
+
+ // Creates an audio encoder for the specified configuration.
+ static scoped_ptr<AudioEncoder> CreateAudioEncoder(
+ const protocol::SessionConfig& config);
+
+ // Creates a video encoder for the specified configuration.
+ static VideoEncoder* CreateVideoEncoder(
+ const protocol::SessionConfig& config);
+
EventHandler* event_handler_;
// The connection to the client.
scoped_ptr<protocol::ConnectionToClient> connection_;
+ // The desktop environment used by this session.
+ scoped_ptr<DesktopEnvironment> desktop_environment_;
+
std::string client_jid_;
// The host clipboard and input stubs to which this object delegates.
@@ -159,12 +197,6 @@ class ClientSession : public protocol::HostStub,
// it.
base::WeakPtrFactory<protocol::ClipboardStub> client_clipboard_factory_;
- // VideoFrameCapturer, used to determine current screen size for ensuring
- // injected mouse events fall within the screen area.
- // TODO(lambroslambrou): Move floor-control logic, and clamping to screen
- // area, out of this class (crbug.com/96508).
- VideoFrameCapturer* capturer_;
-
// The maximum duration of this session.
// There is no maximum if this value is <= 0.
base::TimeDelta max_duration_;
@@ -173,9 +205,30 @@ class ClientSession : public protocol::HostStub,
// is reached.
base::OneShotTimer<ClientSession> max_duration_timer_;
+ scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+
+ // Schedulers for audio and video capture.
+ scoped_refptr<AudioScheduler> audio_scheduler_;
+ scoped_refptr<ScreenRecorder> video_recorder_;
+
+ // Number of screen recorders and audio schedulers that are currently being
+ // used or shutdown. Used to delay shutdown if one or more
+ // recorders/schedulers are asynchronously shutting down.
+ int active_recorders_;
+
+ // The task to be executed when the session is completely stopped.
+ base::Closure done_task_;
+
DISALLOW_COPY_AND_ASSIGN(ClientSession);
};
+// Destroys |ClienSession| instances on the network thread.
+struct ClientSessionTraits {
+ static void Destruct(const ClientSession* client);
+};
+
} // namespace remoting
#endif // REMOTING_HOST_CLIENT_SESSION_H_

Powered by Google App Engine
This is Rietveld 408576698