| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 google_post_request_.url = GURL(kDefaultURL); | 431 google_post_request_.url = GURL(kDefaultURL); |
| 432 google_post_request_.upload_data_stream = upload_data_stream_.get(); | 432 google_post_request_.upload_data_stream = upload_data_stream_.get(); |
| 433 google_post_request_initialized_ = true; | 433 google_post_request_initialized_ = true; |
| 434 } | 434 } |
| 435 return google_post_request_; | 435 return google_post_request_; |
| 436 } | 436 } |
| 437 | 437 |
| 438 const HttpRequestInfo& CreateFilePostRequest() { | 438 const HttpRequestInfo& CreateFilePostRequest() { |
| 439 if (!google_post_request_initialized_) { | 439 if (!google_post_request_initialized_) { |
| 440 base::FilePath file_path; | 440 base::FilePath file_path; |
| 441 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); | 441 CHECK(base::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); |
| 442 CHECK_EQ(static_cast<int>(kUploadDataSize), | 442 CHECK_EQ(static_cast<int>(kUploadDataSize), |
| 443 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); | 443 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); |
| 444 | 444 |
| 445 ScopedVector<UploadElementReader> element_readers; | 445 ScopedVector<UploadElementReader> element_readers; |
| 446 element_readers.push_back( | 446 element_readers.push_back( |
| 447 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 447 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 448 file_path, | 448 file_path, |
| 449 0, | 449 0, |
| 450 kUploadDataSize, | 450 kUploadDataSize, |
| 451 base::Time())); | 451 base::Time())); |
| 452 upload_data_stream_.reset( | 452 upload_data_stream_.reset( |
| 453 new UploadDataStream(element_readers.Pass(), 0)); | 453 new UploadDataStream(element_readers.Pass(), 0)); |
| 454 | 454 |
| 455 google_post_request_.method = "POST"; | 455 google_post_request_.method = "POST"; |
| 456 google_post_request_.url = GURL(kDefaultURL); | 456 google_post_request_.url = GURL(kDefaultURL); |
| 457 google_post_request_.upload_data_stream = upload_data_stream_.get(); | 457 google_post_request_.upload_data_stream = upload_data_stream_.get(); |
| 458 google_post_request_initialized_ = true; | 458 google_post_request_initialized_ = true; |
| 459 } | 459 } |
| 460 return google_post_request_; | 460 return google_post_request_; |
| 461 } | 461 } |
| 462 | 462 |
| 463 const HttpRequestInfo& CreateUnreadableFilePostRequest() { | 463 const HttpRequestInfo& CreateUnreadableFilePostRequest() { |
| 464 if (google_post_request_initialized_) | 464 if (google_post_request_initialized_) |
| 465 return google_post_request_; | 465 return google_post_request_; |
| 466 | 466 |
| 467 base::FilePath file_path; | 467 base::FilePath file_path; |
| 468 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); | 468 CHECK(base::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); |
| 469 CHECK_EQ(static_cast<int>(kUploadDataSize), | 469 CHECK_EQ(static_cast<int>(kUploadDataSize), |
| 470 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); | 470 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); |
| 471 CHECK(file_util::MakeFileUnreadable(file_path)); | 471 CHECK(file_util::MakeFileUnreadable(file_path)); |
| 472 | 472 |
| 473 ScopedVector<UploadElementReader> element_readers; | 473 ScopedVector<UploadElementReader> element_readers; |
| 474 element_readers.push_back( | 474 element_readers.push_back( |
| 475 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 475 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 476 file_path, | 476 file_path, |
| 477 0, | 477 0, |
| 478 kUploadDataSize, | 478 kUploadDataSize, |
| 479 base::Time())); | 479 base::Time())); |
| 480 upload_data_stream_.reset( | 480 upload_data_stream_.reset( |
| 481 new UploadDataStream(element_readers.Pass(), 0)); | 481 new UploadDataStream(element_readers.Pass(), 0)); |
| 482 | 482 |
| 483 google_post_request_.method = "POST"; | 483 google_post_request_.method = "POST"; |
| 484 google_post_request_.url = GURL(kDefaultURL); | 484 google_post_request_.url = GURL(kDefaultURL); |
| 485 google_post_request_.upload_data_stream = upload_data_stream_.get(); | 485 google_post_request_.upload_data_stream = upload_data_stream_.get(); |
| 486 google_post_request_initialized_ = true; | 486 google_post_request_initialized_ = true; |
| 487 return google_post_request_; | 487 return google_post_request_; |
| 488 } | 488 } |
| 489 | 489 |
| 490 const HttpRequestInfo& CreateComplexPostRequest() { | 490 const HttpRequestInfo& CreateComplexPostRequest() { |
| 491 if (!google_post_request_initialized_) { | 491 if (!google_post_request_initialized_) { |
| 492 const int kFileRangeOffset = 1; | 492 const int kFileRangeOffset = 1; |
| 493 const int kFileRangeLength = 3; | 493 const int kFileRangeLength = 3; |
| 494 CHECK_LT(kFileRangeOffset + kFileRangeLength, kUploadDataSize); | 494 CHECK_LT(kFileRangeOffset + kFileRangeLength, kUploadDataSize); |
| 495 | 495 |
| 496 base::FilePath file_path; | 496 base::FilePath file_path; |
| 497 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); | 497 CHECK(base::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); |
| 498 CHECK_EQ(static_cast<int>(kUploadDataSize), | 498 CHECK_EQ(static_cast<int>(kUploadDataSize), |
| 499 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); | 499 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); |
| 500 | 500 |
| 501 ScopedVector<UploadElementReader> element_readers; | 501 ScopedVector<UploadElementReader> element_readers; |
| 502 element_readers.push_back( | 502 element_readers.push_back( |
| 503 new UploadBytesElementReader(kUploadData, kFileRangeOffset)); | 503 new UploadBytesElementReader(kUploadData, kFileRangeOffset)); |
| 504 element_readers.push_back( | 504 element_readers.push_back( |
| 505 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 505 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 506 file_path, | 506 file_path, |
| 507 kFileRangeOffset, | 507 kFileRangeOffset, |
| (...skipping 5958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6466 // since we're send-stalled. | 6466 // since we're send-stalled. |
| 6467 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); | 6467 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); |
| 6468 | 6468 |
| 6469 // Read in WINDOW_UPDATE or SETTINGS frame. | 6469 // Read in WINDOW_UPDATE or SETTINGS frame. |
| 6470 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); | 6470 data.RunFor((GetParam().protocol >= kProtoSPDY31) ? 8 : 7); |
| 6471 rv = callback.WaitForResult(); | 6471 rv = callback.WaitForResult(); |
| 6472 helper.VerifyDataConsumed(); | 6472 helper.VerifyDataConsumed(); |
| 6473 } | 6473 } |
| 6474 | 6474 |
| 6475 } // namespace net | 6475 } // namespace net |
| OLD | NEW |