зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569183: Rename NrSocketProxy to NrTcpSocket, and use NrTcpSocket for TCP on content/socket process. r=mjf
Differential Revision: https://phabricator.services.mozilla.com/D45099 --HG-- rename : media/mtransport/nr_socket_proxy.cpp => media/mtransport/nr_socket_tcp.cpp rename : media/mtransport/nr_socket_proxy.h => media/mtransport/nr_socket_tcp.h extra : moz-landing-system : lando
This commit is contained in:
Родитель
ffa09cee72
Коммит
c368262621
|
@ -7,9 +7,9 @@
|
|||
mtransport_lcppsrcs = [
|
||||
'dtlsidentity.cpp',
|
||||
'mediapacket.cpp',
|
||||
'nr_socket_proxy.cpp',
|
||||
'nr_socket_proxy_config.cpp',
|
||||
'nr_socket_prsock.cpp',
|
||||
'nr_socket_tcp.cpp',
|
||||
'nr_timer.cpp',
|
||||
'nricectx.cpp',
|
||||
'nricemediastream.cpp',
|
||||
|
|
|
@ -140,7 +140,7 @@ nrappkit copyright:
|
|||
|
||||
# include "mozilla/dom/network/TCPSocketChild.h"
|
||||
# include "mozilla/dom/network/UDPSocketChild.h"
|
||||
# include "nr_socket_proxy.h"
|
||||
# include "nr_socket_tcp.h"
|
||||
|
||||
# ifdef LOG_TEMP_INFO
|
||||
# define LOG_INFO LOG_TEMP_INFO
|
||||
|
@ -2082,31 +2082,19 @@ int NrSocketBase::CreateSocket(
|
|||
|
||||
// create IPC bridge for content process
|
||||
if (XRE_IsParentProcess()) {
|
||||
// TODO: Make NrTcpSocket work on the parent process
|
||||
*sock = new NrSocket();
|
||||
} else if (XRE_IsSocketProcess()) {
|
||||
if (addr->protocol == IPPROTO_TCP && config) {
|
||||
*sock = new NrSocketProxy(config);
|
||||
if (addr->protocol == IPPROTO_TCP) {
|
||||
*sock = new NrTcpSocket(config);
|
||||
} else {
|
||||
*sock = new NrSocket();
|
||||
}
|
||||
} else {
|
||||
switch (addr->protocol) {
|
||||
case IPPROTO_UDP:
|
||||
*sock = new NrUdpSocketIpc();
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
#if defined(MOZILLA_INTERNAL_API)
|
||||
if (!config) {
|
||||
nsCOMPtr<nsIThread> main_thread;
|
||||
NS_GetMainThread(getter_AddRefs(main_thread));
|
||||
*sock = new NrTcpSocketIpc(main_thread.get());
|
||||
if (addr->protocol == IPPROTO_TCP) {
|
||||
*sock = new NrTcpSocket(config);
|
||||
} else {
|
||||
*sock = new NrSocketProxy(config);
|
||||
}
|
||||
#else
|
||||
ABORT(R_REJECTED);
|
||||
#endif
|
||||
break;
|
||||
*sock = new NrUdpSocketIpc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "nr_socket_proxy.h"
|
||||
#include "nr_socket_tcp.h"
|
||||
|
||||
#include "mozilla/ErrorNames.h"
|
||||
|
||||
|
@ -50,13 +50,13 @@ using namespace net;
|
|||
|
||||
using std::shared_ptr;
|
||||
|
||||
class NrSocketProxyData {
|
||||
class NrTcpSocketData {
|
||||
public:
|
||||
explicit NrSocketProxyData(nsTArray<uint8_t>&& aData) : mData(aData) {
|
||||
MOZ_COUNT_CTOR(NrSocketProxyData);
|
||||
explicit NrTcpSocketData(nsTArray<uint8_t>&& aData) : mData(aData) {
|
||||
MOZ_COUNT_CTOR(NrTcpSocketData);
|
||||
}
|
||||
|
||||
~NrSocketProxyData() { MOZ_COUNT_DTOR(NrSocketProxyData); }
|
||||
~NrTcpSocketData() { MOZ_COUNT_DTOR(NrTcpSocketData); }
|
||||
|
||||
const nsTArray<uint8_t>& GetData() const { return mData; }
|
||||
|
||||
|
@ -64,21 +64,21 @@ class NrSocketProxyData {
|
|||
nsTArray<uint8_t> mData;
|
||||
};
|
||||
|
||||
NrSocketProxy::NrSocketProxy(const shared_ptr<NrSocketProxyConfig>& aConfig)
|
||||
NrTcpSocket::NrTcpSocket(const shared_ptr<NrSocketProxyConfig>& aConfig)
|
||||
: mClosed(false),
|
||||
mReadOffset(0),
|
||||
mConfig(aConfig),
|
||||
mWebrtcTCPSocket(nullptr) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::NrSocketProxy %p\n", this);
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::NrTcpSocket %p\n", this);
|
||||
MOZ_ASSERT(mConfig, "config should not be null");
|
||||
}
|
||||
|
||||
NrSocketProxy::~NrSocketProxy() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::~NrSocketProxy %p\n", this);
|
||||
MOZ_ASSERT(!mWebrtcTCPSocket, "webrtc proxy channel not null");
|
||||
NrTcpSocket::~NrTcpSocket() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::~NrTcpSocket %p\n", this);
|
||||
MOZ_ASSERT(!mWebrtcTCPSocket, "webrtc TCP socket not null");
|
||||
}
|
||||
|
||||
int NrSocketProxy::create(nr_transport_addr* aAddr) {
|
||||
int NrTcpSocket::create(nr_transport_addr* aAddr) {
|
||||
int32_t port;
|
||||
nsCString host;
|
||||
|
||||
|
@ -94,8 +94,8 @@ int NrSocketProxy::create(nr_transport_addr* aAddr) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int NrSocketProxy::connect(nr_transport_addr* aAddr) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::Connect %p\n", this);
|
||||
int NrTcpSocket::connect(nr_transport_addr* aAddr) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::Connect %p\n", this);
|
||||
|
||||
nsCString host;
|
||||
int port;
|
||||
|
@ -112,8 +112,8 @@ int NrSocketProxy::connect(nr_transport_addr* aAddr) {
|
|||
return R_WOULDBLOCK;
|
||||
}
|
||||
|
||||
void NrSocketProxy::close() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::Close %p\n", this);
|
||||
void NrTcpSocket::close() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::Close %p\n", this);
|
||||
|
||||
if (mClosed) {
|
||||
return;
|
||||
|
@ -128,8 +128,8 @@ void NrSocketProxy::close() {
|
|||
}
|
||||
}
|
||||
|
||||
int NrSocketProxy::write(const void* aBuffer, size_t aCount, size_t* aWrote) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::Write %p count=%zu\n", this,
|
||||
int NrTcpSocket::write(const void* aBuffer, size_t aCount, size_t* aWrote) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::Write %p count=%zu\n", this,
|
||||
aCount);
|
||||
|
||||
if (mClosed) {
|
||||
|
@ -153,8 +153,8 @@ int NrSocketProxy::write(const void* aBuffer, size_t aCount, size_t* aWrote) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int NrSocketProxy::read(void* aBuffer, size_t aCount, size_t* aRead) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::Read %p\n", this);
|
||||
int NrTcpSocket::read(void* aBuffer, size_t aCount, size_t* aRead) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::Read %p\n", this);
|
||||
|
||||
if (mClosed) {
|
||||
return R_FAILED;
|
||||
|
@ -171,7 +171,7 @@ int NrSocketProxy::read(void* aBuffer, size_t aCount, size_t* aRead) {
|
|||
}
|
||||
|
||||
while (aCount > 0 && !mReadQueue.empty()) {
|
||||
const NrSocketProxyData& data = mReadQueue.front();
|
||||
const NrTcpSocketData& data = mReadQueue.front();
|
||||
|
||||
size_t remainingCount = data.GetData().Length() - mReadOffset;
|
||||
size_t amountToCopy = std::min(aCount, remainingCount);
|
||||
|
@ -193,37 +193,37 @@ int NrSocketProxy::read(void* aBuffer, size_t aCount, size_t* aRead) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int NrSocketProxy::getaddr(nr_transport_addr* aAddr) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::GetAddr %p\n", this);
|
||||
int NrTcpSocket::getaddr(nr_transport_addr* aAddr) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::GetAddr %p\n", this);
|
||||
return nr_transport_addr_copy(aAddr, &my_addr_);
|
||||
}
|
||||
|
||||
int NrSocketProxy::sendto(const void* aBuffer, size_t aCount, int aFlags,
|
||||
int NrTcpSocket::sendto(const void* aBuffer, size_t aCount, int aFlags,
|
||||
nr_transport_addr* aAddr) {
|
||||
// never call this
|
||||
MOZ_ASSERT(0);
|
||||
return R_FAILED;
|
||||
}
|
||||
|
||||
int NrSocketProxy::recvfrom(void* aBuffer, size_t aCount, size_t* aRead,
|
||||
int NrTcpSocket::recvfrom(void* aBuffer, size_t aCount, size_t* aRead,
|
||||
int aFlags, nr_transport_addr* aAddr) {
|
||||
// never call this
|
||||
MOZ_ASSERT(0);
|
||||
return R_FAILED;
|
||||
}
|
||||
|
||||
int NrSocketProxy::listen(int aBacklog) { return R_INTERNAL; }
|
||||
int NrTcpSocket::listen(int aBacklog) { return R_INTERNAL; }
|
||||
|
||||
int NrSocketProxy::accept(nr_transport_addr* aAddr, nr_socket** aSocket) {
|
||||
int NrTcpSocket::accept(nr_transport_addr* aAddr, nr_socket** aSocket) {
|
||||
return R_INTERNAL;
|
||||
}
|
||||
|
||||
// WebrtcTCPSocketCallback
|
||||
void NrSocketProxy::OnClose(nsresult aReason) {
|
||||
void NrTcpSocket::OnClose(nsresult aReason) {
|
||||
nsCString errorName;
|
||||
GetErrorName(aReason, errorName);
|
||||
|
||||
r_log(LOG_GENERIC, LOG_ERR, "NrSocketProxy::OnClose %p reason=%u name=%s\n",
|
||||
r_log(LOG_GENERIC, LOG_ERR, "NrTcpSocket::OnClose %p reason=%u name=%s\n",
|
||||
this, static_cast<uint32_t>(aReason), errorName.get());
|
||||
|
||||
close();
|
||||
|
@ -231,14 +231,14 @@ void NrSocketProxy::OnClose(nsresult aReason) {
|
|||
DoCallbacks();
|
||||
}
|
||||
|
||||
void NrSocketProxy::OnConnected() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::OnConnected %p\n", this);
|
||||
void NrTcpSocket::OnConnected() {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::OnConnected %p\n", this);
|
||||
|
||||
DoCallbacks();
|
||||
}
|
||||
|
||||
void NrSocketProxy::OnRead(nsTArray<uint8_t>&& aReadData) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrSocketProxy::OnRead %p read=%zu\n", this,
|
||||
void NrTcpSocket::OnRead(nsTArray<uint8_t>&& aReadData) {
|
||||
r_log(LOG_GENERIC, LOG_DEBUG, "NrTcpSocket::OnRead %p read=%zu\n", this,
|
||||
aReadData.Length());
|
||||
|
||||
mReadQueue.emplace_back(std::move(aReadData));
|
||||
|
@ -246,7 +246,7 @@ void NrSocketProxy::OnRead(nsTArray<uint8_t>&& aReadData) {
|
|||
DoCallbacks();
|
||||
}
|
||||
|
||||
void NrSocketProxy::DoCallbacks() {
|
||||
void NrTcpSocket::DoCallbacks() {
|
||||
size_t lastCount = -1;
|
||||
size_t currentCount = 0;
|
||||
while ((poll_flags() & PR_POLL_READ) != 0 &&
|
||||
|
@ -265,10 +265,10 @@ void NrSocketProxy::DoCallbacks() {
|
|||
}
|
||||
}
|
||||
|
||||
size_t NrSocketProxy::CountUnreadBytes() const {
|
||||
size_t NrTcpSocket::CountUnreadBytes() const {
|
||||
size_t count = 0;
|
||||
|
||||
for (const NrSocketProxyData& data : mReadQueue) {
|
||||
for (const NrTcpSocketData& data : mReadQueue) {
|
||||
count += data.GetData().Length();
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ size_t NrSocketProxy::CountUnreadBytes() const {
|
|||
return count;
|
||||
}
|
||||
|
||||
void NrSocketProxy::AssignChannel_DoNotUse(WebrtcTCPSocketWrapper* aWrapper) {
|
||||
void NrTcpSocket::AssignChannel_DoNotUse(WebrtcTCPSocketWrapper* aWrapper) {
|
||||
mWebrtcTCPSocket = aWrapper;
|
||||
}
|
||||
|
|
@ -39,8 +39,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef nr_socket_proxy_h__
|
||||
#define nr_socket_proxy_h__
|
||||
#ifndef nr_socket_tcp_h__
|
||||
#define nr_socket_tcp_h__
|
||||
|
||||
#include <list>
|
||||
|
||||
|
@ -63,14 +63,14 @@ namespace net {
|
|||
class WebrtcTCPSocketWrapper;
|
||||
} // namespace net
|
||||
|
||||
class NrSocketProxyData;
|
||||
class NrTcpSocketData;
|
||||
class NrSocketProxyConfig;
|
||||
|
||||
class NrSocketProxy : public NrSocketBase, public WebrtcTCPSocketCallback {
|
||||
class NrTcpSocket : public NrSocketBase, public WebrtcTCPSocketCallback {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrSocketProxy, override)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrTcpSocket, override)
|
||||
|
||||
explicit NrSocketProxy(const std::shared_ptr<NrSocketProxyConfig>& aConfig);
|
||||
explicit NrTcpSocket(const std::shared_ptr<NrSocketProxyConfig>& aConfig);
|
||||
|
||||
// NrSocketBase
|
||||
int create(nr_transport_addr* aAddr) override;
|
||||
|
@ -99,7 +99,7 @@ class NrSocketProxy : public NrSocketBase, public WebrtcTCPSocketCallback {
|
|||
void AssignChannel_DoNotUse(WebrtcTCPSocketWrapper* aWrapper);
|
||||
|
||||
protected:
|
||||
virtual ~NrSocketProxy();
|
||||
virtual ~NrTcpSocket();
|
||||
|
||||
private:
|
||||
void DoCallbacks();
|
||||
|
@ -107,7 +107,7 @@ class NrSocketProxy : public NrSocketBase, public WebrtcTCPSocketCallback {
|
|||
bool mClosed;
|
||||
|
||||
size_t mReadOffset;
|
||||
std::list<NrSocketProxyData> mReadQueue;
|
||||
std::list<NrTcpSocketData> mReadQueue;
|
||||
|
||||
std::shared_ptr<NrSocketProxyConfig> mConfig;
|
||||
|
||||
|
@ -116,4 +116,4 @@ class NrSocketProxy : public NrSocketBase, public WebrtcTCPSocketCallback {
|
|||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // nr_socket_proxy_h__
|
||||
#endif // nr_socket_tcp_h__
|
|
@ -10,7 +10,7 @@
|
|||
#include <numeric>
|
||||
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "nr_socket_proxy.h"
|
||||
#include "nr_socket_tcp.h"
|
||||
#include "nr_socket_proxy_config.h"
|
||||
#include "WebrtcTCPSocketWrapper.h"
|
||||
|
||||
|
@ -23,9 +23,9 @@ using namespace mozilla;
|
|||
// update TestReadMultipleSizes if you change this
|
||||
const std::string kHelloMessage = "HELLO IS IT ME YOU'RE LOOKING FOR?";
|
||||
|
||||
class NrSocketProxyTest : public MtransportTest {
|
||||
class NrTcpSocketTest : public MtransportTest {
|
||||
public:
|
||||
NrSocketProxyTest()
|
||||
NrTcpSocketTest()
|
||||
: mSProxy(nullptr),
|
||||
nr_socket_(nullptr),
|
||||
mEmptyArray(0),
|
||||
|
@ -39,7 +39,7 @@ class NrSocketProxyTest : public MtransportTest {
|
|||
std::shared_ptr<NrSocketProxyConfig> config;
|
||||
config.reset(new NrSocketProxyConfig(0, alpn, net::LoadInfoArgs()));
|
||||
// config is never used but must be non-null
|
||||
mSProxy = new NrSocketProxy(config);
|
||||
mSProxy = new NrTcpSocket(config);
|
||||
int r = nr_socket_create_int((void*)mSProxy.get(), mSProxy->vtbl(),
|
||||
&nr_socket_);
|
||||
ASSERT_EQ(0, r);
|
||||
|
@ -51,7 +51,7 @@ class NrSocketProxyTest : public MtransportTest {
|
|||
void TearDown() override { mSProxy->close(); }
|
||||
|
||||
static void readable_cb(NR_SOCKET s, int how, void* cb_arg) {
|
||||
NrSocketProxyTest* test = (NrSocketProxyTest*)cb_arg;
|
||||
NrTcpSocketTest* test = (NrTcpSocketTest*)cb_arg;
|
||||
size_t capacity = std::min(test->mReadChunkSize, test->mReadAllowance);
|
||||
nsTArray<uint8_t> array(capacity);
|
||||
size_t read;
|
||||
|
@ -71,12 +71,12 @@ class NrSocketProxyTest : public MtransportTest {
|
|||
test->mReadChunkSize += test->mReadChunkSizeIncrement;
|
||||
|
||||
if (test->mReadAllowance > 0) {
|
||||
NR_ASYNC_WAIT(s, how, &NrSocketProxyTest::readable_cb, cb_arg);
|
||||
NR_ASYNC_WAIT(s, how, &NrTcpSocketTest::readable_cb, cb_arg);
|
||||
}
|
||||
}
|
||||
|
||||
static void writable_cb(NR_SOCKET s, int how, void* cb_arg) {
|
||||
NrSocketProxyTest* test = (NrSocketProxyTest*)cb_arg;
|
||||
NrTcpSocketTest* test = (NrTcpSocketTest*)cb_arg;
|
||||
test->mConnected = true;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class NrSocketProxyTest : public MtransportTest {
|
|||
}
|
||||
|
||||
protected:
|
||||
RefPtr<NrSocketProxy> mSProxy;
|
||||
RefPtr<NrTcpSocket> mSProxy;
|
||||
nr_socket* nr_socket_;
|
||||
|
||||
nsTArray<uint8_t> mData;
|
||||
|
@ -98,12 +98,12 @@ class NrSocketProxyTest : public MtransportTest {
|
|||
bool mConnected;
|
||||
};
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestCreate) {}
|
||||
TEST_F(NrTcpSocketTest, TestCreate) {}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestConnected) {
|
||||
TEST_F(NrTcpSocketTest, TestConnected) {
|
||||
ASSERT_TRUE(!mConnected);
|
||||
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_WRITE, &NrSocketProxyTest::writable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_WRITE, &NrTcpSocketTest::writable_cb,
|
||||
this);
|
||||
|
||||
// still not connected just registered for writes...
|
||||
|
@ -114,11 +114,11 @@ TEST_F(NrSocketProxyTest, TestConnected) {
|
|||
ASSERT_TRUE(mConnected);
|
||||
}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestRead) {
|
||||
TEST_F(NrTcpSocketTest, TestRead) {
|
||||
nsTArray<uint8_t> array;
|
||||
array.AppendElements(kHelloMessage.c_str(), kHelloMessage.length());
|
||||
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrSocketProxyTest::readable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrTcpSocketTest::readable_cb,
|
||||
this);
|
||||
// this will read 0 bytes here
|
||||
mSProxy->OnRead(std::move(array));
|
||||
|
@ -133,7 +133,7 @@ TEST_F(NrSocketProxyTest, TestRead) {
|
|||
ASSERT_EQ(kHelloMessage, DataString());
|
||||
}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestReadConstantConsumeSize) {
|
||||
TEST_F(NrTcpSocketTest, TestReadConstantConsumeSize) {
|
||||
std::string data;
|
||||
|
||||
// triangle number
|
||||
|
@ -161,7 +161,7 @@ TEST_F(NrSocketProxyTest, TestReadConstantConsumeSize) {
|
|||
// read same amount each callback
|
||||
mReadChunkSize = 128;
|
||||
mReadChunkSizeIncrement = 0;
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrSocketProxyTest::readable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrTcpSocketTest::readable_cb,
|
||||
this);
|
||||
|
||||
ASSERT_EQ(data.length(), mSProxy->CountUnreadBytes());
|
||||
|
@ -173,7 +173,7 @@ TEST_F(NrSocketProxyTest, TestReadConstantConsumeSize) {
|
|||
ASSERT_EQ(data, DataString());
|
||||
}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestReadNone) {
|
||||
TEST_F(NrTcpSocketTest, TestReadNone) {
|
||||
char buf[4096];
|
||||
size_t read = 0;
|
||||
int r = nr_socket_read(nr_socket_, buf, sizeof(buf), &read, 0);
|
||||
|
@ -193,7 +193,7 @@ TEST_F(NrSocketProxyTest, TestReadNone) {
|
|||
ASSERT_EQ(kHelloMessage, std::string(buf, read));
|
||||
}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestReadMultipleSizes) {
|
||||
TEST_F(NrTcpSocketTest, TestReadMultipleSizes) {
|
||||
using namespace std;
|
||||
|
||||
string data;
|
||||
|
@ -227,7 +227,7 @@ TEST_F(NrSocketProxyTest, TestReadMultipleSizes) {
|
|||
|
||||
// don't need to read 0 on the first read, so start at 1 and keep going
|
||||
mReadChunkSize = 1;
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrSocketProxyTest::readable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrTcpSocketTest::readable_cb,
|
||||
this);
|
||||
// start callbacks
|
||||
mSProxy->OnRead(std::move(mEmptyArray));
|
||||
|
@ -236,7 +236,7 @@ TEST_F(NrSocketProxyTest, TestReadMultipleSizes) {
|
|||
ASSERT_EQ(data, DataString());
|
||||
}
|
||||
|
||||
TEST_F(NrSocketProxyTest, TestReadConsumeReadDrain) {
|
||||
TEST_F(NrTcpSocketTest, TestReadConsumeReadDrain) {
|
||||
std::string data;
|
||||
// ~26kb total; should be even
|
||||
const int kCount = 512;
|
||||
|
@ -255,7 +255,7 @@ TEST_F(NrSocketProxyTest, TestReadConsumeReadDrain) {
|
|||
mReadAllowance = kCount / 2 * kHelloMessage.length();
|
||||
// start by reading 1 byte
|
||||
mReadChunkSize = 1;
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrSocketProxyTest::readable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrTcpSocketTest::readable_cb,
|
||||
this);
|
||||
mSProxy->OnRead(std::move(mEmptyArray));
|
||||
|
||||
|
@ -273,7 +273,7 @@ TEST_F(NrSocketProxyTest, TestReadConsumeReadDrain) {
|
|||
// remove read limit
|
||||
mReadAllowance = -1;
|
||||
// used entire read allowance so we need to setup a new await
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrSocketProxyTest::readable_cb,
|
||||
NR_ASYNC_WAIT(mSProxy, NR_ASYNC_WAIT_READ, &NrTcpSocketTest::readable_cb,
|
||||
this);
|
||||
// start callbacks
|
||||
mSProxy->OnRead(std::move(mEmptyArray));
|
||||
|
|
Загрузка…
Ссылка в новой задаче