summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-09-28 17:42:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-09-28 17:43:38 (GMT)
commitbab047c1bef2936124db1346863a902e1064af12 (patch)
treec59de84a76581bd07713eb0591121e6a4aa04e7b /Swiften/Network/UnitTest
parent7b8860c794419b63f827c9b87fbc469a1bcd58ef (diff)
downloadswift-bab047c1bef2936124db1346863a902e1064af12.zip
swift-bab047c1bef2936124db1346863a902e1064af12.tar.bz2
Pass read data from connection via shared_ptr.
This should avoid unnecessary copying of the received data while being processed by the event loop.
Diffstat (limited to 'Swiften/Network/UnitTest')
-rw-r--r--Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
index 48189ab..133773f 100644
--- a/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
+++ b/Swiften/Network/UnitTest/HTTPConnectProxiedConnectionTest.cpp
@@ -76,7 +76,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("HTTP/1.0 200 Connection established\r\n\r\n"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("HTTP/1.0 200 Connection established\r\n\r\n"));
eventLoop->processEvents();
CPPUNIT_ASSERT(connectFinished);
@@ -89,7 +89,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("FLOOP"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("FLOOP"));
eventLoop->processEvents();
CPPUNIT_ASSERT(connectFinished);
@@ -102,7 +102,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("HTTP/1.0 401 Unauthorized\r\n\r\n"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("HTTP/1.0 401 Unauthorized\r\n\r\n"));
eventLoop->processEvents();
CPPUNIT_ASSERT(connectFinished);
@@ -114,10 +114,10 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
HTTPConnectProxiedConnection::ref testling(createTestling());
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("HTTP/1.0 200 Connection established\r\n\r\n"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("HTTP/1.0 200 Connection established\r\n\r\n"));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("abcdef"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("abcdef"));
CPPUNIT_ASSERT_EQUAL(createByteArray("abcdef"), dataRead);
}
@@ -126,7 +126,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
HTTPConnectProxiedConnection::ref testling(createTestling());
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("HTTP/1.0 200 Connection established\r\n\r\n"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("HTTP/1.0 200 Connection established\r\n\r\n"));
eventLoop->processEvents();
connectionFactory->connections[0]->dataWritten.clear();
@@ -151,7 +151,7 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
HTTPConnectProxiedConnection::ref testling(createTestling());
testling->connect(HostAddressPort(HostAddress("2.2.2.2"), 2345));
eventLoop->processEvents();
- connectionFactory->connections[0]->onDataRead(createSafeByteArray("HTTP/1.0 200 Connection established\r\n\r\n"));
+ connectionFactory->connections[0]->onDataRead(createSafeByteArrayRef("HTTP/1.0 200 Connection established\r\n\r\n"));
eventLoop->processEvents();
testling->disconnect();
@@ -180,8 +180,8 @@ class HTTPConnectProxiedConnectionTest : public CppUnit::TestFixture {
disconnectedError = e;
}
- void handleDataRead(const SafeByteArray& d) {
- append(dataRead, d);
+ void handleDataRead(boost::shared_ptr<SafeByteArray> d) {
+ append(dataRead, *d);
}
struct MockConnection : public Connection {