Commit 2586be5b authored by Mingtao Yang's avatar Mingtao Yang Committed by Facebook GitHub Bot

Deprecate AsyncTransportWrapper

Summary:
All implementations of transports in practice were all AsyncTransportWrappers
(AsyncSocket, AsyncSSLSocket, AsyncFizzBase, etc.).

AsyncTransportWrapper was confusing. The only additional functionality that
it provided was the ability to query underlying transports, a piece of
functionality which makes just as much sense on AsyncTransport.

The simplified model:

"AsyncTransport deals with bidirectional I/O. It is both an AsyncReader, and
an AsyncWriter. It may be nested."

This diff changes AsyncTransportWrapper usages in folly to refer to
AsyncTransport, and aliases AsyncTransportWrapper for compatibility.

Reviewed By: yfeldblum

Differential Revision: D21915048

fbshipit-source-id: 741fad91b8f7c8080f942168f5513b12602cfe9a
parent 0e32d9f4
...@@ -368,7 +368,7 @@ bool AsyncSSLSocket::good() const { ...@@ -368,7 +368,7 @@ bool AsyncSSLSocket::good() const {
sslState_ == STATE_UNINIT)); sslState_ == STATE_UNINIT));
} }
// The AsyncTransportWrapper definition of 'good' states that the transport is // The AsyncTransport definition of 'good' states that the transport is
// ready to perform reads and writes, so sslState_ == UNINIT must report !good. // ready to perform reads and writes, so sslState_ == UNINIT must report !good.
// connecting can be true when the sslState_ == UNINIT because the AsyncSocket // connecting can be true when the sslState_ == UNINIT because the AsyncSocket
// is connected but we haven't initiated the call to SSL_connect. // is connected but we haven't initiated the call to SSL_connect.
......
...@@ -320,7 +320,7 @@ class AsyncSSLSocket : public virtual AsyncSocket { ...@@ -320,7 +320,7 @@ class AsyncSSLSocket : public virtual AsyncSocket {
* the flag should be reset. * the flag should be reset.
*/ */
// Inherit AsyncTransportWrapper methods from AsyncSocket except the // Inherit AsyncTransport methods from AsyncSocket except the
// following. // following.
// See the documentation in AsyncTransport.h // See the documentation in AsyncTransport.h
// TODO: implement graceful shutdown in close() // TODO: implement graceful shutdown in close()
......
...@@ -73,7 +73,7 @@ namespace folly { ...@@ -73,7 +73,7 @@ namespace folly {
#define SO_NO_TSOCKS 201 #define SO_NO_TSOCKS 201
#endif #endif
class AsyncSocket : public AsyncTransportWrapper { class AsyncSocket : public AsyncTransport {
public: public:
using UniquePtr = std::unique_ptr<AsyncSocket, Destructor>; using UniquePtr = std::unique_ptr<AsyncSocket, Destructor>;
......
This diff is collapsed.
...@@ -21,31 +21,30 @@ ...@@ -21,31 +21,30 @@
namespace folly { namespace folly {
/** /**
* Convenience class so that AsyncTransportWrapper can be decorated without * Convenience class so that AsyncTransport can be decorated without
* having to redefine every single method. * having to redefine every single method.
*/ */
template <class T> template <class T>
class DecoratedAsyncTransportWrapper : public folly::AsyncTransportWrapper { class DecoratedAsyncTransportWrapper : public folly::AsyncTransport {
public: public:
explicit DecoratedAsyncTransportWrapper(typename T::UniquePtr transport) explicit DecoratedAsyncTransportWrapper(typename T::UniquePtr transport)
: transport_(std::move(transport)) {} : transport_(std::move(transport)) {}
const AsyncTransportWrapper* getWrappedTransport() const override { const AsyncTransport* getWrappedTransport() const override {
return transport_.get(); return transport_.get();
} }
// folly::AsyncTransportWrapper // folly::AsyncTransport
ReadCallback* getReadCallback() const override { ReadCallback* getReadCallback() const override {
return transport_->getReadCallback(); return transport_->getReadCallback();
} }
void setReadCB( void setReadCB(folly::AsyncTransport::ReadCallback* callback) override {
folly::AsyncTransportWrapper::ReadCallback* callback) override {
transport_->setReadCB(callback); transport_->setReadCB(callback);
} }
void write( void write(
folly::AsyncTransportWrapper::WriteCallback* callback, folly::AsyncTransport::WriteCallback* callback,
const void* buf, const void* buf,
size_t bytes, size_t bytes,
folly::WriteFlags flags = folly::WriteFlags::NONE) override { folly::WriteFlags flags = folly::WriteFlags::NONE) override {
...@@ -53,14 +52,14 @@ class DecoratedAsyncTransportWrapper : public folly::AsyncTransportWrapper { ...@@ -53,14 +52,14 @@ class DecoratedAsyncTransportWrapper : public folly::AsyncTransportWrapper {
} }
void writeChain( void writeChain(
folly::AsyncTransportWrapper::WriteCallback* callback, folly::AsyncTransport::WriteCallback* callback,
std::unique_ptr<folly::IOBuf>&& buf, std::unique_ptr<folly::IOBuf>&& buf,
folly::WriteFlags flags = folly::WriteFlags::NONE) override { folly::WriteFlags flags = folly::WriteFlags::NONE) override {
transport_->writeChain(callback, std::move(buf), flags); transport_->writeChain(callback, std::move(buf), flags);
} }
void writev( void writev(
folly::AsyncTransportWrapper::WriteCallback* callback, folly::AsyncTransport::WriteCallback* callback,
const iovec* vec, const iovec* vec,
size_t bytes, size_t bytes,
folly::WriteFlags flags = folly::WriteFlags::NONE) override { folly::WriteFlags flags = folly::WriteFlags::NONE) override {
......
...@@ -32,7 +32,7 @@ class WriteChainAsyncTransportWrapper ...@@ -32,7 +32,7 @@ class WriteChainAsyncTransportWrapper
using DecoratedAsyncTransportWrapper<T>::DecoratedAsyncTransportWrapper; using DecoratedAsyncTransportWrapper<T>::DecoratedAsyncTransportWrapper;
void write( void write(
folly::AsyncTransportWrapper::WriteCallback* callback, AsyncTransport::WriteCallback* callback,
const void* buf, const void* buf,
size_t bytes, size_t bytes,
folly::WriteFlags flags = folly::WriteFlags::NONE) override { folly::WriteFlags flags = folly::WriteFlags::NONE) override {
...@@ -41,7 +41,7 @@ class WriteChainAsyncTransportWrapper ...@@ -41,7 +41,7 @@ class WriteChainAsyncTransportWrapper
} }
void writev( void writev(
folly::AsyncTransportWrapper::WriteCallback* callback, AsyncTransport::WriteCallback* callback,
const iovec* vec, const iovec* vec,
size_t count, size_t count,
folly::WriteFlags flags = folly::WriteFlags::NONE) override { folly::WriteFlags flags = folly::WriteFlags::NONE) override {
...@@ -54,7 +54,7 @@ class WriteChainAsyncTransportWrapper ...@@ -54,7 +54,7 @@ class WriteChainAsyncTransportWrapper
* derived classes to do that. * derived classes to do that.
*/ */
void writeChain( void writeChain(
folly::AsyncTransportWrapper::WriteCallback* callback, AsyncTransport::WriteCallback* callback,
std::unique_ptr<folly::IOBuf>&& buf, std::unique_ptr<folly::IOBuf>&& buf,
folly::WriteFlags flags = folly::WriteFlags::NONE) override = 0; folly::WriteFlags flags = folly::WriteFlags::NONE) override = 0;
}; };
......
...@@ -805,7 +805,7 @@ TEST(AsyncSSLSocketTest, SSLClientTimeoutTest) { ...@@ -805,7 +805,7 @@ TEST(AsyncSSLSocketTest, SSLClientTimeoutTest) {
cerr << "SSLClientTimeoutTest test completed" << endl; cerr << "SSLClientTimeoutTest test completed" << endl;
} }
class PerLoopReadCallback : public AsyncTransportWrapper::ReadCallback { class PerLoopReadCallback : public AsyncTransport::ReadCallback {
public: public:
void getReadBuffer(void** bufReturn, size_t* lenReturn) override { void getReadBuffer(void** bufReturn, size_t* lenReturn) override {
*bufReturn = buf_.data(); *bufReturn = buf_.data();
......
...@@ -151,7 +151,7 @@ class SendMsgAncillaryDataCallback : public SendMsgParamsCallbackBase { ...@@ -151,7 +151,7 @@ class SendMsgAncillaryDataCallback : public SendMsgParamsCallbackBase {
std::vector<char> ancillaryData_; std::vector<char> ancillaryData_;
}; };
class WriteCallbackBase : public AsyncTransportWrapper::WriteCallback { class WriteCallbackBase : public AsyncTransport::WriteCallback {
public: public:
explicit WriteCallbackBase(SendMsgParamsCallbackBase* mcb = nullptr) explicit WriteCallbackBase(SendMsgParamsCallbackBase* mcb = nullptr)
: state(STATE_WAITING), : state(STATE_WAITING),
...@@ -320,7 +320,7 @@ class WriteCheckTimestampCallback : public WriteCallbackBase { ...@@ -320,7 +320,7 @@ class WriteCheckTimestampCallback : public WriteCallbackBase {
}; };
#endif // FOLLY_HAVE_MSG_ERRQUEUE #endif // FOLLY_HAVE_MSG_ERRQUEUE
class ReadCallbackBase : public AsyncTransportWrapper::ReadCallback { class ReadCallbackBase : public AsyncTransport::ReadCallback {
public: public:
explicit ReadCallbackBase(WriteCallbackBase* wcb) explicit ReadCallbackBase(WriteCallbackBase* wcb)
: wcb_(wcb), state(STATE_WAITING) {} : wcb_(wcb), state(STATE_WAITING) {}
...@@ -771,7 +771,7 @@ void sslsocketpair( ...@@ -771,7 +771,7 @@ void sslsocketpair(
AsyncSSLSocket::UniquePtr* serverSock); AsyncSSLSocket::UniquePtr* serverSock);
class BlockingWriteClient : private AsyncSSLSocket::HandshakeCB, class BlockingWriteClient : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::WriteCallback { private AsyncTransport::WriteCallback {
public: public:
explicit BlockingWriteClient(AsyncSSLSocket::UniquePtr socket) explicit BlockingWriteClient(AsyncSSLSocket::UniquePtr socket)
: socket_(std::move(socket)), bufLen_(2500), iovCount_(2000) { : socket_(std::move(socket)), bufLen_(2500), iovCount_(2000) {
...@@ -829,7 +829,7 @@ class BlockingWriteClient : private AsyncSSLSocket::HandshakeCB, ...@@ -829,7 +829,7 @@ class BlockingWriteClient : private AsyncSSLSocket::HandshakeCB,
}; };
class BlockingWriteServer : private AsyncSSLSocket::HandshakeCB, class BlockingWriteServer : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::ReadCallback { private AsyncTransport::ReadCallback {
public: public:
explicit BlockingWriteServer(AsyncSSLSocket::UniquePtr socket) explicit BlockingWriteServer(AsyncSSLSocket::UniquePtr socket)
: socket_(std::move(socket)), bufSize_(2500 * 2000), bytesRead_(0) { : socket_(std::move(socket)), bufSize_(2500 * 2000), bytesRead_(0) {
...@@ -898,7 +898,7 @@ class BlockingWriteServer : private AsyncSSLSocket::HandshakeCB, ...@@ -898,7 +898,7 @@ class BlockingWriteServer : private AsyncSSLSocket::HandshakeCB,
}; };
class AlpnClient : private AsyncSSLSocket::HandshakeCB, class AlpnClient : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::WriteCallback { private AsyncTransport::WriteCallback {
public: public:
explicit AlpnClient(AsyncSSLSocket::UniquePtr socket) explicit AlpnClient(AsyncSSLSocket::UniquePtr socket)
: nextProto(nullptr), nextProtoLength(0), socket_(std::move(socket)) { : nextProto(nullptr), nextProtoLength(0), socket_(std::move(socket)) {
...@@ -932,7 +932,7 @@ class AlpnClient : private AsyncSSLSocket::HandshakeCB, ...@@ -932,7 +932,7 @@ class AlpnClient : private AsyncSSLSocket::HandshakeCB,
}; };
class AlpnServer : private AsyncSSLSocket::HandshakeCB, class AlpnServer : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::ReadCallback { private AsyncTransport::ReadCallback {
public: public:
explicit AlpnServer(AsyncSSLSocket::UniquePtr socket) explicit AlpnServer(AsyncSSLSocket::UniquePtr socket)
: nextProto(nullptr), nextProtoLength(0), socket_(std::move(socket)) { : nextProto(nullptr), nextProtoLength(0), socket_(std::move(socket)) {
...@@ -967,7 +967,7 @@ class AlpnServer : private AsyncSSLSocket::HandshakeCB, ...@@ -967,7 +967,7 @@ class AlpnServer : private AsyncSSLSocket::HandshakeCB,
}; };
class RenegotiatingServer : public AsyncSSLSocket::HandshakeCB, class RenegotiatingServer : public AsyncSSLSocket::HandshakeCB,
public AsyncTransportWrapper::ReadCallback { public AsyncTransport::ReadCallback {
public: public:
explicit RenegotiatingServer(AsyncSSLSocket::UniquePtr socket) explicit RenegotiatingServer(AsyncSSLSocket::UniquePtr socket)
: socket_(std::move(socket)) { : socket_(std::move(socket)) {
...@@ -1010,7 +1010,7 @@ class RenegotiatingServer : public AsyncSSLSocket::HandshakeCB, ...@@ -1010,7 +1010,7 @@ class RenegotiatingServer : public AsyncSSLSocket::HandshakeCB,
#ifndef OPENSSL_NO_TLSEXT #ifndef OPENSSL_NO_TLSEXT
class SNIClient : private AsyncSSLSocket::HandshakeCB, class SNIClient : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::WriteCallback { private AsyncTransport::WriteCallback {
public: public:
explicit SNIClient(AsyncSSLSocket::UniquePtr socket) explicit SNIClient(AsyncSSLSocket::UniquePtr socket)
: serverNameMatch(false), socket_(std::move(socket)) { : serverNameMatch(false), socket_(std::move(socket)) {
...@@ -1042,7 +1042,7 @@ class SNIClient : private AsyncSSLSocket::HandshakeCB, ...@@ -1042,7 +1042,7 @@ class SNIClient : private AsyncSSLSocket::HandshakeCB,
}; };
class SNIServer : private AsyncSSLSocket::HandshakeCB, class SNIServer : private AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::ReadCallback { private AsyncTransport::ReadCallback {
public: public:
explicit SNIServer( explicit SNIServer(
AsyncSSLSocket::UniquePtr socket, AsyncSSLSocket::UniquePtr socket,
...@@ -1098,8 +1098,8 @@ class SNIServer : private AsyncSSLSocket::HandshakeCB, ...@@ -1098,8 +1098,8 @@ class SNIServer : private AsyncSSLSocket::HandshakeCB,
#endif #endif
class SSLClient : public AsyncSocket::ConnectCallback, class SSLClient : public AsyncSocket::ConnectCallback,
public AsyncTransportWrapper::WriteCallback, public AsyncTransport::WriteCallback,
public AsyncTransportWrapper::ReadCallback { public AsyncTransport::ReadCallback {
private: private:
EventBase* eventBase_; EventBase* eventBase_;
std::shared_ptr<AsyncSSLSocket> sslSocket_; std::shared_ptr<AsyncSSLSocket> sslSocket_;
...@@ -1251,7 +1251,7 @@ class SSLClient : public AsyncSocket::ConnectCallback, ...@@ -1251,7 +1251,7 @@ class SSLClient : public AsyncSocket::ConnectCallback,
}; };
class SSLHandshakeBase : public AsyncSSLSocket::HandshakeCB, class SSLHandshakeBase : public AsyncSSLSocket::HandshakeCB,
private AsyncTransportWrapper::WriteCallback { private AsyncTransport::WriteCallback {
public: public:
explicit SSLHandshakeBase( explicit SSLHandshakeBase(
AsyncSSLSocket::UniquePtr socket, AsyncSSLSocket::UniquePtr socket,
......
...@@ -56,8 +56,8 @@ struct EvbAndContext { ...@@ -56,8 +56,8 @@ struct EvbAndContext {
}; };
class AttachDetachClient : public AsyncSocket::ConnectCallback, class AttachDetachClient : public AsyncSocket::ConnectCallback,
public AsyncTransportWrapper::WriteCallback, public AsyncTransport::WriteCallback,
public AsyncTransportWrapper::ReadCallback { public AsyncTransport::ReadCallback {
private: private:
// two threads here - we'll create the socket in one, connect // two threads here - we'll create the socket in one, connect
// in the other, and then read/write in the initial one // in the other, and then read/write in the initial one
......
...@@ -55,7 +55,7 @@ class ConnCallback : public folly::AsyncSocket::ConnectCallback { ...@@ -55,7 +55,7 @@ class ConnCallback : public folly::AsyncSocket::ConnectCallback {
VoidCallback errorCallback; VoidCallback errorCallback;
}; };
class WriteCallback : public folly::AsyncTransportWrapper::WriteCallback { class WriteCallback : public folly::AsyncTransport::WriteCallback {
public: public:
WriteCallback() WriteCallback()
: state(STATE_WAITING), : state(STATE_WAITING),
...@@ -88,7 +88,7 @@ class WriteCallback : public folly::AsyncTransportWrapper::WriteCallback { ...@@ -88,7 +88,7 @@ class WriteCallback : public folly::AsyncTransportWrapper::WriteCallback {
VoidCallback errorCallback; VoidCallback errorCallback;
}; };
class ReadCallback : public folly::AsyncTransportWrapper::ReadCallback { class ReadCallback : public folly::AsyncTransport::ReadCallback {
public: public:
explicit ReadCallback(size_t _maxBufferSz = 4096) explicit ReadCallback(size_t _maxBufferSz = 4096)
: state(STATE_WAITING), : state(STATE_WAITING),
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include <folly/net/NetworkSocket.h> #include <folly/net/NetworkSocket.h>
class BlockingSocket : public folly::AsyncSocket::ConnectCallback, class BlockingSocket : public folly::AsyncSocket::ConnectCallback,
public folly::AsyncTransportWrapper::ReadCallback, public folly::AsyncTransport::ReadCallback,
public folly::AsyncTransportWrapper::WriteCallback { public folly::AsyncTransport::WriteCallback {
public: public:
explicit BlockingSocket(folly::NetworkSocket fd) explicit BlockingSocket(folly::NetworkSocket fd)
: sock_(new folly::AsyncSocket(&eventBase_, fd)) {} : sock_(new folly::AsyncSocket(&eventBase_, fd)) {}
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
namespace folly { namespace folly {
namespace test { namespace test {
class MockAsyncTransport : public AsyncTransportWrapper { class MockAsyncTransport : public AsyncTransport {
public: public:
MOCK_METHOD1(setReadCB, void(ReadCallback*)); MOCK_METHOD1(setReadCB, void(ReadCallback*));
MOCK_CONST_METHOD0(getReadCallback, ReadCallback*()); MOCK_CONST_METHOD0(getReadCallback, ReadCallback*());
...@@ -64,7 +64,7 @@ class MockAsyncTransport : public AsyncTransportWrapper { ...@@ -64,7 +64,7 @@ class MockAsyncTransport : public AsyncTransportWrapper {
MOCK_CONST_METHOD0(getRawBytesReceived, size_t()); MOCK_CONST_METHOD0(getRawBytesReceived, size_t());
MOCK_CONST_METHOD0(isEorTrackingEnabled, bool()); MOCK_CONST_METHOD0(isEorTrackingEnabled, bool());
MOCK_METHOD1(setEorTracking, void(bool)); MOCK_METHOD1(setEorTracking, void(bool));
MOCK_CONST_METHOD0(getWrappedTransport, AsyncTransportWrapper*()); MOCK_CONST_METHOD0(getWrappedTransport, AsyncTransport*());
MOCK_CONST_METHOD0(isReplaySafe, bool()); MOCK_CONST_METHOD0(isReplaySafe, bool());
MOCK_METHOD1( MOCK_METHOD1(
setReplaySafetyCallback, setReplaySafetyCallback,
...@@ -80,7 +80,7 @@ class MockReplaySafetyCallback : public AsyncTransport::ReplaySafetyCallback { ...@@ -80,7 +80,7 @@ class MockReplaySafetyCallback : public AsyncTransport::ReplaySafetyCallback {
} }
}; };
class MockReadCallback : public AsyncTransportWrapper::ReadCallback { class MockReadCallback : public AsyncTransport::ReadCallback {
public: public:
MOCK_METHOD2(getReadBuffer, void(void**, size_t*)); MOCK_METHOD2(getReadBuffer, void(void**, size_t*));
...@@ -111,7 +111,7 @@ class MockReadCallback : public AsyncTransportWrapper::ReadCallback { ...@@ -111,7 +111,7 @@ class MockReadCallback : public AsyncTransportWrapper::ReadCallback {
} }
}; };
class MockWriteCallback : public AsyncTransportWrapper::WriteCallback { class MockWriteCallback : public AsyncTransport::WriteCallback {
public: public:
MOCK_METHOD0(writeSuccess_, void()); MOCK_METHOD0(writeSuccess_, void());
void writeSuccess() noexcept override { void writeSuccess() noexcept override {
......
...@@ -25,16 +25,15 @@ namespace folly { ...@@ -25,16 +25,15 @@ namespace folly {
namespace test { namespace test {
class TestWriteChainAsyncTransportWrapper class TestWriteChainAsyncTransportWrapper
: public WriteChainAsyncTransportWrapper<folly::AsyncTransportWrapper> { : public WriteChainAsyncTransportWrapper<folly::AsyncTransport> {
public: public:
TestWriteChainAsyncTransportWrapper() TestWriteChainAsyncTransportWrapper()
: WriteChainAsyncTransportWrapper<folly::AsyncTransportWrapper>(nullptr) { : WriteChainAsyncTransportWrapper<folly::AsyncTransport>(nullptr) {}
}
MOCK_METHOD3( MOCK_METHOD3(
writeChain, writeChain,
void( void(
folly::AsyncTransportWrapper::WriteCallback*, folly::AsyncTransport::WriteCallback*,
std::shared_ptr<folly::IOBuf>, std::shared_ptr<folly::IOBuf>,
folly::WriteFlags)); folly::WriteFlags));
......
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