Commit 5075d042 authored by Leonard Grey's avatar Leonard Grey Committed by Chromium LUCI CQ

[Code health] Convert callbacks in MockAdbServer to repeating

Bug: 1152274
Change-Id: I4de8bb8ea36b9152c79460ef044814277f793980
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587454Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836675}
parent 640793ee
...@@ -212,8 +212,8 @@ class SimpleHttpServer { ...@@ -212,8 +212,8 @@ class SimpleHttpServer {
virtual ~Parser() {} virtual ~Parser() {}
}; };
using SendCallback = base::Callback<void(const std::string&)>; using SendCallback = base::RepeatingCallback<void(const std::string&)>;
using ParserFactory = base::Callback<Parser*(const SendCallback&)>; using ParserFactory = base::RepeatingCallback<Parser*(const SendCallback&)>;
SimpleHttpServer(const ParserFactory& factory, net::IPEndPoint endpoint); SimpleHttpServer(const ParserFactory& factory, net::IPEndPoint endpoint);
virtual ~SimpleHttpServer(); virtual ~SimpleHttpServer();
...@@ -274,8 +274,8 @@ SimpleHttpServer::~SimpleHttpServer() { ...@@ -274,8 +274,8 @@ SimpleHttpServer::~SimpleHttpServer() {
SimpleHttpServer::Connection::Connection(net::StreamSocket* socket, SimpleHttpServer::Connection::Connection(net::StreamSocket* socket,
const ParserFactory& factory) const ParserFactory& factory)
: socket_(socket), : socket_(socket),
parser_( parser_(factory.Run(
factory.Run(base::Bind(&Connection::Send, base::Unretained(this)))), base::BindRepeating(&Connection::Send, base::Unretained(this)))),
input_buffer_(base::MakeRefCounted<net::GrowableIOBuffer>()), input_buffer_(base::MakeRefCounted<net::GrowableIOBuffer>()),
output_buffer_(base::MakeRefCounted<net::GrowableIOBuffer>()), output_buffer_(base::MakeRefCounted<net::GrowableIOBuffer>()),
bytes_to_write_(0), bytes_to_write_(0),
...@@ -510,21 +510,21 @@ class AdbParser : public SimpleHttpServer::Parser, ...@@ -510,21 +510,21 @@ class AdbParser : public SimpleHttpServer::Parser,
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
}; };
static SimpleHttpServer* mock_adb_server_ = NULL; static SimpleHttpServer* mock_adb_server_ = nullptr;
void StartMockAdbServerOnIOThread(FlushMode flush_mode) { void StartMockAdbServerOnIOThread(FlushMode flush_mode) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
CHECK(mock_adb_server_ == NULL); CHECK(mock_adb_server_ == nullptr);
net::IPEndPoint endpoint(net::IPAddress(127, 0, 0, 1), kAdbPort); net::IPEndPoint endpoint(net::IPAddress(127, 0, 0, 1), kAdbPort);
mock_adb_server_ = new SimpleHttpServer( mock_adb_server_ = new SimpleHttpServer(
base::Bind(&AdbParser::Create, flush_mode), endpoint); base::BindRepeating(&AdbParser::Create, flush_mode), endpoint);
} }
void StopMockAdbServerOnIOThread() { void StopMockAdbServerOnIOThread() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
CHECK(mock_adb_server_ != NULL); CHECK(mock_adb_server_ != nullptr);
delete mock_adb_server_; delete mock_adb_server_;
mock_adb_server_ = NULL; mock_adb_server_ = nullptr;
} }
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment