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

Unified Diff: remoting/protocol/pseudotcp_adapter_unittest.cc

Issue 2082363002: Remove calls to deprecated MessageLoop methods in remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing include Created 4 years, 6 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/protocol/pseudotcp_adapter_unittest.cc
diff --git a/remoting/protocol/pseudotcp_adapter_unittest.cc b/remoting/protocol/pseudotcp_adapter_unittest.cc
index 1900214a070197957c6dfbcf39cfd20612525e44..0059204294a99485dadf5c95bf44f7fa5e2d3cef 100644
--- a/remoting/protocol/pseudotcp_adapter_unittest.cc
+++ b/remoting/protocol/pseudotcp_adapter_unittest.cc
@@ -4,6 +4,7 @@
#include "remoting/protocol/pseudotcp_adapter.h"
+#include <utility>
#include <vector>
#include "base/bind.h"
@@ -11,7 +12,7 @@
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
-#include "base/single_thread_task_runner.h"
+#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "jingle/glue/thread_wrapper.h"
#include "net/base/io_buffer.h"
@@ -155,10 +156,10 @@ class FakeSocket : public P2PDatagramSocket {
class TCPChannelTester : public base::RefCountedThreadSafe<TCPChannelTester> {
public:
- TCPChannelTester(base::MessageLoop* message_loop,
+ TCPChannelTester(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
P2PStreamSocket* client_socket,
P2PStreamSocket* host_socket)
- : message_loop_(message_loop),
+ : task_runner_(std::move(task_runner)),
host_socket_(host_socket),
client_socket_(client_socket),
done_(false),
@@ -166,8 +167,8 @@ class TCPChannelTester : public base::RefCountedThreadSafe<TCPChannelTester> {
read_errors_(0) {}
void Start() {
- message_loop_->PostTask(
- FROM_HERE, base::Bind(&TCPChannelTester::DoStart, this));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&TCPChannelTester::DoStart, this));
}
void CheckResults() {
@@ -188,8 +189,7 @@ class TCPChannelTester : public base::RefCountedThreadSafe<TCPChannelTester> {
void Done() {
done_ = true;
- message_loop_->PostTask(FROM_HERE,
- base::MessageLoop::QuitWhenIdleClosure());
+ task_runner_->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
}
void DoStart() {
@@ -275,7 +275,7 @@ class TCPChannelTester : public base::RefCountedThreadSafe<TCPChannelTester> {
private:
friend class base::RefCountedThreadSafe<TCPChannelTester>;
- base::MessageLoop* message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
P2PStreamSocket* host_socket_;
P2PStreamSocket* client_socket_;
bool done_;
@@ -326,11 +326,11 @@ TEST_F(PseudoTcpAdapterTest, DataTransfer) {
ASSERT_EQ(net::OK, rv2);
scoped_refptr<TCPChannelTester> tester =
- new TCPChannelTester(&message_loop_, host_pseudotcp_.get(),
- client_pseudotcp_.get());
+ new TCPChannelTester(base::ThreadTaskRunnerHandle::Get(),
+ host_pseudotcp_.get(), client_pseudotcp_.get());
tester->Start();
- message_loop_.Run();
+ base::RunLoop().Run();
tester->CheckResults();
}
@@ -361,25 +361,24 @@ TEST_F(PseudoTcpAdapterTest, LimitedChannel) {
ASSERT_EQ(net::OK, rv2);
scoped_refptr<TCPChannelTester> tester =
- new TCPChannelTester(&message_loop_, host_pseudotcp_.get(),
- client_pseudotcp_.get());
+ new TCPChannelTester(base::ThreadTaskRunnerHandle::Get(),
+ host_pseudotcp_.get(), client_pseudotcp_.get());
tester->Start();
- message_loop_.Run();
+ base::RunLoop().Run();
tester->CheckResults();
}
class DeleteOnConnected {
public:
- DeleteOnConnected(base::MessageLoop* message_loop,
+ DeleteOnConnected(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
std::unique_ptr<PseudoTcpAdapter>* adapter)
- : message_loop_(message_loop), adapter_(adapter) {}
+ : task_runner_(std::move(task_runner)), adapter_(adapter) {}
void OnConnected(int error) {
adapter_->reset();
- message_loop_->PostTask(FROM_HERE,
- base::MessageLoop::QuitWhenIdleClosure());
+ task_runner_->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
}
- base::MessageLoop* message_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
std::unique_ptr<PseudoTcpAdapter>* adapter_;
};
@@ -388,12 +387,13 @@ TEST_F(PseudoTcpAdapterTest, DeleteOnConnected) {
// to deleted structures being touched as the stack unrolls, so the failure
// mode is a crash rather than a normal test failure.
net::TestCompletionCallback client_connect_cb;
- DeleteOnConnected host_delete(&message_loop_, &host_pseudotcp_);
+ DeleteOnConnected host_delete(base::ThreadTaskRunnerHandle::Get(),
+ &host_pseudotcp_);
host_pseudotcp_->Connect(base::Bind(&DeleteOnConnected::OnConnected,
base::Unretained(&host_delete)));
client_pseudotcp_->Connect(client_connect_cb.callback());
- message_loop_.Run();
+ base::RunLoop().Run();
ASSERT_EQ(NULL, host_pseudotcp_.get());
}
@@ -422,11 +422,11 @@ TEST_F(PseudoTcpAdapterTest, WriteWaitsForSendLetsDataThrough) {
ASSERT_EQ(net::OK, rv2);
scoped_refptr<TCPChannelTester> tester =
- new TCPChannelTester(&message_loop_, host_pseudotcp_.get(),
- client_pseudotcp_.get());
+ new TCPChannelTester(base::ThreadTaskRunnerHandle::Get(),
+ host_pseudotcp_.get(), client_pseudotcp_.get());
tester->Start();
- message_loop_.Run();
+ base::RunLoop().Run();
tester->CheckResults();
}
« no previous file with comments | « remoting/protocol/chromium_socket_factory_unittest.cc ('k') | remoting/protocol/spake2_authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698