| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_transaction_unittest.h" | 5 #include "net/http/http_transaction_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 332 } |
| 333 | 333 |
| 334 net::HttpCache* MockNetworkLayer::GetCache() { | 334 net::HttpCache* MockNetworkLayer::GetCache() { |
| 335 return NULL; | 335 return NULL; |
| 336 } | 336 } |
| 337 | 337 |
| 338 net::HttpNetworkSession* MockNetworkLayer::GetSession() { | 338 net::HttpNetworkSession* MockNetworkLayer::GetSession() { |
| 339 return NULL; | 339 return NULL; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void MockNetworkLayer::Suspend(bool suspend) {} | |
| 343 | |
| 344 //----------------------------------------------------------------------------- | 342 //----------------------------------------------------------------------------- |
| 345 // helpers | 343 // helpers |
| 346 | 344 |
| 347 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { | 345 int ReadTransaction(net::HttpTransaction* trans, std::string* result) { |
| 348 int rv; | 346 int rv; |
| 349 | 347 |
| 350 TestCompletionCallback callback; | 348 TestCompletionCallback callback; |
| 351 | 349 |
| 352 std::string content; | 350 std::string content; |
| 353 do { | 351 do { |
| 354 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); | 352 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(256)); |
| 355 rv = trans->Read(buf, 256, &callback); | 353 rv = trans->Read(buf, 256, &callback); |
| 356 if (rv == net::ERR_IO_PENDING) | 354 if (rv == net::ERR_IO_PENDING) |
| 357 rv = callback.WaitForResult(); | 355 rv = callback.WaitForResult(); |
| 358 if (rv > 0) { | 356 if (rv > 0) { |
| 359 content.append(buf->data(), rv); | 357 content.append(buf->data(), rv); |
| 360 } else if (rv < 0) { | 358 } else if (rv < 0) { |
| 361 return rv; | 359 return rv; |
| 362 } | 360 } |
| 363 } while (rv > 0); | 361 } while (rv > 0); |
| 364 | 362 |
| 365 result->swap(content); | 363 result->swap(content); |
| 366 return net::OK; | 364 return net::OK; |
| 367 } | 365 } |
| OLD | NEW |