Commit 3ad84b57 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Update some unit test fixtures to use OnceClosure.

This finishes conversion of base::Bind and friends in net/reporting,
net/server, and net/websockets.

Bug: 1007815
Change-Id: I8c8e060198cc9058c865b36e7f8529e49c1f65a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2288106Reviewed-by: default avatarDavid Benjamin <davidben@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786566}
parent ef6988fd
...@@ -119,7 +119,7 @@ class TestUploadCallback { ...@@ -119,7 +119,7 @@ class TestUploadCallback {
if (waiting_) { if (waiting_) {
waiting_ = false; waiting_ = false;
closure_.Run(); std::move(closure_).Run();
} }
} }
...@@ -127,7 +127,7 @@ class TestUploadCallback { ...@@ -127,7 +127,7 @@ class TestUploadCallback {
ReportingUploader::Outcome outcome_; ReportingUploader::Outcome outcome_;
bool waiting_; bool waiting_;
base::Closure closure_; base::OnceClosure closure_;
}; };
TEST_F(ReportingUploaderTest, Upload) { TEST_F(ReportingUploaderTest, Upload) {
......
...@@ -199,7 +199,7 @@ class HttpServerTest : public TestWithTaskEnvironment, ...@@ -199,7 +199,7 @@ class HttpServerTest : public TestWithTaskEnvironment,
const HttpServerRequestInfo& info) override { const HttpServerRequestInfo& info) override {
requests_.push_back(std::make_pair(info, connection_id)); requests_.push_back(std::make_pair(info, connection_id));
if (requests_.size() == quit_after_request_count_) if (requests_.size() == quit_after_request_count_)
run_loop_quit_func_.Run(); std::move(run_loop_quit_func_).Run();
} }
void OnWebSocketRequest(int connection_id, void OnWebSocketRequest(int connection_id,
...@@ -215,7 +215,7 @@ class HttpServerTest : public TestWithTaskEnvironment, ...@@ -215,7 +215,7 @@ class HttpServerTest : public TestWithTaskEnvironment,
DCHECK(connection_map_.find(connection_id) != connection_map_.end()); DCHECK(connection_map_.find(connection_id) != connection_map_.end());
connection_map_[connection_id] = false; connection_map_[connection_id] = false;
if (connection_id == quit_on_close_connection_) if (connection_id == quit_on_close_connection_)
run_loop_quit_func_.Run(); std::move(run_loop_quit_func_).Run();
} }
void RunUntilRequestsReceived(size_t count) { void RunUntilRequestsReceived(size_t count) {
...@@ -224,7 +224,7 @@ class HttpServerTest : public TestWithTaskEnvironment, ...@@ -224,7 +224,7 @@ class HttpServerTest : public TestWithTaskEnvironment,
return; return;
base::RunLoop run_loop; base::RunLoop run_loop;
base::AutoReset<base::RepeatingClosure> run_loop_quit_func( base::AutoReset<base::OnceClosure> run_loop_quit_func(
&run_loop_quit_func_, run_loop.QuitClosure()); &run_loop_quit_func_, run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
...@@ -250,7 +250,7 @@ class HttpServerTest : public TestWithTaskEnvironment, ...@@ -250,7 +250,7 @@ class HttpServerTest : public TestWithTaskEnvironment,
} }
base::RunLoop run_loop; base::RunLoop run_loop;
base::AutoReset<base::RepeatingClosure> run_loop_quit_func( base::AutoReset<base::OnceClosure> run_loop_quit_func(
&run_loop_quit_func_, run_loop.QuitClosure()); &run_loop_quit_func_, run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
...@@ -283,7 +283,7 @@ class HttpServerTest : public TestWithTaskEnvironment, ...@@ -283,7 +283,7 @@ class HttpServerTest : public TestWithTaskEnvironment,
protected: protected:
std::unique_ptr<HttpServer> server_; std::unique_ptr<HttpServer> server_;
IPEndPoint server_address_; IPEndPoint server_address_;
base::Closure run_loop_quit_func_; base::OnceClosure run_loop_quit_func_;
std::vector<std::pair<HttpServerRequestInfo, int> > requests_; std::vector<std::pair<HttpServerRequestInfo, int> > requests_;
std::unordered_map<int /* connection_id */, bool /* connected */> std::unordered_map<int /* connection_id */, bool /* connected */>
connection_map_; connection_map_;
......
...@@ -27,8 +27,8 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate ...@@ -27,8 +27,8 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate
: public WebSocketStream::ConnectDelegate { : public WebSocketStream::ConnectDelegate {
public: public:
TestConnectDelegate(WebSocketStreamCreateTestBase* owner, TestConnectDelegate(WebSocketStreamCreateTestBase* owner,
const base::Closure& done_callback) base::OnceClosure done_callback)
: owner_(owner), done_callback_(done_callback) {} : owner_(owner), done_callback_(std::move(done_callback)) {}
void OnCreateRequest(URLRequest* request) override { void OnCreateRequest(URLRequest* request) override {
owner_->url_request_ = request; owner_->url_request_ = request;
...@@ -41,13 +41,13 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate ...@@ -41,13 +41,13 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate
ADD_FAILURE(); ADD_FAILURE();
owner_->response_info_ = std::move(response); owner_->response_info_ = std::move(response);
stream.swap(owner_->stream_); stream.swap(owner_->stream_);
done_callback_.Run(); std::move(done_callback_).Run();
} }
void OnFailure(const std::string& message) override { void OnFailure(const std::string& message) override {
owner_->has_failed_ = true; owner_->has_failed_ = true;
owner_->failure_message_ = message; owner_->failure_message_ = message;
done_callback_.Run(); std::move(done_callback_).Run();
} }
void OnStartOpeningHandshake( void OnStartOpeningHandshake(
...@@ -82,7 +82,7 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate ...@@ -82,7 +82,7 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate
private: private:
WebSocketStreamCreateTestBase* owner_; WebSocketStreamCreateTestBase* owner_;
base::Closure done_callback_; base::OnceClosure done_callback_;
DISALLOW_COPY_AND_ASSIGN(TestConnectDelegate); DISALLOW_COPY_AND_ASSIGN(TestConnectDelegate);
}; };
......
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