OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 5 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
7 | 7 |
8 #include "net/http/http_transaction.h" | 8 #include "net/http/http_transaction.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 explicit TestTransactionConsumer(net::HttpTransactionFactory* factory) | 101 explicit TestTransactionConsumer(net::HttpTransactionFactory* factory) |
102 : state_(IDLE), | 102 : state_(IDLE), |
103 trans_(factory->CreateTransaction()), | 103 trans_(factory->CreateTransaction()), |
104 error_(net::OK) { | 104 error_(net::OK) { |
105 ++quit_counter_; | 105 ++quit_counter_; |
106 } | 106 } |
107 | 107 |
108 ~TestTransactionConsumer() { | 108 ~TestTransactionConsumer() { |
109 } | 109 } |
110 | 110 |
111 void Start(const net::HttpRequestInfo* request) { | 111 void Start(net::LoadLog* load_log, const net::HttpRequestInfo* request) { |
112 state_ = STARTING; | 112 state_ = STARTING; |
113 int result = trans_->Start(request, this); | 113 int result = trans_->Start(load_log, request, this); |
114 if (result != net::ERR_IO_PENDING) | 114 if (result != net::ERR_IO_PENDING) |
115 DidStart(result); | 115 DidStart(result); |
116 } | 116 } |
117 | 117 |
118 bool is_done() const { return state_ == DONE; } | 118 bool is_done() const { return state_ == DONE; } |
119 int error() const { return error_; } | 119 int error() const { return error_; } |
120 | 120 |
121 const net::HttpResponseInfo* response_info() const { | 121 const net::HttpResponseInfo* response_info() const { |
122 return trans_->GetResponseInfo(); | 122 return trans_->GetResponseInfo(); |
123 } | 123 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // This transaction class inspects the available set of mock transactions to | 192 // This transaction class inspects the available set of mock transactions to |
193 // find data for the request URL. It supports IO operations that complete | 193 // find data for the request URL. It supports IO operations that complete |
194 // synchronously or asynchronously to help exercise different code paths in the | 194 // synchronously or asynchronously to help exercise different code paths in the |
195 // HttpCache implementation. | 195 // HttpCache implementation. |
196 class MockNetworkTransaction : public net::HttpTransaction { | 196 class MockNetworkTransaction : public net::HttpTransaction { |
197 public: | 197 public: |
198 MockNetworkTransaction() : | 198 MockNetworkTransaction() : |
199 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) { | 199 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), data_cursor_(0) { |
200 } | 200 } |
201 | 201 |
202 virtual int Start(const net::HttpRequestInfo* request, | 202 virtual int Start(net::LoadLog* load_log, |
| 203 const net::HttpRequestInfo* request, |
203 net::CompletionCallback* callback) { | 204 net::CompletionCallback* callback) { |
204 const MockTransaction* t = FindMockTransaction(request->url); | 205 const MockTransaction* t = FindMockTransaction(request->url); |
205 if (!t) | 206 if (!t) |
206 return net::ERR_FAILED; | 207 return net::ERR_FAILED; |
207 | 208 |
208 std::string resp_status = t->status; | 209 std::string resp_status = t->status; |
209 std::string resp_headers = t->response_headers; | 210 std::string resp_headers = t->response_headers; |
210 std::string resp_data = t->data; | 211 std::string resp_data = t->data; |
211 if (t->handler) | 212 if (t->handler) |
212 (t->handler)(request, &resp_status, &resp_headers, &resp_data); | 213 (t->handler)(request, &resp_status, &resp_headers, &resp_data); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 }; | 317 }; |
317 | 318 |
318 | 319 |
319 //----------------------------------------------------------------------------- | 320 //----------------------------------------------------------------------------- |
320 // helpers | 321 // helpers |
321 | 322 |
322 // read the transaction completely | 323 // read the transaction completely |
323 int ReadTransaction(net::HttpTransaction* trans, std::string* result); | 324 int ReadTransaction(net::HttpTransaction* trans, std::string* result); |
324 | 325 |
325 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 326 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
OLD | NEW |