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

Side by Side Diff: net/http/http_transaction_test_util.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 #include <unordered_map> 8 #include <unordered_map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 : state_(IDLE), error_(OK) { 156 : state_(IDLE), error_(OK) {
157 // Disregard the error code. 157 // Disregard the error code.
158 factory->CreateTransaction(priority, &trans_); 158 factory->CreateTransaction(priority, &trans_);
159 ++quit_counter_; 159 ++quit_counter_;
160 } 160 }
161 161
162 TestTransactionConsumer::~TestTransactionConsumer() { 162 TestTransactionConsumer::~TestTransactionConsumer() {
163 } 163 }
164 164
165 void TestTransactionConsumer::Start(const HttpRequestInfo* request, 165 void TestTransactionConsumer::Start(const HttpRequestInfo* request,
166 const BoundNetLog& net_log) { 166 const NetLogWithSource& net_log) {
167 state_ = STARTING; 167 state_ = STARTING;
168 int result = trans_->Start( 168 int result = trans_->Start(
169 request, base::Bind(&TestTransactionConsumer::OnIOComplete, 169 request, base::Bind(&TestTransactionConsumer::OnIOComplete,
170 base::Unretained(this)), net_log); 170 base::Unretained(this)), net_log);
171 if (result != ERR_IO_PENDING) 171 if (result != ERR_IO_PENDING)
172 DidStart(result); 172 DidStart(result);
173 } 173 }
174 174
175 void TestTransactionConsumer::DidStart(int result) { 175 void TestTransactionConsumer::DidStart(int result) {
176 if (result != OK) { 176 if (result != OK) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 received_bytes_(0), 232 received_bytes_(0),
233 sent_bytes_(0), 233 sent_bytes_(0),
234 socket_log_id_(NetLog::Source::kInvalidId), 234 socket_log_id_(NetLog::Source::kInvalidId),
235 done_reading_called_(false), 235 done_reading_called_(false),
236 weak_factory_(this) {} 236 weak_factory_(this) {}
237 237
238 MockNetworkTransaction::~MockNetworkTransaction() {} 238 MockNetworkTransaction::~MockNetworkTransaction() {}
239 239
240 int MockNetworkTransaction::Start(const HttpRequestInfo* request, 240 int MockNetworkTransaction::Start(const HttpRequestInfo* request,
241 const CompletionCallback& callback, 241 const CompletionCallback& callback,
242 const BoundNetLog& net_log) { 242 const NetLogWithSource& net_log) {
243 if (request_) 243 if (request_)
244 return ERR_FAILED; 244 return ERR_FAILED;
245 245
246 request_ = request; 246 request_ = request;
247 return StartInternal(request, callback, net_log); 247 return StartInternal(request, callback, net_log);
248 } 248 }
249 249
250 int MockNetworkTransaction::RestartIgnoringLastError( 250 int MockNetworkTransaction::RestartIgnoringLastError(
251 const CompletionCallback& callback) { 251 const CompletionCallback& callback) {
252 return ERR_FAILED; 252 return ERR_FAILED;
(...skipping 11 matching lines...) Expand all
264 const CompletionCallback& callback) { 264 const CompletionCallback& callback) {
265 if (!IsReadyToRestartForAuth()) 265 if (!IsReadyToRestartForAuth())
266 return ERR_FAILED; 266 return ERR_FAILED;
267 267
268 HttpRequestInfo auth_request_info = *request_; 268 HttpRequestInfo auth_request_info = *request_;
269 auth_request_info.extra_headers.SetHeader("Authorization", "Bar"); 269 auth_request_info.extra_headers.SetHeader("Authorization", "Bar");
270 270
271 // Let the MockTransactionHandler worry about this: the only way for this 271 // Let the MockTransactionHandler worry about this: the only way for this
272 // test to succeed is by using an explicit handler for the transaction so 272 // test to succeed is by using an explicit handler for the transaction so
273 // that server behavior can be simulated. 273 // that server behavior can be simulated.
274 return StartInternal(&auth_request_info, callback, BoundNetLog()); 274 return StartInternal(&auth_request_info, callback, NetLogWithSource());
275 } 275 }
276 276
277 void MockNetworkTransaction::PopulateNetErrorDetails( 277 void MockNetworkTransaction::PopulateNetErrorDetails(
278 NetErrorDetails* /*details*/) const { 278 NetErrorDetails* /*details*/) const {
279 NOTIMPLEMENTED(); 279 NOTIMPLEMENTED();
280 } 280 }
281 281
282 bool MockNetworkTransaction::IsReadyToRestartForAuth() { 282 bool MockNetworkTransaction::IsReadyToRestartForAuth() {
283 if (!request_) 283 if (!request_)
284 return false; 284 return false;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 // static 395 // static
396 const int64_t MockNetworkTransaction::kTotalReceivedBytes = 1000; 396 const int64_t MockNetworkTransaction::kTotalReceivedBytes = 1000;
397 397
398 // static 398 // static
399 const int64_t MockNetworkTransaction::kTotalSentBytes = 100; 399 const int64_t MockNetworkTransaction::kTotalSentBytes = 100;
400 400
401 int MockNetworkTransaction::StartInternal(const HttpRequestInfo* request, 401 int MockNetworkTransaction::StartInternal(const HttpRequestInfo* request,
402 const CompletionCallback& callback, 402 const CompletionCallback& callback,
403 const BoundNetLog& net_log) { 403 const NetLogWithSource& net_log) {
404 const MockTransaction* t = FindMockTransaction(request->url); 404 const MockTransaction* t = FindMockTransaction(request->url);
405 if (!t) 405 if (!t)
406 return ERR_FAILED; 406 return ERR_FAILED;
407 407
408 if (!before_network_start_callback_.is_null()) { 408 if (!before_network_start_callback_.is_null()) {
409 bool defer = false; 409 bool defer = false;
410 before_network_start_callback_.Run(&defer); 410 before_network_start_callback_.Run(&defer);
411 if (defer) 411 if (defer)
412 return net::ERR_IO_PENDING; 412 return net::ERR_IO_PENDING;
413 } 413 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 content.append(buf->data(), rv); 572 content.append(buf->data(), rv);
573 else if (rv < 0) 573 else if (rv < 0)
574 return rv; 574 return rv;
575 } while (rv > 0); 575 } while (rv > 0);
576 576
577 result->swap(content); 577 result->swap(content);
578 return OK; 578 return OK;
579 } 579 }
580 580
581 } // namespace net 581 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698