Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: net/base/ssl_client_socket_unittest.cc

Issue 87073: Extend the use of IOBuffers to the code underneath... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/ssl_client_socket_nss.cc ('k') | net/base/ssl_client_socket_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ssl_client_socket_unittest.cc
===================================================================
--- net/base/ssl_client_socket_unittest.cc (revision 14682)
+++ net/base/ssl_client_socket_unittest.cc (working copy)
@@ -220,7 +220,11 @@
EXPECT_TRUE(sock->IsConnected());
const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
- rv = sock->Write(request_text, arraysize(request_text) - 1, &callback);
+ scoped_refptr<net::IOBuffer> request_buffer =
+ new net::IOBuffer(arraysize(request_text) - 1);
+ memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1);
+
+ rv = sock->Write(request_buffer, arraysize(request_text) - 1, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING) {
@@ -228,9 +232,9 @@
EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv);
}
- char buf[4096];
+ scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(4096);
for (;;) {
- rv = sock->Read(buf, sizeof(buf), &callback);
+ rv = sock->Read(buf, 4096, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING)
@@ -272,7 +276,11 @@
}
const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
- rv = sock->Write(request_text, arraysize(request_text) - 1, &callback);
+ scoped_refptr<net::IOBuffer> request_buffer =
+ new net::IOBuffer(arraysize(request_text) - 1);
+ memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1);
+
+ rv = sock->Write(request_buffer, arraysize(request_text) - 1, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING) {
@@ -280,9 +288,9 @@
EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv);
}
- char buf[1];
+ scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(1);
for (;;) {
- rv = sock->Read(buf, sizeof(buf), &callback);
+ rv = sock->Read(buf, 1, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING)
@@ -324,7 +332,11 @@
}
const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
- rv = sock->Write(request_text, arraysize(request_text) - 1, &callback);
+ scoped_refptr<net::IOBuffer> request_buffer =
+ new net::IOBuffer(arraysize(request_text) - 1);
+ memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1);
+
+ rv = sock->Write(request_buffer, arraysize(request_text) - 1, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING) {
@@ -333,8 +345,8 @@
}
// Do a partial read and then exit. This test should not crash!
- char buf[512];
- rv = sock->Read(buf, sizeof(buf), &callback);
+ scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(512);
+ rv = sock->Read(buf, 512, &callback);
EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING);
if (rv == net::ERR_IO_PENDING)
« no previous file with comments | « net/base/ssl_client_socket_nss.cc ('k') | net/base/ssl_client_socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698