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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 years 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
Index: net/spdy/spdy_network_transaction_unittest.cc
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 901c1eb720bb30e2862136dcf8ae927a1f07e658..03aa6f584f884238d3a02a2e9191fe11463a78d5 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -7,6 +7,8 @@
#include <string>
#include <vector>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "net/base/auth.h"
#include "net/base/net_log_unittest.h"
#include "net/http/http_network_session_peer.h"
@@ -57,9 +59,6 @@ class SpdyNetworkTransactionTest
spdy::SpdyFramer::set_enable_compression_default(enabled);
}
- class StartTransactionCallback;
- class DeleteSessionCallback;
-
// A helper class that handles all the initial npn/ssl setup.
class NormalSpdyTransactionHelper {
public:
@@ -150,7 +149,7 @@ class SpdyNetworkTransactionTest
// Start the transaction, read some data, finish.
void RunDefaultTest() {
- output_.rv = trans_->Start(&request_, &callback, log_);
+ output_.rv = trans_->Start(&request_, callback.callback(), log_);
// We expect an IO Pending or some sort of error.
EXPECT_LT(output_.rv, 0);
@@ -324,7 +323,7 @@ class SpdyNetworkTransactionTest
TransactionHelperResult output_;
scoped_ptr<StaticSocketDataProvider> first_transaction_;
SSLVector ssl_vector_;
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
scoped_ptr<HttpNetworkTransaction> trans_;
scoped_ptr<HttpNetworkTransaction> trans_http_;
DataVector data_vector_;
@@ -408,9 +407,9 @@ class SpdyNetworkTransactionTest
int bytes_read = 0;
scoped_refptr<net::IOBufferWithSize> buf(new net::IOBufferWithSize(kSize));
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
while (true) {
- int rv = trans->Read(buf, kSize, &callback);
+ int rv = trans->Read(buf, kSize, callback.callback());
if (rv == ERR_IO_PENDING) {
// Multiple transactions may be in the data set. Keep pulling off
// reads until we complete our callback.
@@ -458,15 +457,17 @@ class SpdyNetworkTransactionTest
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
// Request the pushed path.
scoped_ptr<HttpNetworkTransaction> trans2(
new HttpNetworkTransaction(helper.session()));
- rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog());
+ rv = trans2->Start(
+ &CreateGetPushRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
MessageLoop::current()->RunAllPending();
@@ -498,6 +499,26 @@ class SpdyNetworkTransactionTest
VerifyStreamsClosed(helper);
}
+ static void DeleteSessionCallback(NormalSpdyTransactionHelper* helper,
+ int result) {
+ helper->ResetTrans();
+ }
+
+ static void StartTransactionCallback(
+ const scoped_refptr<HttpNetworkSession>& session,
+ int result) {
+ scoped_ptr<HttpNetworkTransaction> trans(
+ new HttpNetworkTransaction(session));
+ TestCompletionCallback callback;
+ HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://www.google.com/");
+ request.load_flags = 0;
+ int rv = trans->Start(&request, callback.callback(), BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ callback.WaitForResult();
+ }
+
private:
bool google_get_request_initialized_;
bool google_post_request_initialized_;
@@ -670,19 +691,19 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGets) {
scoped_ptr<HttpNetworkTransaction> trans3(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
- TestOldCompletionCallback callback3;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
+ TestCompletionCallback callback3;
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
HttpRequestInfo httpreq3 = CreateGetRequest();
- out.rv = trans1->Start(&httpreq1, &callback1, log);
+ out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans2->Start(&httpreq2, &callback2, log);
+ out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans3->Start(&httpreq3, &callback3, log);
+ out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
out.rv = callback1.WaitForResult();
@@ -755,15 +776,15 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBinding) {
scoped_ptr<HttpNetworkTransaction> trans2(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
- out.rv = trans1->Start(&httpreq1, &callback1, log);
+ out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans2->Start(&httpreq2, &callback2, log);
+ out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
out.rv = callback1.WaitForResult();
@@ -844,8 +865,8 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
scoped_ptr<HttpNetworkTransaction> trans2(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
HttpRequestInfo httpreq = CreateGetRequest();
@@ -861,9 +882,9 @@ TEST_P(SpdyNetworkTransactionTest, TwoGetsLateBindingFromPreconnect) {
http_stream_factory->PreconnectStreams(
1, httpreq, preconnect_ssl_config, preconnect_ssl_config, log);
- out.rv = trans1->Start(&httpreq, &callback1, log);
+ out.rv = trans1->Start(&httpreq, callback1.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans2->Start(&httpreq, &callback2, log);
+ out.rv = trans2->Start(&httpreq, callback2.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
out.rv = callback1.WaitForResult();
@@ -969,24 +990,24 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrent) {
scoped_ptr<HttpNetworkTransaction> trans3(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
- TestOldCompletionCallback callback3;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
+ TestCompletionCallback callback3;
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
HttpRequestInfo httpreq3 = CreateGetRequest();
- out.rv = trans1->Start(&httpreq1, &callback1, log);
+ out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
// run transaction 1 through quickly to force a read of our SETTINGS
// frame
out.rv = callback1.WaitForResult();
ASSERT_EQ(OK, out.rv);
- out.rv = trans2->Start(&httpreq2, &callback2, log);
+ out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
- out.rv = trans3->Start(&httpreq3, &callback3, log);
+ out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback2.WaitForResult();
ASSERT_EQ(OK, out.rv);
@@ -1111,10 +1132,10 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
scoped_ptr<HttpNetworkTransaction> trans4(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
- TestOldCompletionCallback callback3;
- TestOldCompletionCallback callback4;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
+ TestCompletionCallback callback3;
+ TestCompletionCallback callback4;
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
@@ -1122,18 +1143,18 @@ TEST_P(SpdyNetworkTransactionTest, FourGetsWithMaxConcurrentPriority) {
HttpRequestInfo httpreq4 = CreateGetRequest();
httpreq4.priority = HIGHEST;
- out.rv = trans1->Start(&httpreq1, &callback1, log);
+ out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
// run transaction 1 through quickly to force a read of our SETTINGS
// frame
out.rv = callback1.WaitForResult();
ASSERT_EQ(OK, out.rv);
- out.rv = trans2->Start(&httpreq2, &callback2, log);
+ out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans3->Start(&httpreq3, &callback3, log);
+ out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
- out.rv = trans4->Start(&httpreq4, &callback4, log);
+ out.rv = trans4->Start(&httpreq4, callback4.callback(), log);
ASSERT_EQ(ERR_IO_PENDING, out.rv);
out.rv = callback2.WaitForResult();
@@ -1245,24 +1266,24 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
scoped_ptr<HttpNetworkTransaction> trans3(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
- TestOldCompletionCallback callback3;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
+ TestCompletionCallback callback3;
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
HttpRequestInfo httpreq3 = CreateGetRequest();
- out.rv = trans1->Start(&httpreq1, &callback1, log);
+ out.rv = trans1->Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
// run transaction 1 through quickly to force a read of our SETTINGS
// frame
out.rv = callback1.WaitForResult();
ASSERT_EQ(OK, out.rv);
- out.rv = trans2->Start(&httpreq2, &callback2, log);
+ out.rv = trans2->Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
- out.rv = trans3->Start(&httpreq3, &callback3, log);
+ out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
delete trans3.release();
ASSERT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback2.WaitForResult();
@@ -1295,19 +1316,28 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentDelete) {
// The KillerCallback will delete the transaction on error as part of the
// callback.
-class KillerCallback : public TestOldCompletionCallback {
+class KillerCallback : public TestCompletionCallbackBase {
public:
explicit KillerCallback(HttpNetworkTransaction* transaction)
- : transaction_(transaction) {}
+ : transaction_(transaction),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
+ base::Bind(&KillerCallback::OnComplete, base::Unretained(this)))) {
+ }
+
+ virtual ~KillerCallback() {}
+
+ const CompletionCallback& callback() const { return callback_; }
- virtual void RunWithParams(const Tuple1<int>& params) {
- if (params.a < 0)
+ private:
+ void OnComplete(int result) {
+ if (result < 0)
delete transaction_;
- TestOldCompletionCallback::RunWithParams(params);
+
+ SetResult(result);
}
- private:
HttpNetworkTransaction* transaction_;
+ CompletionCallback callback_;
};
// Similar to ThreeGetsMaxConcurrrentDelete above, however, this test
@@ -1363,24 +1393,24 @@ TEST_P(SpdyNetworkTransactionTest, ThreeGetsWithMaxConcurrentSocketClose) {
HttpNetworkTransaction trans2(helper.session());
HttpNetworkTransaction* trans3(new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback1;
- TestOldCompletionCallback callback2;
+ TestCompletionCallback callback1;
+ TestCompletionCallback callback2;
KillerCallback callback3(trans3);
HttpRequestInfo httpreq1 = CreateGetRequest();
HttpRequestInfo httpreq2 = CreateGetRequest();
HttpRequestInfo httpreq3 = CreateGetRequest();
- out.rv = trans1.Start(&httpreq1, &callback1, log);
+ out.rv = trans1.Start(&httpreq1, callback1.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
// run transaction 1 through quickly to force a read of our SETTINGS
// frame
out.rv = callback1.WaitForResult();
ASSERT_EQ(OK, out.rv);
- out.rv = trans2.Start(&httpreq2, &callback2, log);
+ out.rv = trans2.Start(&httpreq2, callback2.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
- out.rv = trans3->Start(&httpreq3, &callback3, log);
+ out.rv = trans3->Start(&httpreq3, callback3.callback(), log);
ASSERT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback3.WaitForResult();
ASSERT_EQ(ERR_ABORTED, out.rv);
@@ -1757,8 +1787,9 @@ TEST_P(SpdyNetworkTransactionTest, SocketWriteReturnsZero) {
helper.AddDeterministicData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->SetStop(2);
@@ -1813,8 +1844,8 @@ TEST_P(SpdyNetworkTransactionTest, ResponseWithTwoSynReplies) {
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -1908,8 +1939,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) {
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -1965,8 +1996,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
helper.RunPreTestSetup();
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -1990,7 +2021,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
// Issue a read which will cause a WINDOW_UPDATE to be sent and window
// size increased to default.
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kUploadDataSize));
- rv = trans->Read(buf, kUploadDataSize, NULL);
+ rv = trans->Read(buf, kUploadDataSize, CompletionCallback());
EXPECT_EQ(kUploadDataSize, rv);
std::string content(buf->data(), buf->data()+kUploadDataSize);
EXPECT_STREQ(kUploadData, content.c_str());
@@ -2071,8 +2102,8 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) {
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -2179,8 +2210,8 @@ TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
MessageLoop::current()->RunAllPending(); // Write as much as we can.
@@ -2224,8 +2255,9 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransaction) {
helper.AddData(&data);
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
helper.ResetTrans(); // Cancel the transaction.
@@ -2263,9 +2295,10 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) {
helper.AddDeterministicData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->SetStop(2);
@@ -2277,33 +2310,6 @@ TEST_P(SpdyNetworkTransactionTest, CancelledTransactionSendRst) {
helper.VerifyDataConsumed();
}
-class SpdyNetworkTransactionTest::StartTransactionCallback
- : public CallbackRunner< Tuple1<int> > {
- public:
- explicit StartTransactionCallback(
- const scoped_refptr<HttpNetworkSession>& session,
- NormalSpdyTransactionHelper& helper)
- : session_(session), helper_(helper) {}
-
- // We try to start another transaction, which should succeed.
- virtual void RunWithParams(const Tuple1<int>& params) {
- scoped_ptr<HttpNetworkTransaction> trans(
- new HttpNetworkTransaction(session_));
- TestOldCompletionCallback callback;
- HttpRequestInfo request;
- request.method = "GET";
- request.url = GURL("http://www.google.com/");
- request.load_flags = 0;
- int rv = trans->Start(&request, &callback, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- }
-
- private:
- const scoped_refptr<HttpNetworkSession>& session_;
- NormalSpdyTransactionHelper& helper_;
-};
-
// Verify that the client can correctly deal with the user callback attempting
// to start another transaction on a session that is closing down. See
// http://crbug.com/47455
@@ -2350,15 +2356,17 @@ TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
- StartTransactionCallback callback2(helper.session(), helper);
const int kSize = 3000;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
- rv = trans->Read(buf, kSize, &callback2);
+ rv = trans->Read(
+ buf, kSize,
+ base::Bind(&SpdyNetworkTransactionTest::StartTransactionCallback,
+ helper.session()));
// This forces an err_IO_pending, which sets the callback.
data->CompleteRead();
// This finishes the read.
@@ -2366,21 +2374,6 @@ TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
helper.VerifyDataConsumed();
}
-class SpdyNetworkTransactionTest::DeleteSessionCallback
- : public CallbackRunner< Tuple1<int> > {
- public:
- explicit DeleteSessionCallback(NormalSpdyTransactionHelper& helper) :
- helper_(helper) {}
-
- // We kill the transaction, which deletes the session and stream.
- virtual void RunWithParams(const Tuple1<int>& params) {
- helper_.ResetTrans();
- }
-
- private:
- NormalSpdyTransactionHelper& helper_;
-};
-
// Verify that the client can correctly deal with the user callback deleting the
// transaction. Failures will usually be valgrind errors. See
// http://crbug.com/46925
@@ -2408,17 +2401,19 @@ TEST_P(SpdyNetworkTransactionTest, DeleteSessionOnReadCallback) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(&helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
// Setup a user callback which will delete the session, and clear out the
// memory holding the stream object. Note that the callback deletes trans.
- DeleteSessionCallback callback2(helper);
const int kSize = 3000;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSize));
- rv = trans->Read(buf, kSize, &callback2);
+ rv = trans->Read(
+ buf, kSize,
+ base::Bind(&SpdyNetworkTransactionTest::DeleteSessionCallback,
+ base::Unretained(&helper)));
ASSERT_EQ(ERR_IO_PENDING, rv);
data->CompleteRead();
@@ -2815,8 +2810,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushServerAborted) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -3069,8 +3065,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID0) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -3130,8 +3127,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushInvalidAssociatedStreamID9) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -3187,8 +3185,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushNoURL) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);
@@ -3778,14 +3777,15 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) {
writes, arraysize(writes)));
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
NormalSpdyTransactionHelper helper(CreateGetRequest(),
BoundNetLog(), GetParam());
helper.RunPreTestSetup();
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -3799,14 +3799,14 @@ TEST_P(SpdyNetworkTransactionTest, BufferFull) {
out.response_info = *response; // Make a copy so we can verify.
// Read Data
- TestOldCompletionCallback read_callback;
+ TestCompletionCallback read_callback;
std::string content;
do {
// Read small chunks at a time.
const int kSmallReadSize = 3;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
- rv = trans->Read(buf, kSmallReadSize, &read_callback);
+ rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
if (rv == net::ERR_IO_PENDING) {
data->CompleteRead();
rv = read_callback.WaitForResult();
@@ -3875,8 +3875,9 @@ TEST_P(SpdyNetworkTransactionTest, Buffering) {
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -3890,7 +3891,7 @@ TEST_P(SpdyNetworkTransactionTest, Buffering) {
out.response_info = *response; // Make a copy so we can verify.
// Read Data
- TestOldCompletionCallback read_callback;
+ TestCompletionCallback read_callback;
std::string content;
int reads_completed = 0;
@@ -3898,7 +3899,7 @@ TEST_P(SpdyNetworkTransactionTest, Buffering) {
// Read small chunks at a time.
const int kSmallReadSize = 14;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
- rv = trans->Read(buf, kSmallReadSize, &read_callback);
+ rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
if (rv == net::ERR_IO_PENDING) {
data->CompleteRead();
rv = read_callback.WaitForResult();
@@ -3970,8 +3971,9 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -3985,7 +3987,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
out.response_info = *response; // Make a copy so we can verify.
// Read Data
- TestOldCompletionCallback read_callback;
+ TestCompletionCallback read_callback;
std::string content;
int reads_completed = 0;
@@ -3993,7 +3995,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedAll) {
// Read small chunks at a time.
const int kSmallReadSize = 14;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
- rv = trans->Read(buf, kSmallReadSize, &read_callback);
+ rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
if (rv > 0) {
EXPECT_EQ(kSmallReadSize, rv);
content.append(buf->data(), rv);
@@ -4058,9 +4060,10 @@ TEST_P(SpdyNetworkTransactionTest, BufferedClosed) {
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4074,7 +4077,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedClosed) {
out.response_info = *response; // Make a copy so we can verify.
// Read Data
- TestOldCompletionCallback read_callback;
+ TestCompletionCallback read_callback;
std::string content;
int reads_completed = 0;
@@ -4082,7 +4085,7 @@ TEST_P(SpdyNetworkTransactionTest, BufferedClosed) {
// Read small chunks at a time.
const int kSmallReadSize = 14;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kSmallReadSize));
- rv = trans->Read(buf, kSmallReadSize, &read_callback);
+ rv = trans->Read(buf, kSmallReadSize, read_callback.callback());
if (rv == net::ERR_IO_PENDING) {
data->CompleteRead();
rv = read_callback.WaitForResult();
@@ -4137,9 +4140,10 @@ TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) {
helper.RunPreTestSetup();
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
TransactionHelperResult out = helper.output();
@@ -4153,12 +4157,12 @@ TEST_P(SpdyNetworkTransactionTest, BufferedCancelled) {
out.response_info = *response; // Make a copy so we can verify.
// Read Data
- TestOldCompletionCallback read_callback;
+ TestCompletionCallback read_callback;
do {
const int kReadSize = 256;
scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(kReadSize));
- rv = trans->Read(buf, kReadSize, &read_callback);
+ rv = trans->Read(buf, kReadSize, read_callback.callback());
if (rv == net::ERR_IO_PENDING) {
// Complete the read now, which causes buffering to start.
data->CompleteRead();
@@ -4449,9 +4453,9 @@ TEST_P(SpdyNetworkTransactionTest, CloseWithActiveStream) {
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
TransactionHelperResult out;
- out.rv = trans->Start(&CreateGetRequest(), &callback, log);
+ out.rv = trans->Start(&CreateGetRequest(), callback.callback(), log);
EXPECT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback.WaitForResult();
@@ -4542,9 +4546,10 @@ TEST_P(SpdyNetworkTransactionTest, ProxyConnect) {
}
helper.AddData(data.get());
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -4602,9 +4607,10 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
TransactionHelperResult out;
- out.rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ out.rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(out.rv, ERR_IO_PENDING);
out.rv = callback.WaitForResult();
@@ -4718,8 +4724,9 @@ TEST_P(SpdyNetworkTransactionTest, DirectConnectProxyReconnect) {
helper_proxy.AddData(data_proxy.get());
HttpNetworkTransaction* trans_proxy = helper_proxy.trans();
- TestOldCompletionCallback callback_proxy;
- int rv = trans_proxy->Start(&request_proxy, &callback_proxy, BoundNetLog());
+ TestCompletionCallback callback_proxy;
+ int rv = trans_proxy->Start(
+ &request_proxy, callback_proxy.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback_proxy.WaitForResult();
EXPECT_EQ(0, rv);
@@ -4786,8 +4793,9 @@ TEST_P(SpdyNetworkTransactionTest, VerifyRetryOnConnectionReset) {
scoped_ptr<HttpNetworkTransaction> trans(
new HttpNetworkTransaction(helper.session()));
- TestOldCompletionCallback callback;
- int rv = trans->Start(&helper.request(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &helper.request(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
// On the second transaction, we trigger the RST.
if (i == 1) {
@@ -4924,10 +4932,10 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
helper.RunPreTestSetup();
helper.AddData(data.get());
HttpNetworkTransaction* trans = helper.trans();
- TestOldCompletionCallback callback_start;
- const int rv_start = trans->Start(&request, &callback_start, net_log);
+ TestCompletionCallback callback;
+ const int rv_start = trans->Start(&request, callback.callback(), net_log);
EXPECT_EQ(ERR_IO_PENDING, rv_start);
- const int rv_start_complete = callback_start.WaitForResult();
+ const int rv_start_complete = callback.WaitForResult();
EXPECT_EQ(OK, rv_start_complete);
// Make sure the response has an auth challenge.
@@ -4944,8 +4952,9 @@ TEST_P(SpdyNetworkTransactionTest, SpdyBasicAuth) {
// Restart with a username/password.
AuthCredentials credentials(ASCIIToUTF16("foo"), ASCIIToUTF16("bar"));
- TestOldCompletionCallback callback_restart;
- const int rv_restart = trans->RestartWithAuth(credentials, &callback_restart);
+ TestCompletionCallback callback_restart;
+ const int rv_restart = trans->RestartWithAuth(
+ credentials, callback_restart.callback());
EXPECT_EQ(ERR_IO_PENDING, rv_restart);
const int rv_restart_complete = callback_restart.WaitForResult();
EXPECT_EQ(OK, rv_restart_complete);
@@ -5126,8 +5135,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
data->SetStop(3);
// Start the transaction.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->Run();
rv = callback.WaitForResult();
@@ -5137,7 +5147,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushClaimBeforeHeaders) {
// headers are not yet complete.
scoped_ptr<HttpNetworkTransaction> trans2(
new HttpNetworkTransaction(helper.session()));
- rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog());
+ rv = trans2->Start(
+ &CreateGetPushRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->RunFor(3);
MessageLoop::current()->RunAllPending();
@@ -5275,8 +5286,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
data->SetStop(4);
// Start the transaction.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->Run();
rv = callback.WaitForResult();
@@ -5286,7 +5298,8 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushWithTwoHeaderFrames) {
// headers are not yet complete.
scoped_ptr<HttpNetworkTransaction> trans2(
new HttpNetworkTransaction(helper.session()));
- rv = trans2->Start(&CreateGetPushRequest(), &callback, BoundNetLog());
+ rv = trans2->Start(
+ &CreateGetPushRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
data->RunFor(3);
MessageLoop::current()->RunAllPending();
@@ -5589,9 +5602,9 @@ TEST_P(SpdyNetworkTransactionTest, ServerPushCrossOriginCorrectness) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
+ TestCompletionCallback callback;
- int rv = trans->Start(&request, &callback, BoundNetLog());
+ int rv = trans->Start(&request, callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -5647,8 +5660,9 @@ TEST_P(SpdyNetworkTransactionTest, RetryAfterRefused) {
HttpNetworkTransaction* trans = helper.trans();
// Start the transaction with basic parameters.
- TestOldCompletionCallback callback;
- int rv = trans->Start(&CreateGetRequest(), &callback, BoundNetLog());
+ TestCompletionCallback callback;
+ int rv = trans->Start(
+ &CreateGetRequest(), callback.callback(), BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
EXPECT_EQ(OK, rv);

Powered by Google App Engine
This is Rietveld 408576698