OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_test_util.h" | 5 #include "net/http/http_transaction_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 } | 204 } |
205 | 205 |
206 void TestTransactionConsumer::DidFinish(int result) { | 206 void TestTransactionConsumer::DidFinish(int result) { |
207 state_ = DONE; | 207 state_ = DONE; |
208 error_ = result; | 208 error_ = result; |
209 if (--quit_counter_ == 0) | 209 if (--quit_counter_ == 0) |
210 base::MessageLoop::current()->QuitWhenIdle(); | 210 base::MessageLoop::current()->QuitWhenIdle(); |
211 } | 211 } |
212 | 212 |
213 void TestTransactionConsumer::Read() { | 213 void TestTransactionConsumer::Read() { |
214 CHECK(!done_reading_called_); | |
xunjieli
2015/11/23 15:37:56
I can't add CHECK(!done_reading_called_) here, bec
mmenke
2015/11/23 16:06:02
Sorry, I meant in MockNetworkTransaction::Read.
xunjieli
2015/11/23 16:15:58
Sorry, I meant to say it is a member of MockNetwor
| |
214 state_ = READING; | 215 state_ = READING; |
215 read_buf_ = new IOBuffer(1024); | 216 read_buf_ = new IOBuffer(1024); |
216 int result = trans_->Read(read_buf_.get(), | 217 int result = trans_->Read(read_buf_.get(), |
217 1024, | 218 1024, |
218 base::Bind(&TestTransactionConsumer::OnIOComplete, | 219 base::Bind(&TestTransactionConsumer::OnIOComplete, |
219 base::Unretained(this))); | 220 base::Unretained(this))); |
220 if (result != ERR_IO_PENDING) | 221 if (result != ERR_IO_PENDING) |
221 DidRead(result); | 222 DidRead(result); |
222 } | 223 } |
223 | 224 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 : transaction_count_(0), | 500 : transaction_count_(0), |
500 done_reading_called_(false), | 501 done_reading_called_(false), |
501 stop_caching_called_(false), | 502 stop_caching_called_(false), |
502 last_create_transaction_priority_(DEFAULT_PRIORITY), | 503 last_create_transaction_priority_(DEFAULT_PRIORITY), |
503 clock_(nullptr) { | 504 clock_(nullptr) { |
504 } | 505 } |
505 | 506 |
506 MockNetworkLayer::~MockNetworkLayer() {} | 507 MockNetworkLayer::~MockNetworkLayer() {} |
507 | 508 |
508 void MockNetworkLayer::TransactionDoneReading() { | 509 void MockNetworkLayer::TransactionDoneReading() { |
510 CHECK(!done_reading_called_); | |
509 done_reading_called_ = true; | 511 done_reading_called_ = true; |
510 } | 512 } |
511 | 513 |
512 void MockNetworkLayer::TransactionStopCaching() { | 514 void MockNetworkLayer::TransactionStopCaching() { |
513 stop_caching_called_ = true; | 515 stop_caching_called_ = true; |
514 } | 516 } |
515 | 517 |
516 int MockNetworkLayer::CreateTransaction(RequestPriority priority, | 518 int MockNetworkLayer::CreateTransaction(RequestPriority priority, |
517 scoped_ptr<HttpTransaction>* trans) { | 519 scoped_ptr<HttpTransaction>* trans) { |
518 transaction_count_++; | 520 transaction_count_++; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 content.append(buf->data(), rv); | 564 content.append(buf->data(), rv); |
563 else if (rv < 0) | 565 else if (rv < 0) |
564 return rv; | 566 return rv; |
565 } while (rv > 0); | 567 } while (rv > 0); |
566 | 568 |
567 result->swap(content); | 569 result->swap(content); |
568 return OK; | 570 return OK; |
569 } | 571 } |
570 | 572 |
571 } // namespace net | 573 } // namespace net |
OLD | NEW |