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