summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 23:06:07 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 23:06:07 +0000
commit2cb5bd463052b15d5848e39689090fda1d5c34ec (patch)
tree0ec042307614e389bb799cdb3c005af3ebe761a4 /remoting/host
parentc588b7ffe21fffd49328a2b44edf903a8af843f3 (diff)
downloadchromium_src-2cb5bd463052b15d5848e39689090fda1d5c34ec.zip
chromium_src-2cb5bd463052b15d5848e39689090fda1d5c34ec.tar.gz
chromium_src-2cb5bd463052b15d5848e39689090fda1d5c34ec.tar.bz2
Rename SessionManager to ScreenRecorder
BUG=None TEST=None Review URL: http://codereview.chromium.org/5118002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/chromoting_host.cc32
-rw-r--r--remoting/host/chromoting_host.h19
-rw-r--r--remoting/host/screen_recorder.cc (renamed from remoting/host/session_manager.cc)96
-rw-r--r--remoting/host/screen_recorder.h (renamed from remoting/host/session_manager.h)18
-rw-r--r--remoting/host/screen_recorder_unittest.cc (renamed from remoting/host/session_manager_unittest.cc)28
5 files changed, 93 insertions, 100 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index d55b244..e58623d 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -16,7 +16,7 @@
#include "remoting/host/event_executor.h"
#include "remoting/host/host_config.h"
#include "remoting/host/host_stub_fake.h"
-#include "remoting/host/session_manager.h"
+#include "remoting/host/screen_recorder.h"
#include "remoting/protocol/connection_to_client.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/input_stub.h"
@@ -122,9 +122,9 @@ void ChromotingHost::Shutdown() {
}
// Tell the session to pause and then disconnect all clients.
- if (session_.get()) {
- session_->Pause();
- session_->RemoveAllConnections();
+ if (recorder_.get()) {
+ recorder_->Pause();
+ recorder_->RemoveAllConnections();
}
// Disconnect the client.
@@ -159,23 +159,23 @@ void ChromotingHost::OnClientConnected(ConnectionToClient* connection) {
DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
// Create a new RecordSession if there was none.
- if (!session_.get()) {
- // Then we create a SessionManager passing the message loops that
+ if (!recorder_.get()) {
+ // Then we create a ScreenRecorder passing the message loops that
// it should run on.
DCHECK(capturer_.get());
Encoder* encoder = CreateEncoder(connection->session()->config());
- session_ = new SessionManager(context_->main_message_loop(),
- context_->encode_message_loop(),
- context_->network_message_loop(),
- capturer_.release(),
- encoder);
+ recorder_ = new ScreenRecorder(context_->main_message_loop(),
+ context_->encode_message_loop(),
+ context_->network_message_loop(),
+ capturer_.release(),
+ encoder);
}
// Immediately add the connection and start the session.
- session_->AddConnection(connection);
- session_->Start();
+ recorder_->AddConnection(connection);
+ recorder_->Start();
VLOG(1) << "Session manager started";
}
@@ -184,9 +184,9 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) {
// Remove the connection from the session manager and pause the session.
// TODO(hclam): Pause only if the last connection disconnected.
- if (session_.get()) {
- session_->RemoveConnection(connection);
- session_->Pause();
+ if (recorder_.get()) {
+ recorder_->RemoveConnection(connection);
+ recorder_->Pause();
}
// Close the connection to connection just to be safe.
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 1d37ad9..f2db25f 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -33,7 +33,7 @@ class Capturer;
class ChromotingHostContext;
class Encoder;
class MutableHostConfig;
-class SessionManager;
+class ScreenRecorder;
// A class to implement the functionality of a host process.
//
@@ -45,17 +45,17 @@ class SessionManager;
//
// 2. We listen for incoming connection using libjingle. We will create
// a ConnectionToClient object that wraps around linjingle for transport.
-// Also create a SessionManager with appropriate Encoder and Capturer and
-// add the ConnectionToClient to this SessionManager for transporting the
-// screen captures. An InputStub is created and registered with the
+// A ScreenRecorder is created with an Encoder and a Capturer.
+// A ConnectionToClient is added to the ScreenRecorder for transporting
+// the screen captures. An InputStub is created and registered with the
// ConnectionToClient to receive mouse / keyboard events from the remote
// client.
// This is also the right time to create multiple threads to host
// the above objects. After we have done all the initialization
-// we'll start the SessionManager. We'll then enter the running state
+// we'll start the ScreenRecorder. We'll then enter the running state
// of the host process.
//
-// 3. When the user is disconencted, we will pause the SessionManager
+// 3. When the user is disconnected, we will pause the ScreenRecorder
// and try to terminate the threads we have created. This will allow
// all pending tasks to complete. After all of that completed we
// return to the idle state. We then go to step (2) if there a new
@@ -136,13 +136,10 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
scoped_refptr<MutableHostConfig> config_;
- // Capturer to be used by SessionManager. Once the SessionManager is
+ // Capturer to be used by ScreenRecorder. Once the ScreenRecorder is
// constructed this is set to NULL.
scoped_ptr<Capturer> capturer_;
- // constructed this is set to NULL.
- scoped_ptr<Encoder> encoder_;
-
// InputStub in the host executes input events received from the client.
scoped_ptr<protocol::InputStub> input_stub_;
@@ -165,7 +162,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
scoped_refptr<protocol::ConnectionToClient> connection_;
// Session manager for the host process.
- scoped_refptr<SessionManager> session_;
+ scoped_refptr<ScreenRecorder> recorder_;
// This task gets executed when this object fails to connect to the
// talk network or Shutdown() is called.
diff --git a/remoting/host/session_manager.cc b/remoting/host/screen_recorder.cc
index 219c982..a972c1a 100644
--- a/remoting/host/session_manager.cc
+++ b/remoting/host/screen_recorder.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/session_manager.h"
+#include "remoting/host/screen_recorder.h"
#include <algorithm>
@@ -39,7 +39,7 @@ static const int kSlowDownFactor = 10;
// capture rate.
static const int kRateDividers[] = {1, 2, 4, 8, 16};
-SessionManager::SessionManager(
+ScreenRecorder::ScreenRecorder(
MessageLoop* capture_loop,
MessageLoop* encode_loop,
MessageLoop* network_loop,
@@ -60,63 +60,63 @@ SessionManager::SessionManager(
DCHECK(network_loop_);
}
-SessionManager::~SessionManager() {
+ScreenRecorder::~ScreenRecorder() {
connections_.clear();
}
// Public methods --------------------------------------------------------------
-void SessionManager::Start() {
+void ScreenRecorder::Start() {
capture_loop_->PostTask(
- FROM_HERE, NewTracedMethod(this, &SessionManager::DoStart));
+ FROM_HERE, NewTracedMethod(this, &ScreenRecorder::DoStart));
}
-void SessionManager::Pause() {
+void ScreenRecorder::Pause() {
capture_loop_->PostTask(
- FROM_HERE, NewTracedMethod(this, &SessionManager::DoPause));
+ FROM_HERE, NewTracedMethod(this, &ScreenRecorder::DoPause));
}
-void SessionManager::SetMaxRate(double rate) {
+void ScreenRecorder::SetMaxRate(double rate) {
capture_loop_->PostTask(
- FROM_HERE, NewTracedMethod(this, &SessionManager::DoSetMaxRate, rate));
+ FROM_HERE, NewTracedMethod(this, &ScreenRecorder::DoSetMaxRate, rate));
}
-void SessionManager::AddConnection(
+void ScreenRecorder::AddConnection(
scoped_refptr<ConnectionToClient> connection) {
// Gets the init information for the connection.
capture_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoGetInitInfo, connection));
+ NewTracedMethod(this, &ScreenRecorder::DoGetInitInfo, connection));
}
-void SessionManager::RemoveConnection(
+void ScreenRecorder::RemoveConnection(
scoped_refptr<ConnectionToClient> connection) {
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoRemoveClient, connection));
+ NewTracedMethod(this, &ScreenRecorder::DoRemoveClient, connection));
}
-void SessionManager::RemoveAllConnections() {
+void ScreenRecorder::RemoveAllConnections() {
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoRemoveAllClients));
+ NewTracedMethod(this, &ScreenRecorder::DoRemoveAllClients));
}
// Private accessors -----------------------------------------------------------
-Capturer* SessionManager::capturer() {
+Capturer* ScreenRecorder::capturer() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
return capturer_.get();
}
-Encoder* SessionManager::encoder() {
+Encoder* ScreenRecorder::encoder() {
DCHECK_EQ(encode_loop_, MessageLoop::current());
return encoder_.get();
}
// Capturer thread -------------------------------------------------------------
-void SessionManager::DoStart() {
+void ScreenRecorder::DoStart() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
if (started_) {
@@ -130,10 +130,10 @@ void SessionManager::DoStart() {
// Starts the rate regulation.
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoStartRateControl));
+ NewTracedMethod(this, &ScreenRecorder::DoStartRateControl));
}
-void SessionManager::DoPause() {
+void ScreenRecorder::DoPause() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
if (!started_) {
@@ -146,10 +146,10 @@ void SessionManager::DoPause() {
// Pause the rate regulation.
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoPauseRateControl));
+ NewTracedMethod(this, &ScreenRecorder::DoPauseRateControl));
}
-void SessionManager::DoSetRate(double rate) {
+void ScreenRecorder::DoSetRate(double rate) {
DCHECK_EQ(capture_loop_, MessageLoop::current());
if (rate == rate_)
return;
@@ -163,7 +163,7 @@ void SessionManager::DoSetRate(double rate) {
ScheduleNextCapture();
}
-void SessionManager::DoSetMaxRate(double max_rate) {
+void ScreenRecorder::DoSetMaxRate(double max_rate) {
DCHECK_EQ(capture_loop_, MessageLoop::current());
// TODO(hclam): Should also check for small epsilon.
@@ -175,7 +175,7 @@ void SessionManager::DoSetMaxRate(double max_rate) {
}
}
-void SessionManager::ScheduleNextCapture() {
+void ScreenRecorder::ScheduleNextCapture() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
ScopedTracer tracer("capture");
@@ -189,11 +189,11 @@ void SessionManager::ScheduleNextCapture() {
static_cast<int>(base::Time::kMillisecondsPerSecond / rate_));
capture_loop_->PostDelayedTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoCapture),
+ NewTracedMethod(this, &ScreenRecorder::DoCapture),
interval.InMilliseconds());
}
-void SessionManager::DoCapture() {
+void ScreenRecorder::DoCapture() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
// Make sure we have at most two oustanding recordings. We can simply return
// if we can't make a capture now, the next capture will be started by the
@@ -225,10 +225,10 @@ void SessionManager::DoCapture() {
DCHECK(capturer());
capturer()->CaptureInvalidRects(
- NewCallback(this, &SessionManager::CaptureDoneCallback));
+ NewCallback(this, &ScreenRecorder::CaptureDoneCallback));
}
-void SessionManager::CaptureDoneCallback(
+void ScreenRecorder::CaptureDoneCallback(
scoped_refptr<CaptureData> capture_data) {
// TODO(hclam): There is a bug if the capturer doesn't produce any dirty
// rects.
@@ -236,10 +236,10 @@ void SessionManager::CaptureDoneCallback(
TraceContext::tracer()->PrintString("Capture Done");
encode_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoEncode, capture_data));
+ NewTracedMethod(this, &ScreenRecorder::DoEncode, capture_data));
}
-void SessionManager::DoFinishEncode() {
+void ScreenRecorder::DoFinishEncode() {
DCHECK_EQ(capture_loop_, MessageLoop::current());
// Decrement the number of recording in process since we have completed
@@ -252,7 +252,7 @@ void SessionManager::DoFinishEncode() {
DoCapture();
}
-void SessionManager::DoGetInitInfo(
+void ScreenRecorder::DoGetInitInfo(
scoped_refptr<ConnectionToClient> connection) {
DCHECK_EQ(capture_loop_, MessageLoop::current());
@@ -261,12 +261,12 @@ void SessionManager::DoGetInitInfo(
// Add the client to the list so it can receive update stream.
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoAddClient, connection));
+ NewTracedMethod(this, &ScreenRecorder::DoAddClient, connection));
}
// Network thread --------------------------------------------------------------
-void SessionManager::DoStartRateControl() {
+void ScreenRecorder::DoStartRateControl() {
DCHECK_EQ(network_loop_, MessageLoop::current());
if (rate_control_started_) {
@@ -277,7 +277,7 @@ void SessionManager::DoStartRateControl() {
ScheduleNextRateControl();
}
-void SessionManager::DoPauseRateControl() {
+void ScreenRecorder::DoPauseRateControl() {
DCHECK_EQ(network_loop_, MessageLoop::current());
if (!rate_control_started_) {
@@ -287,15 +287,15 @@ void SessionManager::DoPauseRateControl() {
rate_control_started_ = false;
}
-void SessionManager::ScheduleNextRateControl() {
+void ScreenRecorder::ScheduleNextRateControl() {
ScopedTracer tracer("Rate Control");
network_loop_->PostDelayedTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoRateControl),
+ NewTracedMethod(this, &ScreenRecorder::DoRateControl),
kRateControlInterval.InMilliseconds());
}
-void SessionManager::DoRateControl() {
+void ScreenRecorder::DoRateControl() {
DCHECK_EQ(network_loop_, MessageLoop::current());
// If we have been paused then shutdown the rate regulation loop.
@@ -326,11 +326,11 @@ void SessionManager::DoRateControl() {
// Then set the rate.
capture_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoSetRate, new_rate));
+ NewTracedMethod(this, &ScreenRecorder::DoSetRate, new_rate));
ScheduleNextRateControl();
}
-void SessionManager::DoSendVideoPacket(VideoPacket* packet) {
+void ScreenRecorder::DoSendVideoPacket(VideoPacket* packet) {
DCHECK_EQ(network_loop_, MessageLoop::current());
TraceContext::tracer()->PrintString("DoSendUpdate");
@@ -344,14 +344,14 @@ void SessionManager::DoSendVideoPacket(VideoPacket* packet) {
TraceContext::tracer()->PrintString("DoSendUpdate done");
}
-void SessionManager::DoAddClient(scoped_refptr<ConnectionToClient> connection) {
+void ScreenRecorder::DoAddClient(scoped_refptr<ConnectionToClient> connection) {
DCHECK_EQ(network_loop_, MessageLoop::current());
// TODO(hclam): Force a full frame for next encode.
connections_.push_back(connection);
}
-void SessionManager::DoRemoveClient(
+void ScreenRecorder::DoRemoveClient(
scoped_refptr<ConnectionToClient> connection) {
DCHECK_EQ(network_loop_, MessageLoop::current());
@@ -363,7 +363,7 @@ void SessionManager::DoRemoveClient(
}
}
-void SessionManager::DoRemoveAllClients() {
+void ScreenRecorder::DoRemoveAllClients() {
DCHECK_EQ(network_loop_, MessageLoop::current());
// Clear the list of connections.
@@ -372,7 +372,7 @@ void SessionManager::DoRemoveAllClients() {
// Encoder thread --------------------------------------------------------------
-void SessionManager::DoEncode(
+void ScreenRecorder::DoEncode(
scoped_refptr<CaptureData> capture_data) {
DCHECK_EQ(encode_loop_, MessageLoop::current());
TraceContext::tracer()->PrintString("DoEncode called");
@@ -380,7 +380,7 @@ void SessionManager::DoEncode(
// Early out if there's nothing to encode.
if (!capture_data->dirty_rects().size()) {
capture_loop_->PostTask(
- FROM_HERE, NewTracedMethod(this, &SessionManager::DoFinishEncode));
+ FROM_HERE, NewTracedMethod(this, &ScreenRecorder::DoFinishEncode));
return;
}
@@ -388,11 +388,11 @@ void SessionManager::DoEncode(
// added.
TraceContext::tracer()->PrintString("Encode start");
encoder_->Encode(capture_data, false,
- NewCallback(this, &SessionManager::EncodeDataAvailableTask));
+ NewCallback(this, &ScreenRecorder::EncodeDataAvailableTask));
TraceContext::tracer()->PrintString("Encode Done");
}
-void SessionManager::EncodeDataAvailableTask(VideoPacket* packet) {
+void ScreenRecorder::EncodeDataAvailableTask(VideoPacket* packet) {
DCHECK_EQ(encode_loop_, MessageLoop::current());
bool last = (packet->flags() & VideoPacket::LAST_PACKET) != 0;
@@ -403,11 +403,11 @@ void SessionManager::EncodeDataAvailableTask(VideoPacket* packet) {
// task. The ownership will eventually pass to the ConnectionToClients.
network_loop_->PostTask(
FROM_HERE,
- NewTracedMethod(this, &SessionManager::DoSendVideoPacket, packet));
+ NewTracedMethod(this, &ScreenRecorder::DoSendVideoPacket, packet));
if (last) {
capture_loop_->PostTask(
- FROM_HERE, NewTracedMethod(this, &SessionManager::DoFinishEncode));
+ FROM_HERE, NewTracedMethod(this, &ScreenRecorder::DoFinishEncode));
}
}
diff --git a/remoting/host/session_manager.h b/remoting/host/screen_recorder.h
index e5a12d2..2cd02b1 100644
--- a/remoting/host/session_manager.h
+++ b/remoting/host/screen_recorder.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_HOST_RECORD_SESSION_H_
-#define REMOTING_HOST_RECORD_SESSION_H_
+#ifndef REMOTING_HOST_SCREEN_RECORDER_H_
+#define REMOTING_HOST_SCREEN_RECORDER_H_
#include <vector>
@@ -56,22 +56,22 @@ class CaptureData;
// | Time
// v
//
-// SessionManager has the following responsibilities:
+// ScreenRecorder has the following responsibilities:
// 1. Make sure capture and encode occurs no more frequently than |rate|.
// 2. Make sure there is at most one outstanding capture not being encoded.
// 3. Distribute tasks on three threads on a timely fashion to minimize latency.
-class SessionManager : public base::RefCountedThreadSafe<SessionManager> {
+class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
public:
- // Construct a SessionManager. Message loops and threads are provided.
+ // Construct a ScreenRecorder. Message loops and threads are provided.
// This object does not own capturer and encoder.
- SessionManager(MessageLoop* capture_loop,
+ ScreenRecorder(MessageLoop* capture_loop,
MessageLoop* encode_loop,
MessageLoop* network_loop,
Capturer* capturer,
Encoder* encoder);
- virtual ~SessionManager();
+ virtual ~ScreenRecorder();
// Start recording.
void Start();
@@ -179,9 +179,9 @@ class SessionManager : public base::RefCountedThreadSafe<SessionManager> {
// The following member is accessed on the network thread.
bool rate_control_started_;
- DISALLOW_COPY_AND_ASSIGN(SessionManager);
+ DISALLOW_COPY_AND_ASSIGN(ScreenRecorder);
};
} // namespace remoting
-#endif // REMOTING_HOST_RECORD_SESSION_H_
+#endif // REMOTING_HOST_SCREEN_RECORDER_H_
diff --git a/remoting/host/session_manager_unittest.cc b/remoting/host/screen_recorder_unittest.cc
index 967d778..848226f 100644
--- a/remoting/host/session_manager_unittest.cc
+++ b/remoting/host/screen_recorder_unittest.cc
@@ -6,7 +6,7 @@
#include "base/task.h"
#include "remoting/base/mock_objects.h"
#include "remoting/host/mock_objects.h"
-#include "remoting/host/session_manager.h"
+#include "remoting/host/screen_recorder.h"
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/mock_objects.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -28,34 +28,33 @@ static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32;
static const VideoPacketFormat::Encoding kEncoding =
VideoPacketFormat::ENCODING_VERBATIM;
-class SessionManagerTest : public testing::Test {
+class ScreenRecorderTest : public testing::Test {
public:
- SessionManagerTest() {
+ ScreenRecorderTest() {
}
- protected:
- void Init() {
+ virtual void SetUp() {
+ // Capturer and Encoder are owned by ScreenRecorder.
capturer_ = new MockCapturer();
encoder_ = new MockEncoder();
connection_ = new MockConnectionToClient();
- record_ = new SessionManager(
+ record_ = new ScreenRecorder(
&message_loop_, &message_loop_, &message_loop_,
capturer_, encoder_);
}
- scoped_refptr<SessionManager> record_;
+ protected:
+ scoped_refptr<ScreenRecorder> record_;
scoped_refptr<MockConnectionToClient> connection_;
+
+ // The following mock objects are owned by ScreenRecorder.
MockCapturer* capturer_;
MockEncoder* encoder_;
MessageLoop message_loop_;
private:
- DISALLOW_COPY_AND_ASSIGN(SessionManagerTest);
+ DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest);
};
-TEST_F(SessionManagerTest, Init) {
- Init();
-}
-
ACTION_P2(RunCallback, rects, data) {
InvalidRects& dirty_rects = data->mutable_dirty_rects();
InvalidRects temp_rects;
@@ -72,10 +71,7 @@ ACTION_P(FinishEncode, msg) {
delete arg2;
}
-// BUG 57351
-TEST_F(SessionManagerTest, DISABLED_OneRecordCycle) {
- Init();
-
+TEST_F(ScreenRecorderTest, OneRecordCycle) {
InvalidRects update_rects;
update_rects.insert(gfx::Rect(0, 0, 10, 10));
DataPlanes planes;