diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 05:07:40 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-07 05:07:40 +0000 |
commit | 9e2a3137641bc104980e13388b6088d3f4a9b52f (patch) | |
tree | 353e7915a047c43b466f2d4de514605a71691b45 /remoting/host | |
parent | 7feba7ed4d88f95d041abd6bea7a2ba93d9a9f3a (diff) | |
download | chromium_src-9e2a3137641bc104980e13388b6088d3f4a9b52f.zip chromium_src-9e2a3137641bc104980e13388b6088d3f4a9b52f.tar.gz chromium_src-9e2a3137641bc104980e13388b6088d3f4a9b52f.tar.bz2 |
Switch remoting/protocol to new callbacks
There is still some code that uses old callbacks (particularly unittests) - I will convert them in a separate CL.
BUG=None
TEST=Unittests
Review URL: http://codereview.chromium.org/8116021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/chromoting_host.cc | 4 | ||||
-rw-r--r-- | remoting/host/chromoting_host_unittest.cc | 12 | ||||
-rw-r--r-- | remoting/host/client_session.cc | 5 | ||||
-rw-r--r-- | remoting/host/client_session.h | 3 | ||||
-rw-r--r-- | remoting/host/client_session_unittest.cc | 16 | ||||
-rw-r--r-- | remoting/host/screen_recorder.cc | 7 | ||||
-rw-r--r-- | remoting/host/screen_recorder_unittest.cc | 5 |
7 files changed, 20 insertions, 32 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 8eb6b33..7d738d8 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -465,7 +465,7 @@ void ChromotingHost::AddAuthenticatedClient( protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus(); status->set_success(true); connection->client_stub()->BeginSessionResponse( - status, new DeleteTask<protocol::LocalLoginStatus>(status)); + status, base::Bind(&DeletePointer<protocol::LocalLoginStatus>, status)); // Disconnect all other clients. // Iterate over a copy of the list of clients, to avoid mutating the list @@ -526,7 +526,7 @@ void ChromotingHost::LocalLoginFailed( protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus(); status->set_success(false); connection->client_stub()->BeginSessionResponse( - status, new DeleteTask<protocol::LocalLoginStatus>(status)); + status, base::Bind(&DeletePointer<protocol::LocalLoginStatus>, status)); } void ChromotingHost::ProcessPreAuthentication( diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index 2ae5ee4..4f48e53 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -50,8 +50,7 @@ void PostQuitTask(MessageLoop* message_loop) { // Run the task and delete it afterwards. This action is used to deal with // done callbacks. ACTION(RunDoneTask) { - arg1->Run(); - delete arg1; + arg1.Run(); } ACTION_P(QuitMainMessageLoop, message_loop) { @@ -118,11 +117,9 @@ class ChromotingHostTest : public testing::Test { session_config2_ = SessionConfig::GetDefault(); ON_CALL(video_stub_, ProcessVideoPacket(_, _)) - .WillByDefault( - DoAll(DeleteArg<0>(), DeleteArg<1>())); + .WillByDefault(DeleteArg<0>()); ON_CALL(video_stub2_, ProcessVideoPacket(_, _)) - .WillByDefault( - DoAll(DeleteArg<0>(), DeleteArg<1>())); + .WillByDefault(DeleteArg<0>()); ON_CALL(*connection_.get(), video_stub()) .WillByDefault(Return(&video_stub_)); ON_CALL(*connection_.get(), client_stub()) @@ -191,7 +188,7 @@ class ChromotingHostTest : public testing::Test { NewRunnableMethod(client.get(), &ClientSession::BeginSessionRequest, &credentials_, - NewRunnableFunction(&DummyDoneTask))); + base::Bind(&DummyDoneTask))); } // Helper method to remove a client connection from ChromotingHost. @@ -501,4 +498,5 @@ TEST_F(ChromotingHostTest, CurtainModeIT2Me) { host_->set_it2me(false); EXPECT_THAT(curtain_activated, false); } + } // namespace remoting diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 36bb89c..78dcddf 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -48,10 +48,11 @@ ClientSession::~ClientSession() { } void ClientSession::BeginSessionRequest( - const protocol::LocalLoginCredentials* credentials, Task* done) { + const protocol::LocalLoginCredentials* credentials, + const base::Closure& done) { DCHECK(event_handler_); - base::ScopedTaskRunner done_runner(done); + base::ScopedClosureRunner done_runner(done); bool success = false; switch (credentials->type()) { diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h index bc35a45..013dc57 100644 --- a/remoting/host/client_session.h +++ b/remoting/host/client_session.h @@ -50,7 +50,8 @@ class ClientSession : public protocol::HostStub, // protocol::HostStub interface. virtual void BeginSessionRequest( - const protocol::LocalLoginCredentials* credentials, Task* done); + const protocol::LocalLoginCredentials* credentials, + const base::Closure& done); // protocol::InputStub interface. virtual void InjectKeyEvent(const protocol::KeyEvent& event); diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index be66a80..d7e1124 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc @@ -9,16 +9,6 @@ namespace remoting { -namespace { - -// A task that does nothing. -class DummyTask : public Task { - public: - void Run() {} -}; - -} // namespace - using protocol::MockConnectionToClient; using protocol::MockConnectionToClientEventHandler; using protocol::MockHostStub; @@ -131,7 +121,7 @@ TEST_F(ClientSessionTest, InputStubFilter) { // because the client isn't authenticated yet. client_session_->InjectKeyEvent(key_event1); client_session_->InjectMouseEvent(mouse_event1); - client_session_->BeginSessionRequest(&credentials, new DummyTask()); + client_session_->BeginSessionRequest(&credentials, base::Closure()); // These events should get through to the input stub. client_session_->InjectKeyEvent(key_event2_down); client_session_->InjectKeyEvent(key_event2_up); @@ -166,7 +156,7 @@ TEST_F(ClientSessionTest, LocalInputTest) { EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(100, 101))); EXPECT_CALL(input_stub_, InjectMouseEvent(EqualsMouseEvent(200, 201))); - client_session_->BeginSessionRequest(&credentials, new DummyTask()); + client_session_->BeginSessionRequest(&credentials, base::Closure()); // This event should get through to the input stub. client_session_->InjectMouseEvent(mouse_event1); // This one should too because the local event echoes the remote one. @@ -219,7 +209,7 @@ TEST_F(ClientSessionTest, ClampMouseEvents) { EXPECT_CALL(*user_authenticator_, Authenticate(_, _)) .WillOnce(Return(true)); EXPECT_CALL(session_event_handler_, LocalLoginSucceeded(_)); - client_session_->BeginSessionRequest(&credentials, new DummyTask()); + client_session_->BeginSessionRequest(&credentials, base::Closure()); int input_x[3] = { -999, 100, 999 }; int expected_x[3] = { 0, 100, 199 }; diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc index cca7c37..98266e3 100644 --- a/remoting/host/screen_recorder.cc +++ b/remoting/host/screen_recorder.cc @@ -268,17 +268,16 @@ void ScreenRecorder::DoSendVideoPacket(VideoPacket* packet) { for (ConnectionToClientList::const_iterator i = connections_.begin(); i < connections_.end(); ++i) { - Task* done_task = NULL; + base::Closure done_task; // Call FrameSentCallback() only for the last packet in the first // connection. if (last && i == connections_.begin()) { - done_task = NewRunnableMethod(this, &ScreenRecorder::FrameSentCallback, - packet); + done_task = base::Bind(&ScreenRecorder::FrameSentCallback, this, packet); } else { // TODO(hclam): Fix this code since it causes multiple deletion if there's // more than one connection. - done_task = new DeleteTask<VideoPacket>(packet); + done_task = base::Bind(&DeletePointer<VideoPacket>, packet); } (*i)->video_stub()->ProcessVideoPacket(packet, done_task); diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc index 4a821e9..05c0904 100644 --- a/remoting/host/screen_recorder_unittest.cc +++ b/remoting/host/screen_recorder_unittest.cc @@ -48,8 +48,7 @@ ACTION(FinishEncode) { } ACTION(FinishSend) { - arg1->Run(); - delete arg1; + arg1.Run(); } // Helper method to quit the main message loop. @@ -131,7 +130,7 @@ TEST_F(ScreenRecorderTest, OneRecordCycle) { // Expect the client be notified. EXPECT_CALL(video_stub, ProcessVideoPacket(_, _)) .Times(1) - .WillOnce(DoAll(DeleteArg<0>(), DeleteArg<1>())); + .WillOnce(DeleteArg<0>()); EXPECT_CALL(video_stub, GetPendingPackets()) .Times(AtLeast(0)) .WillRepeatedly(Return(0)); |