summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 02:07:41 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 02:07:41 +0000
commit1e1cb3bc787a85e1791f737f831d00ee08db364d (patch)
treeab228ff464b8bd78aee795e58262bd6c11e5f3dc /remoting/host
parentbe4565bce9bb1a5b3f5477cc27e20da6ddcc1de7 (diff)
downloadchromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.zip
chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.gz
chromium_src-1e1cb3bc787a85e1791f737f831d00ee08db364d.tar.bz2
Move code in src/remoting to the new callbacks.
BUG=None TEST=Remoting still works. Review URL: http://codereview.chromium.org/8493020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/capturer.h8
-rw-r--r--remoting/host/capturer_fake.cc7
-rw-r--r--remoting/host/capturer_fake.h4
-rw-r--r--remoting/host/capturer_fake_ascii.cc6
-rw-r--r--remoting/host/capturer_fake_ascii.h4
-rw-r--r--remoting/host/capturer_linux.cc10
-rw-r--r--remoting/host/capturer_mac.cc16
-rw-r--r--remoting/host/capturer_mac_unittest.cc9
-rw-r--r--remoting/host/capturer_win.cc15
-rw-r--r--remoting/host/chromoting_host.cc16
-rw-r--r--remoting/host/chromoting_host.h6
-rw-r--r--remoting/host/chromoting_host_unittest.cc25
-rw-r--r--remoting/host/continue_window_linux.cc2
-rw-r--r--remoting/host/continue_window_mac.mm2
-rw-r--r--remoting/host/continue_window_win.cc2
-rw-r--r--remoting/host/desktop_environment.cc2
-rw-r--r--remoting/host/disconnect_window_linux.cc2
-rw-r--r--remoting/host/disconnect_window_mac.mm2
-rw-r--r--remoting/host/disconnect_window_win.cc2
-rw-r--r--remoting/host/host_key_pair.h2
-rw-r--r--remoting/host/host_mock_objects.h3
-rw-r--r--remoting/host/json_host_config.cc3
-rw-r--r--remoting/host/local_input_monitor_mac.mm3
-rw-r--r--remoting/host/local_input_monitor_thread_linux.cc2
-rw-r--r--remoting/host/plugin/host_script_object.cc3
-rw-r--r--remoting/host/screen_recorder.cc44
-rw-r--r--remoting/host/screen_recorder_unittest.cc11
27 files changed, 94 insertions, 117 deletions
diff --git a/remoting/host/capturer.h b/remoting/host/capturer.h
index e29b7f5..9039e04 100644
--- a/remoting/host/capturer.h
+++ b/remoting/host/capturer.h
@@ -6,7 +6,7 @@
#define REMOTING_HOST_CAPTURER_H_
#include "base/basictypes.h"
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "remoting/base/capture_data.h"
#include "third_party/skia/include/core/SkRegion.h"
@@ -38,7 +38,8 @@ namespace remoting {
class Capturer {
public:
// CaptureCompletedCallback is called when the capturer has completed.
- typedef Callback1<scoped_refptr<CaptureData> >::Type CaptureCompletedCallback;
+ typedef base::Callback<void(scoped_refptr<CaptureData>)>
+ CaptureCompletedCallback;
virtual ~Capturer() {};
@@ -73,7 +74,8 @@ class Capturer {
// data of the previous capture.
// There can be at most one concurrent read going on when this
// method is called.
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) = 0;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) = 0;
// Get the size of the most recently captured screen.
virtual const SkISize& size_most_recent() const = 0;
diff --git a/remoting/host/capturer_fake.cc b/remoting/host/capturer_fake.cc
index 88bac10..647a148 100644
--- a/remoting/host/capturer_fake.cc
+++ b/remoting/host/capturer_fake.cc
@@ -68,9 +68,8 @@ void CapturerFake::InvalidateFullScreen() {
helper.InvalidateFullScreen();
}
-void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
- scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
-
+void CapturerFake::CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) {
GenerateImage();
InvalidateScreen(size_);
@@ -89,7 +88,7 @@ void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
helper.set_size_most_recent(capture_data->size());
- callback->Run(capture_data);
+ callback.Run(capture_data);
}
const SkISize& CapturerFake::size_most_recent() const {
diff --git a/remoting/host/capturer_fake.h b/remoting/host/capturer_fake.h
index 252fd40..ba74a98 100644
--- a/remoting/host/capturer_fake.h
+++ b/remoting/host/capturer_fake.h
@@ -27,8 +27,8 @@ class CapturerFake : public Capturer {
virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
- OVERRIDE;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) OVERRIDE;
virtual const SkISize& size_most_recent() const OVERRIDE;
private:
diff --git a/remoting/host/capturer_fake_ascii.cc b/remoting/host/capturer_fake_ascii.cc
index f2bb5d2..e0f5845 100644
--- a/remoting/host/capturer_fake_ascii.cc
+++ b/remoting/host/capturer_fake_ascii.cc
@@ -52,9 +52,7 @@ void CapturerFakeAscii::InvalidateFullScreen() {
}
void CapturerFakeAscii::CaptureInvalidRegion(
- CaptureCompletedCallback* callback) {
- scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
-
+ const CaptureCompletedCallback& callback) {
GenerateImage();
DataPlanes planes;
planes.data[0] = buffers_[current_buffer_].get();
@@ -65,7 +63,7 @@ void CapturerFakeAscii::CaptureInvalidRegion(
helper_.set_size_most_recent(capture_data->size());
- callback->Run(capture_data);
+ callback.Run(capture_data);
}
const SkISize& CapturerFakeAscii::size_most_recent() const {
diff --git a/remoting/host/capturer_fake_ascii.h b/remoting/host/capturer_fake_ascii.h
index 8902cee..07261e3 100644
--- a/remoting/host/capturer_fake_ascii.h
+++ b/remoting/host/capturer_fake_ascii.h
@@ -28,8 +28,8 @@ class CapturerFakeAscii : public Capturer {
virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
- OVERRIDE;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) OVERRIDE;
virtual const SkISize& size_most_recent() const;
private:
diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc
index 062f259..239aa16 100644
--- a/remoting/host/capturer_linux.cc
+++ b/remoting/host/capturer_linux.cc
@@ -79,8 +79,8 @@ class CapturerLinux : public Capturer {
virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
- OVERRIDE;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) OVERRIDE;
virtual const SkISize& size_most_recent() const OVERRIDE;
private:
@@ -264,9 +264,7 @@ void CapturerLinux::InvalidateFullScreen() {
}
void CapturerLinux::CaptureInvalidRegion(
- CaptureCompletedCallback* callback) {
- scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
-
+ const CaptureCompletedCallback& callback) {
// TODO(lambroslambrou): In the non-DAMAGE case, there should be no need
// for any X event processing in this class.
ProcessPendingXEvents();
@@ -286,7 +284,7 @@ void CapturerLinux::CaptureInvalidRegion(
current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
helper_.set_size_most_recent(capture_data->size());
- callback->Run(capture_data);
+ callback.Run(capture_data);
}
void CapturerLinux::ProcessPendingXEvents() {
diff --git a/remoting/host/capturer_mac.cc b/remoting/host/capturer_mac.cc
index a4ee518..394c8b1 100644
--- a/remoting/host/capturer_mac.cc
+++ b/remoting/host/capturer_mac.cc
@@ -153,8 +153,8 @@ class CapturerMac : public Capturer {
virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
- OVERRIDE;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) OVERRIDE;
virtual const SkISize& size_most_recent() const OVERRIDE;
private:
@@ -163,12 +163,12 @@ class CapturerMac : public Capturer {
void CgBlitPreLion(const VideoFrameBuffer& buffer, const SkRegion& region);
void CgBlitPostLion(const VideoFrameBuffer& buffer, const SkRegion& region);
void CaptureRegion(const SkRegion& region,
- CaptureCompletedCallback* callback);
+ const CaptureCompletedCallback& callback);
void ScreenRefresh(CGRectCount count, const CGRect *rect_array);
void ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
- size_t count,
- const CGRect *rect_array);
+ size_t count,
+ const CGRect *rect_array);
void DisplaysReconfigured(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags);
static void ScreenRefreshCallback(CGRectCount count,
@@ -346,7 +346,8 @@ void CapturerMac::InvalidateFullScreen() {
helper_.InvalidateFullScreen();
}
-void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
+void CapturerMac::CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) {
// Only allow captures when the display configuration is not occurring.
scoped_refptr<CaptureData> data;
@@ -391,8 +392,7 @@ void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
helper_.set_size_most_recent(data->size());
display_configuration_capture_event_.Signal();
- callback->Run(data);
- delete callback;
+ callback.Run(data);
}
void CapturerMac::GlBlitFast(const VideoFrameBuffer& buffer,
diff --git a/remoting/host/capturer_mac_unittest.cc b/remoting/host/capturer_mac_unittest.cc
index 80deedb..e6224ba 100644
--- a/remoting/host/capturer_mac_unittest.cc
+++ b/remoting/host/capturer_mac_unittest.cc
@@ -8,6 +8,7 @@
#include <ostream>
+#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -88,14 +89,14 @@ TEST_F(CapturerMacTest, Capture) {
SCOPED_TRACE("");
// Check that we get an initial full-screen updated.
CapturerCallback1 callback1;
- capturer_->CaptureInvalidRegion(
- NewCallback(&callback1, &CapturerCallback1::CaptureDoneCallback));
+ capturer_->CaptureInvalidRegion(base::Bind(
+ &CapturerCallback1::CaptureDoneCallback, base::Unretained(&callback1)));
// Check that subsequent dirty rects are propagated correctly.
AddDirtyRect();
CapturerCallback2 callback2(region_);
capturer_->InvalidateRegion(region_);
- capturer_->CaptureInvalidRegion(
- NewCallback(&callback2, &CapturerCallback2::CaptureDoneCallback));
+ capturer_->CaptureInvalidRegion(base::Bind(
+ &CapturerCallback2::CaptureDoneCallback, base::Unretained(&callback2)));
}
} // namespace remoting
diff --git a/remoting/host/capturer_win.cc b/remoting/host/capturer_win.cc
index cdb84cb..9d8b860 100644
--- a/remoting/host/capturer_win.cc
+++ b/remoting/host/capturer_win.cc
@@ -30,8 +30,8 @@ class CapturerGdi : public Capturer {
virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
virtual void InvalidateFullScreen() OVERRIDE;
- virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
- OVERRIDE;
+ virtual void CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) OVERRIDE;
virtual const SkISize& size_most_recent() const OVERRIDE;
private:
@@ -62,7 +62,7 @@ class CapturerGdi : public Capturer {
void CalculateInvalidRegion();
void CaptureRegion(const SkRegion& region,
- CaptureCompletedCallback* callback);
+ const CaptureCompletedCallback& callback);
void ReleaseBuffers();
// Generates an image in the current buffer.
@@ -144,7 +144,8 @@ void CapturerGdi::InvalidateFullScreen() {
helper_.InvalidateFullScreen();
}
-void CapturerGdi::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
+void CapturerGdi::CaptureInvalidRegion(
+ const CaptureCompletedCallback& callback) {
CalculateInvalidRegion();
SkRegion invalid_region;
helper_.SwapInvalidRegion(&invalid_region);
@@ -277,9 +278,7 @@ void CapturerGdi::CalculateInvalidRegion() {
}
void CapturerGdi::CaptureRegion(const SkRegion& region,
- CaptureCompletedCallback* callback) {
- scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
-
+ const CaptureCompletedCallback& callback) {
const VideoFrameBuffer& buffer = buffers_[current_buffer_];
current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
@@ -294,7 +293,7 @@ void CapturerGdi::CaptureRegion(const SkRegion& region,
helper_.set_size_most_recent(data->size());
- callback->Run(data);
+ callback.Run(data);
}
void CapturerGdi::CaptureImage() {
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index fe54f78..434552f 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -104,7 +104,7 @@ void ChromotingHost::Start() {
}
// This method is called when we need to destroy the host process.
-void ChromotingHost::Shutdown(Task* shutdown_task) {
+void ChromotingHost::Shutdown(const base::Closure& shutdown_task) {
if (MessageLoop::current() != context_->main_message_loop()) {
context_->main_message_loop()->PostTask(
FROM_HERE,
@@ -121,7 +121,7 @@ void ChromotingHost::Shutdown(Task* shutdown_task) {
context_->main_message_loop()->PostTask(FROM_HERE, shutdown_task);
return;
}
- if (shutdown_task)
+ if (!shutdown_task.is_null())
shutdown_tasks_.push_back(shutdown_task);
if (state_ == kStopping)
return;
@@ -263,7 +263,7 @@ void ChromotingHost::OnIncomingSession(
*response = protocol::SessionManager::DECLINE;
// Close existing sessions and shutdown the host.
- Shutdown(NULL);
+ Shutdown(base::Closure());
return;
}
@@ -331,10 +331,7 @@ void ChromotingHost::LocalMouseMoved(const SkIPoint& new_pos) {
void ChromotingHost::PauseSession(bool pause) {
if (context_->main_message_loop() != MessageLoop::current()) {
context_->main_message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(this,
- &ChromotingHost::PauseSession,
- pause));
+ FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause));
return;
}
ClientList::iterator client;
@@ -610,10 +607,9 @@ void ChromotingHost::ShutdownFinish() {
(*it)->OnShutdown();
}
- for (std::vector<Task*>::iterator it = shutdown_tasks_.begin();
+ for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin();
it != shutdown_tasks_.end(); ++it) {
- (*it)->Run();
- delete *it;
+ it->Run();
}
shutdown_tasks_.clear();
}
diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h
index 76c204c..2596afb 100644
--- a/remoting/host/chromoting_host.h
+++ b/remoting/host/chromoting_host.h
@@ -90,7 +90,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
// Asynchronously shutdown the host process. |shutdown_task| is
// called after shutdown is completed.
- void Shutdown(Task* shutdown_task);
+ void Shutdown(const base::Closure& shutdown_task);
// Adds |observer| to the list of status observers. Doesn't take
// ownership of |observer|, so |observer| must outlive this
@@ -245,9 +245,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
std::string access_code_;
- // Stores list of tasks that should be executed when we finish
+ // Stores list of closures that should be executed when we finish
// shutdown. Used only while |state_| is set to kStopping.
- std::vector<Task*> shutdown_tasks_;
+ std::vector<base::Closure> shutdown_tasks_;
UiStrings ui_strings_;
diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc
index 9a636c0..d5e4df6 100644
--- a/remoting/host/chromoting_host_unittest.cc
+++ b/remoting/host/chromoting_host_unittest.cc
@@ -171,24 +171,20 @@ class ChromotingHostTest : public testing::Test {
connection->set_host_stub(client.get());
context_.network_message_loop()->PostTask(
- FROM_HERE,
- NewRunnableFunction(&ChromotingHostTest::AddClientToHost,
- host_, client));
+ FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost,
+ host_, client));
if (authenticate) {
context_.network_message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(client.get(),
- &ClientSession::OnAuthenticationComplete));
+ FROM_HERE, base::Bind(&ClientSession::OnAuthenticationComplete,
+ client.get()));
}
}
// Helper method to remove a client connection from ChromotingHost.
void RemoveClientConnection() {
context_.network_message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(host_.get(),
- &ChromotingHost::OnClientDisconnected,
- connection_));
+ FROM_HERE, base::Bind(&ChromotingHost::OnClientDisconnected,
+ host_.get(), connection_));
}
static void AddClientToHost(scoped_refptr<ChromotingHost> host,
@@ -197,8 +193,7 @@ class ChromotingHostTest : public testing::Test {
}
void ShutdownHost() {
- host_->Shutdown(
- NewRunnableFunction(&PostQuitTask, &message_loop_));
+ host_->Shutdown(base::Bind(&PostQuitTask, &message_loop_));
}
protected:
@@ -237,9 +232,9 @@ TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) {
host_->Start();
message_loop_.PostTask(
- FROM_HERE,NewRunnableMethod(
- host_.get(), &ChromotingHost::Shutdown,
- NewRunnableFunction(&PostQuitTask, &message_loop_)));
+ FROM_HERE, base::Bind(
+ &ChromotingHost::Shutdown, host_.get(),
+ base::Bind(&PostQuitTask, &message_loop_)));
message_loop_.Run();
}
diff --git a/remoting/host/continue_window_linux.cc b/remoting/host/continue_window_linux.cc
index 431144d..ddd959c 100644
--- a/remoting/host/continue_window_linux.cc
+++ b/remoting/host/continue_window_linux.cc
@@ -97,7 +97,7 @@ void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) {
if (response_id == GTK_RESPONSE_OK) {
host_->PauseSession(false);
} else {
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
}
Hide();
}
diff --git a/remoting/host/continue_window_mac.mm b/remoting/host/continue_window_mac.mm
index c53c11f..2dac22c 100644
--- a/remoting/host/continue_window_mac.mm
+++ b/remoting/host/continue_window_mac.mm
@@ -143,7 +143,7 @@ ContinueWindow* ContinueWindow::Create() {
- (void)onCancel:(id)sender {
[self hide];
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
host_ = nil;
}
diff --git a/remoting/host/continue_window_win.cc b/remoting/host/continue_window_win.cc
index ed5eea2..73a214a 100644
--- a/remoting/host/continue_window_win.cc
+++ b/remoting/host/continue_window_win.cc
@@ -95,7 +95,7 @@ BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg,
return TRUE;
case IDC_CONTINUE_CANCEL:
CHECK(host_);
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
::EndDialog(hwnd, LOWORD(wParam));
hwnd_ = NULL;
return TRUE;
diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc
index d891fe6..c838a0f 100644
--- a/remoting/host/desktop_environment.cc
+++ b/remoting/host/desktop_environment.cc
@@ -202,7 +202,7 @@ void DesktopEnvironment::OnShutdownHostTimer() {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
ShowContinueWindow(false);
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
}
} // namespace remoting
diff --git a/remoting/host/disconnect_window_linux.cc b/remoting/host/disconnect_window_linux.cc
index b2dd6f5..b7292d6 100644
--- a/remoting/host/disconnect_window_linux.cc
+++ b/remoting/host/disconnect_window_linux.cc
@@ -120,7 +120,7 @@ void DisconnectWindowLinux::OnResponse(GtkWidget* dialog, int response_id) {
// button were visible).
CHECK(host_);
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
Hide();
}
diff --git a/remoting/host/disconnect_window_mac.mm b/remoting/host/disconnect_window_mac.mm
index 7c1ab44..94ba855 100644
--- a/remoting/host/disconnect_window_mac.mm
+++ b/remoting/host/disconnect_window_mac.mm
@@ -90,7 +90,7 @@ remoting::DisconnectWindow* remoting::DisconnectWindow::Create() {
- (IBAction)stopSharing:(id)sender {
if (self.host) {
- self.host->Shutdown(NULL);
+ self.host->Shutdown(base::Closure());
self.host = NULL;
}
}
diff --git a/remoting/host/disconnect_window_win.cc b/remoting/host/disconnect_window_win.cc
index 9f33d2b..a9f7742 100644
--- a/remoting/host/disconnect_window_win.cc
+++ b/remoting/host/disconnect_window_win.cc
@@ -204,7 +204,7 @@ void DisconnectWindowWin::Show(ChromotingHost* host,
void DisconnectWindowWin::ShutdownHost() {
CHECK(host_);
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
}
static int GetControlTextWidth(HWND control) {
diff --git a/remoting/host/host_key_pair.h b/remoting/host/host_key_pair.h
index 32a15d0..2ea00a0 100644
--- a/remoting/host/host_key_pair.h
+++ b/remoting/host/host_key_pair.h
@@ -43,6 +43,4 @@ class HostKeyPair {
} // namespace remoting
-DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostKeyPair);
-
#endif // REMOTING_HOST_HOST_KEY_PAIR_H_
diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h
index 7696dbd..5dbdd7b 100644
--- a/remoting/host/host_mock_objects.h
+++ b/remoting/host/host_mock_objects.h
@@ -30,7 +30,8 @@ class MockCapturer : public Capturer {
MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region));
MOCK_METHOD1(InvalidateScreen, void(const SkISize&));
MOCK_METHOD0(InvalidateFullScreen, void());
- MOCK_METHOD1(CaptureInvalidRegion, void(CaptureCompletedCallback* callback));
+ MOCK_METHOD1(CaptureInvalidRegion,
+ void(const CaptureCompletedCallback& callback));
MOCK_CONST_METHOD0(size_most_recent, const SkISize&());
private:
diff --git a/remoting/host/json_host_config.cc b/remoting/host/json_host_config.cc
index 2d2c884..66ac912 100644
--- a/remoting/host/json_host_config.cc
+++ b/remoting/host/json_host_config.cc
@@ -4,6 +4,7 @@
#include "remoting/host/json_host_config.h"
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
@@ -44,7 +45,7 @@ bool JsonHostConfig::Read() {
void JsonHostConfig::Save() {
message_loop_proxy_->PostTask(
- FROM_HERE, NewRunnableMethod(this, &JsonHostConfig::DoWrite));
+ FROM_HERE, base::Bind(&JsonHostConfig::DoWrite, this));
}
void JsonHostConfig::DoWrite() {
diff --git a/remoting/host/local_input_monitor_mac.mm b/remoting/host/local_input_monitor_mac.mm
index c6d9484..6b8f0e0 100644
--- a/remoting/host/local_input_monitor_mac.mm
+++ b/remoting/host/local_input_monitor_mac.mm
@@ -7,6 +7,7 @@
#import <AppKit/AppKit.h>
#include <set>
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
@@ -99,7 +100,7 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
- (void)hotKeyHit:(GTMCarbonHotKey*)hotKey {
base::AutoLock lock(hostsLock_);
for (Hosts::const_iterator i = hosts_.begin(); i != hosts_.end(); ++i) {
- (*i)->Shutdown(NULL);
+ (*i)->Shutdown(base::Closure());
}
}
diff --git a/remoting/host/local_input_monitor_thread_linux.cc b/remoting/host/local_input_monitor_thread_linux.cc
index 2f429d6..cae44f1 100644
--- a/remoting/host/local_input_monitor_thread_linux.cc
+++ b/remoting/host/local_input_monitor_thread_linux.cc
@@ -173,7 +173,7 @@ void LocalInputMonitorThread::LocalKeyPressed(int key_code, bool down) {
} else if (key_sym == XK_Alt_L || key_sym == XK_Alt_R) {
alt_pressed_ = down;
} else if (alt_pressed_ && ctrl_pressed_ && key_sym == XK_Escape && down) {
- host_->Shutdown(NULL);
+ host_->Shutdown(base::Closure());
}
}
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index 1838cf0..6fb0171 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -578,7 +578,8 @@ void HostNPScriptObject::DisconnectInternal() {
DCHECK(host_);
SetState(kDisconnecting);
host_->Shutdown(
- NewRunnableMethod(this, &HostNPScriptObject::OnShutdownFinished));
+ base::Bind(&HostNPScriptObject::OnShutdownFinished,
+ base::Unretained(this)));
}
}
diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc
index 9c23874..d779eca 100644
--- a/remoting/host/screen_recorder.cc
+++ b/remoting/host/screen_recorder.cc
@@ -60,7 +60,7 @@ ScreenRecorder::~ScreenRecorder() {
void ScreenRecorder::Start() {
capture_loop_->PostTask(
- FROM_HERE, NewRunnableMethod(this, &ScreenRecorder::DoStart));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoStart, this));
}
void ScreenRecorder::Stop(const base::Closure& done_task) {
@@ -82,35 +82,31 @@ void ScreenRecorder::Stop(const base::Closure& done_task) {
void ScreenRecorder::AddConnection(
scoped_refptr<ConnectionToClient> connection) {
capture_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoInvalidateFullScreen));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoInvalidateFullScreen, this));
// Add the client to the list so it can receive update stream.
network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoAddConnection, connection));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoAddConnection,
+ this, connection));
}
void ScreenRecorder::RemoveConnection(
scoped_refptr<ConnectionToClient> connection) {
network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoRemoveClient, connection));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoRemoveClient, this, connection));
}
void ScreenRecorder::RemoveAllConnections() {
network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoRemoveAllClients));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoRemoveAllClients, this));
}
void ScreenRecorder::UpdateSequenceNumber(int64 sequence_number) {
// Sequence number is used and written only on the capture thread.
if (MessageLoop::current() != capture_loop_) {
capture_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::UpdateSequenceNumber,
- sequence_number));
+ FROM_HERE, base::Bind(&ScreenRecorder::UpdateSequenceNumber,
+ this, sequence_number));
return;
}
@@ -183,7 +179,7 @@ void ScreenRecorder::DoCapture() {
// And finally perform one capture.
capture_start_time_ = base::Time::Now();
capturer()->CaptureInvalidRegion(
- NewCallback(this, &ScreenRecorder::CaptureDoneCallback));
+ base::Bind(&ScreenRecorder::CaptureDoneCallback, this));
}
void ScreenRecorder::CaptureDoneCallback(
@@ -209,8 +205,7 @@ void ScreenRecorder::CaptureDoneCallback(
}
encode_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoEncode, capture_data));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoEncode, this, capture_data));
}
void ScreenRecorder::DoFinishOneRecording() {
@@ -273,8 +268,7 @@ void ScreenRecorder::FrameSentCallback(VideoPacket* packet) {
return;
capture_loop_->PostTask(
- FROM_HERE, NewRunnableMethod(this,
- &ScreenRecorder::DoFinishOneRecording));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this));
}
void ScreenRecorder::DoAddConnection(
@@ -314,9 +308,8 @@ void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) {
network_stopped_ = true;
encode_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoStopOnEncodeThread,
- done_task));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoStopOnEncodeThread,
+ this, done_task));
}
// Encoder thread --------------------------------------------------------------
@@ -331,17 +324,15 @@ void ScreenRecorder::DoEncode(
VideoPacket* packet = new VideoPacket();
packet->set_flags(VideoPacket::LAST_PARTITION);
network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this,
- &ScreenRecorder::DoSendVideoPacket,
- packet));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket,
+ this, packet));
return;
}
encode_start_time_ = base::Time::Now();
encoder()->Encode(
capture_data, false,
- NewCallback(this, &ScreenRecorder::EncodedDataAvailableCallback));
+ base::Bind(&ScreenRecorder::EncodedDataAvailableCallback, this));
}
void ScreenRecorder::DoStopOnEncodeThread(const base::Closure& done_task) {
@@ -371,8 +362,7 @@ void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) {
}
network_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ScreenRecorder::DoSendVideoPacket, packet));
+ FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, packet));
}
} // namespace remoting
diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc
index 3a20283..51996dce 100644
--- a/remoting/host/screen_recorder_unittest.cc
+++ b/remoting/host/screen_recorder_unittest.cc
@@ -25,7 +25,6 @@ using ::testing::DeleteArg;
using ::testing::DoAll;
using ::testing::InSequence;
using ::testing::InvokeWithoutArgs;
-using ::testing::NotNull;
using ::testing::Return;
using ::testing::SaveArg;
@@ -36,15 +35,13 @@ namespace {
ACTION_P2(RunCallback, region, data) {
SkRegion& dirty_region = data->mutable_dirty_region();
dirty_region.op(region, SkRegion::kUnion_Op);
- arg0->Run(data);
- delete arg0;
+ arg0.Run(data);
}
ACTION(FinishEncode) {
scoped_ptr<VideoPacket> packet(new VideoPacket());
packet->set_flags(VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION);
- arg2->Run(packet.release());
- delete arg2;
+ arg2.Run(packet.release());
}
ACTION(FinishSend) {
@@ -119,11 +116,11 @@ TEST_F(ScreenRecorderTest, StartAndStop) {
EXPECT_CALL(capturer_, InvalidateFullScreen());
// First the capturer is called.
- EXPECT_CALL(capturer_, CaptureInvalidRegion(NotNull()))
+ EXPECT_CALL(capturer_, CaptureInvalidRegion(_))
.WillRepeatedly(RunCallback(update_region, data));
// Expect the encoder be called.
- EXPECT_CALL(*encoder_, Encode(data, false, NotNull()))
+ EXPECT_CALL(*encoder_, Encode(data, false, _))
.WillRepeatedly(FinishEncode());
MockVideoStub video_stub;