Commit 0dd89890 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Unqualify uses of folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams

Summary: Unqualify nearly all uses of `folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams` since nearly all uses already have `OnDataAvailableParams` in scope.

Differential Revision: D20450063

fbshipit-source-id: c0fd49a7eace44a6edc8086762c44753224788dd
parent 13655b8a
......@@ -40,6 +40,8 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
public:
class Callback {
public:
using OnDataAvailableParams =
AsyncUDPSocket::ReadCallback::OnDataAvailableParams;
/**
* Invoked when we start reading data from socket. It is invoked in
* each acceptors/listeners event base thread.
......@@ -72,7 +74,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
const folly::SocketAddress& addr,
std::unique_ptr<folly::IOBuf> buf,
bool truncated,
AsyncUDPSocket::ReadCallback::OnDataAvailableParams) noexcept = 0;
OnDataAvailableParams) noexcept = 0;
virtual ~Callback() = default;
};
......@@ -216,8 +218,7 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback,
const folly::SocketAddress& clientAddress,
size_t len,
bool truncated,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams
params) noexcept override {
OnDataAvailableParams params) noexcept override {
buf_.postallocate(len);
auto data = buf_.split(len);
......
......@@ -165,8 +165,7 @@ class UDPAcceptor : public AsyncUDPServerSocket::Callback {
const folly::SocketAddress& client,
std::unique_ptr<folly::IOBuf> data,
bool /*unused*/,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams
params) noexcept override {
OnDataAvailableParams params) noexcept override {
// send pong(s)
if (params.gro_ == -1) {
socket->write(client, data->clone());
......@@ -349,8 +348,7 @@ class UDPClient : private AsyncUDPSocket::ReadCallback, private AsyncTimeout {
const folly::SocketAddress& /*unused*/,
size_t len,
bool /*unused*/,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams
params) noexcept override {
OnDataAvailableParams params) noexcept override {
// no GRO on the client side
CHECK_EQ(params.gro_, -1);
VLOG(0) << "Got " << len << " bytes";
......
......@@ -103,7 +103,6 @@ class UDPAcceptor : public AsyncUDPServerSocket::Callback {
const folly::SocketAddress& client,
std::unique_ptr<folly::IOBuf> data,
bool /*unused*/,
folly::AsyncUDPSocket::ReadCallback::
OnDataAvailableParams /*unused*/) noexcept override {
// send pong
socket->write(client, data->clone());
......@@ -248,7 +247,6 @@ class UDPClient : private AsyncUDPSocket::ReadCallback, private AsyncTimeout {
const folly::SocketAddress& /*unused*/,
size_t len,
bool /*unused*/,
folly::AsyncUDPSocket::ReadCallback::
OnDataAvailableParams /*unused*/) noexcept override {
VLOG(0) << "Got " << len << " bytes";
if (testData_.appendOut(buf_, len)) {
......
......@@ -37,6 +37,9 @@ using folly::EventBase;
using folly::SocketAddress;
using namespace testing;
using OnDataAvailableParams =
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams;
class UDPAcceptor : public AsyncUDPServerSocket::Callback {
public:
UDPAcceptor(EventBase* evb, int n, bool changePortForWrites)
......@@ -51,7 +54,6 @@ class UDPAcceptor : public AsyncUDPServerSocket::Callback {
const folly::SocketAddress& client,
std::unique_ptr<folly::IOBuf> data,
bool truncated,
folly::AsyncUDPSocket::ReadCallback::
OnDataAvailableParams) noexcept override {
lastClient_ = client;
lastMsg_ = data->clone()->moveToFbString().toStdString();
......@@ -173,6 +175,8 @@ class UDPServer {
class UDPClient : private AsyncUDPSocket::ReadCallback, private AsyncTimeout {
public:
using AsyncUDPSocket::ReadCallback::OnDataAvailableParams;
~UDPClient() override = default;
explicit UDPClient(EventBase* evb) : AsyncTimeout(evb), evb_(evb) {}
......@@ -257,7 +261,6 @@ class UDPClient : private AsyncUDPSocket::ReadCallback, private AsyncTimeout {
const folly::SocketAddress& client,
size_t len,
bool truncated,
folly::AsyncUDPSocket::ReadCallback::
OnDataAvailableParams) noexcept override {
VLOG(4) << "Read " << len << " bytes (trun:" << truncated << ") from "
<< client.describe() << " - " << std::string(buf_, len);
......@@ -366,11 +369,7 @@ class UDPNotifyClient : public UDPClient {
SocketAddress addr;
addr.setFromSockaddr(rawAddr, addrLen);
onDataAvailable(
addr,
size_t(read),
false,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams());
onDataAvailable(addr, size_t(read), false, OnDataAvailableParams());
}
void onRecvMmsg(AsyncUDPSocket& sock) {
......@@ -669,17 +668,12 @@ class MockUDPReadCallback : public AsyncUDPSocket::ReadCallback {
MOCK_METHOD4(
onDataAvailable_,
void(
const folly::SocketAddress&,
size_t,
bool,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams));
void(const folly::SocketAddress&, size_t, bool, OnDataAvailableParams));
void onDataAvailable(
const folly::SocketAddress& client,
size_t len,
bool truncated,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams
params) noexcept override {
OnDataAvailableParams params) noexcept override {
onDataAvailable_(client, len, truncated, params);
}
......@@ -836,13 +830,10 @@ TEST_F(AsyncUDPSocketTest, TestDetachAttach) {
*len = 1024;
}));
EXPECT_CALL(readCb, onDataAvailable_(_, _, _, _))
.WillRepeatedly(Invoke(
[&](const folly::SocketAddress&,
.WillRepeatedly(Invoke([&](const folly::SocketAddress&,
size_t,
bool,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams) {
packetsRecvd++;
}));
OnDataAvailableParams) { packetsRecvd++; }));
socket_->resumeRead(&readCb);
writeSocket->write(socket_->address(), folly::IOBuf::copyBuffer("hello"));
while (packetsRecvd != 1) {
......
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