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

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

Issue 11778016: net: Stop using base::WorkerPool from UploadFileElementReader (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: _ Created 7 years, 11 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 (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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 6513 matching lines...) Expand 10 before | Expand all | Expand 10 after
6524 6524
6525 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { 6525 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) {
6526 FilePath temp_file_path; 6526 FilePath temp_file_path;
6527 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); 6527 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path));
6528 const uint64 kFakeSize = 100000; // file is actually blank 6528 const uint64 kFakeSize = 100000; // file is actually blank
6529 UploadFileElementReader::ScopedOverridingContentLengthForTests 6529 UploadFileElementReader::ScopedOverridingContentLengthForTests
6530 overriding_content_length(kFakeSize); 6530 overriding_content_length(kFakeSize);
6531 6531
6532 ScopedVector<UploadElementReader> element_readers; 6532 ScopedVector<UploadElementReader> element_readers;
6533 element_readers.push_back( 6533 element_readers.push_back(
6534 new UploadFileElementReader(temp_file_path, 0, kuint64max, base::Time())); 6534 new UploadFileElementReader(base::MessageLoopProxy::current(),
6535 temp_file_path, 0, kuint64max, base::Time()));
6535 UploadDataStream upload_data_stream(&element_readers, 0); 6536 UploadDataStream upload_data_stream(&element_readers, 0);
6536 6537
6537 HttpRequestInfo request; 6538 HttpRequestInfo request;
6538 request.method = "POST"; 6539 request.method = "POST";
6539 request.url = GURL("http://www.google.com/upload"); 6540 request.url = GURL("http://www.google.com/upload");
6540 request.upload_data_stream = &upload_data_stream; 6541 request.upload_data_stream = &upload_data_stream;
6541 request.load_flags = 0; 6542 request.load_flags = 0;
6542 6543
6543 SpdySessionDependencies session_deps; 6544 SpdySessionDependencies session_deps;
6544 scoped_ptr<HttpTransaction> trans( 6545 scoped_ptr<HttpTransaction> trans(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6577 TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) { 6578 TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) {
6578 FilePath temp_file; 6579 FilePath temp_file;
6579 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); 6580 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file));
6580 std::string temp_file_content("Unreadable file."); 6581 std::string temp_file_content("Unreadable file.");
6581 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), 6582 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(),
6582 temp_file_content.length())); 6583 temp_file_content.length()));
6583 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); 6584 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file));
6584 6585
6585 ScopedVector<UploadElementReader> element_readers; 6586 ScopedVector<UploadElementReader> element_readers;
6586 element_readers.push_back( 6587 element_readers.push_back(
6587 new UploadFileElementReader(temp_file, 0, kuint64max, base::Time())); 6588 new UploadFileElementReader(base::MessageLoopProxy::current(),
6589 temp_file, 0, kuint64max, base::Time()));
6588 UploadDataStream upload_data_stream(&element_readers, 0); 6590 UploadDataStream upload_data_stream(&element_readers, 0);
6589 6591
6590 HttpRequestInfo request; 6592 HttpRequestInfo request;
6591 request.method = "POST"; 6593 request.method = "POST";
6592 request.url = GURL("http://www.google.com/upload"); 6594 request.url = GURL("http://www.google.com/upload");
6593 request.upload_data_stream = &upload_data_stream; 6595 request.upload_data_stream = &upload_data_stream;
6594 request.load_flags = 0; 6596 request.load_flags = 0;
6595 6597
6596 // If we try to upload an unreadable file, the network stack should report 6598 // If we try to upload an unreadable file, the network stack should report
6597 // the file size as zero and upload zero bytes for that file. 6599 // the file size as zero and upload zero bytes for that file.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6633 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { 6635 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) {
6634 FilePath temp_file; 6636 FilePath temp_file;
6635 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); 6637 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file));
6636 std::string temp_file_contents("Unreadable file."); 6638 std::string temp_file_contents("Unreadable file.");
6637 std::string unreadable_contents(temp_file_contents.length(), '\0'); 6639 std::string unreadable_contents(temp_file_contents.length(), '\0');
6638 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), 6640 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(),
6639 temp_file_contents.length())); 6641 temp_file_contents.length()));
6640 6642
6641 ScopedVector<UploadElementReader> element_readers; 6643 ScopedVector<UploadElementReader> element_readers;
6642 element_readers.push_back( 6644 element_readers.push_back(
6643 new UploadFileElementReader(temp_file, 0, kuint64max, base::Time())); 6645 new UploadFileElementReader(base::MessageLoopProxy::current(),
6646 temp_file, 0, kuint64max, base::Time()));
6644 UploadDataStream upload_data_stream(&element_readers, 0); 6647 UploadDataStream upload_data_stream(&element_readers, 0);
6645 6648
6646 HttpRequestInfo request; 6649 HttpRequestInfo request;
6647 request.method = "POST"; 6650 request.method = "POST";
6648 request.url = GURL("http://www.google.com/upload"); 6651 request.url = GURL("http://www.google.com/upload");
6649 request.upload_data_stream = &upload_data_stream; 6652 request.upload_data_stream = &upload_data_stream;
6650 request.load_flags = 0; 6653 request.load_flags = 0;
6651 6654
6652 SpdySessionDependencies session_deps; 6655 SpdySessionDependencies session_deps;
6653 scoped_ptr<HttpTransaction> trans( 6656 scoped_ptr<HttpTransaction> trans(
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after
10179 trans2.Start(&request2, callback2.callback(), BoundNetLog())); 10182 trans2.Start(&request2, callback2.callback(), BoundNetLog()));
10180 MessageLoop::current()->RunUntilIdle(); 10183 MessageLoop::current()->RunUntilIdle();
10181 data2->RunFor(3); 10184 data2->RunFor(3);
10182 10185
10183 ASSERT_TRUE(callback2.have_result()); 10186 ASSERT_TRUE(callback2.have_result());
10184 EXPECT_EQ(OK, callback2.WaitForResult()); 10187 EXPECT_EQ(OK, callback2.WaitForResult());
10185 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); 10188 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy);
10186 } 10189 }
10187 10190
10188 } // namespace net 10191 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698