| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <objbase.h> | 6 #include <objbase.h> |
| 7 #include <urlmon.h> | 7 #include <urlmon.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 void ConfigurableConnection::SendChunk() { | 320 void ConfigurableConnection::SendChunk() { |
| 321 int size = (int)data_.size(); | 321 int size = (int)data_.size(); |
| 322 const char* chunk_ptr = data_.c_str() + cur_pos_; | 322 const char* chunk_ptr = data_.c_str() + cur_pos_; |
| 323 int bytes_to_send = std::min(options_.chunk_size_, size - cur_pos_); | 323 int bytes_to_send = std::min(options_.chunk_size_, size - cur_pos_); |
| 324 | 324 |
| 325 socket_->Send(chunk_ptr, bytes_to_send); | 325 socket_->Send(chunk_ptr, bytes_to_send); |
| 326 DVLOG(1) << "Sent(" << cur_pos_ << "," << bytes_to_send << "): " | 326 VLOG(1) << "Sent(" << cur_pos_ << "," << bytes_to_send << "): " |
| 327 << base::StringPiece(chunk_ptr, bytes_to_send); | 327 << base::StringPiece(chunk_ptr, bytes_to_send); |
| 328 | 328 |
| 329 cur_pos_ += bytes_to_send; | 329 cur_pos_ += bytes_to_send; |
| 330 if (cur_pos_ < size) { | 330 if (cur_pos_ < size) { |
| 331 MessageLoop::current()->PostDelayedTask( | 331 MessageLoop::current()->PostDelayedTask( |
| 332 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), | 332 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), |
| 333 options_.timeout_); | 333 options_.timeout_); |
| 334 } else { | 334 } else { |
| 335 socket_ = 0; // close the connection. | 335 socket_ = 0; // close the connection. |
| 336 } | 336 } |
| 337 } | 337 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 359 socket_->Send(headers); | 359 socket_->Send(headers); |
| 360 socket_->Send(content_length_header, true); | 360 socket_->Send(content_length_header, true); |
| 361 socket_->Send(content); | 361 socket_->Send(content); |
| 362 socket_ = 0; // close the connection. | 362 socket_ = 0; // close the connection. |
| 363 return; | 363 return; |
| 364 } | 364 } |
| 365 | 365 |
| 366 if (options_.speed_ == SendOptions::IMMEDIATE_HEADERS_DELAYED_CONTENT) { | 366 if (options_.speed_ == SendOptions::IMMEDIATE_HEADERS_DELAYED_CONTENT) { |
| 367 socket_->Send(headers); | 367 socket_->Send(headers); |
| 368 socket_->Send(content_length_header, true); | 368 socket_->Send(content_length_header, true); |
| 369 DVLOG(1) << "Headers sent: " << headers << content_length_header; | 369 VLOG(1) << "Headers sent: " << headers << content_length_header; |
| 370 data_.append(content); | 370 data_.append(content); |
| 371 } | 371 } |
| 372 | 372 |
| 373 if (options_.speed_ == SendOptions::DELAYED) { | 373 if (options_.speed_ == SendOptions::DELAYED) { |
| 374 data_ = headers; | 374 data_ = headers; |
| 375 data_.append(content_length_header); | 375 data_.append(content_length_header); |
| 376 data_.append("\r\n"); | 376 data_.append("\r\n"); |
| 377 } | 377 } |
| 378 | 378 |
| 379 MessageLoop::current()->PostDelayedTask( | 379 MessageLoop::current()->PostDelayedTask( |
| 380 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), | 380 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), |
| 381 options.timeout_); | 381 options.timeout_); |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace test_server | 384 } // namespace test_server |
| OLD | NEW |