| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 NOTREACHED(); | 221 NOTREACHED(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 MockNetworkTransaction::MockNetworkTransaction( | 225 MockNetworkTransaction::MockNetworkTransaction( |
| 226 net::RequestPriority priority, | 226 net::RequestPriority priority, |
| 227 MockNetworkLayer* factory) | 227 MockNetworkLayer* factory) |
| 228 : weak_factory_(this), | 228 : weak_factory_(this), |
| 229 data_cursor_(0), | 229 data_cursor_(0), |
| 230 priority_(priority), | 230 priority_(priority), |
| 231 websocket_handshake_stream_factory_(NULL), |
| 231 transaction_factory_(factory->AsWeakPtr()), | 232 transaction_factory_(factory->AsWeakPtr()), |
| 232 socket_log_id_(net::NetLog::Source::kInvalidId) { | 233 socket_log_id_(net::NetLog::Source::kInvalidId) { |
| 233 } | 234 } |
| 234 | 235 |
| 235 MockNetworkTransaction::~MockNetworkTransaction() {} | 236 MockNetworkTransaction::~MockNetworkTransaction() {} |
| 236 | 237 |
| 237 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request, | 238 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request, |
| 238 const net::CompletionCallback& callback, | 239 const net::CompletionCallback& callback, |
| 239 const net::BoundNetLog& net_log) { | 240 const net::BoundNetLog& net_log) { |
| 240 const MockTransaction* t = FindMockTransaction(request->url); | 241 const MockTransaction* t = FindMockTransaction(request->url); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 load_timing_info->send_start = base::TimeTicks::Now(); | 369 load_timing_info->send_start = base::TimeTicks::Now(); |
| 369 load_timing_info->send_end = base::TimeTicks::Now(); | 370 load_timing_info->send_end = base::TimeTicks::Now(); |
| 370 } | 371 } |
| 371 return true; | 372 return true; |
| 372 } | 373 } |
| 373 | 374 |
| 374 void MockNetworkTransaction::SetPriority(net::RequestPriority priority) { | 375 void MockNetworkTransaction::SetPriority(net::RequestPriority priority) { |
| 375 priority_ = priority; | 376 priority_ = priority; |
| 376 } | 377 } |
| 377 | 378 |
| 379 void MockNetworkTransaction::SetWebSocketHandshakeStreamFactory( |
| 380 net::WebSocketHandshakeStreamBase::Factory* factory) { |
| 381 websocket_handshake_stream_factory_ = factory; |
| 382 } |
| 383 |
| 378 void MockNetworkTransaction::CallbackLater( | 384 void MockNetworkTransaction::CallbackLater( |
| 379 const net::CompletionCallback& callback, int result) { | 385 const net::CompletionCallback& callback, int result) { |
| 380 base::MessageLoop::current()->PostTask( | 386 base::MessageLoop::current()->PostTask( |
| 381 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback, | 387 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback, |
| 382 weak_factory_.GetWeakPtr(), callback, result)); | 388 weak_factory_.GetWeakPtr(), callback, result)); |
| 383 } | 389 } |
| 384 | 390 |
| 385 void MockNetworkTransaction::RunCallback( | 391 void MockNetworkTransaction::RunCallback( |
| 386 const net::CompletionCallback& callback, int result) { | 392 const net::CompletionCallback& callback, int result) { |
| 387 callback.Run(result); | 393 callback.Run(result); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 442 |
| 437 if (rv > 0) | 443 if (rv > 0) |
| 438 content.append(buf->data(), rv); | 444 content.append(buf->data(), rv); |
| 439 else if (rv < 0) | 445 else if (rv < 0) |
| 440 return rv; | 446 return rv; |
| 441 } while (rv > 0); | 447 } while (rv > 0); |
| 442 | 448 |
| 443 result->swap(content); | 449 result->swap(content); |
| 444 return net::OK; | 450 return net::OK; |
| 445 } | 451 } |
| OLD | NEW |