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

Side by Side Diff: net/spdy/spdy_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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 const HttpRequestInfo& CreateFilePostRequest() { 384 const HttpRequestInfo& CreateFilePostRequest() {
385 if (!google_post_request_initialized_) { 385 if (!google_post_request_initialized_) {
386 FilePath file_path; 386 FilePath file_path;
387 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); 387 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path));
388 CHECK_EQ(static_cast<int>(kUploadDataSize), 388 CHECK_EQ(static_cast<int>(kUploadDataSize),
389 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); 389 file_util::WriteFile(file_path, kUploadData, kUploadDataSize));
390 390
391 ScopedVector<UploadElementReader> element_readers; 391 ScopedVector<UploadElementReader> element_readers;
392 element_readers.push_back(new UploadFileElementReader( 392 element_readers.push_back(new UploadFileElementReader(
393 base::MessageLoopProxy::current(),
393 file_path, 0, kUploadDataSize, base::Time())); 394 file_path, 0, kUploadDataSize, base::Time()));
394 upload_data_stream_.reset(new UploadDataStream(&element_readers, 0)); 395 upload_data_stream_.reset(new UploadDataStream(&element_readers, 0));
395 396
396 google_post_request_.method = "POST"; 397 google_post_request_.method = "POST";
397 google_post_request_.url = GURL(kDefaultURL); 398 google_post_request_.url = GURL(kDefaultURL);
398 google_post_request_.upload_data_stream = upload_data_stream_.get(); 399 google_post_request_.upload_data_stream = upload_data_stream_.get();
399 google_post_request_initialized_ = true; 400 google_post_request_initialized_ = true;
400 } 401 }
401 return google_post_request_; 402 return google_post_request_;
402 } 403 }
403 404
404 const HttpRequestInfo& CreateComplexPostRequest() { 405 const HttpRequestInfo& CreateComplexPostRequest() {
405 if (!google_post_request_initialized_) { 406 if (!google_post_request_initialized_) {
406 const int kFileRangeOffset = 1; 407 const int kFileRangeOffset = 1;
407 const int kFileRangeLength = 3; 408 const int kFileRangeLength = 3;
408 CHECK_LT(kFileRangeOffset + kFileRangeLength, kUploadDataSize); 409 CHECK_LT(kFileRangeOffset + kFileRangeLength, kUploadDataSize);
409 410
410 FilePath file_path; 411 FilePath file_path;
411 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); 412 CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path));
412 CHECK_EQ(static_cast<int>(kUploadDataSize), 413 CHECK_EQ(static_cast<int>(kUploadDataSize),
413 file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); 414 file_util::WriteFile(file_path, kUploadData, kUploadDataSize));
414 415
415 ScopedVector<UploadElementReader> element_readers; 416 ScopedVector<UploadElementReader> element_readers;
416 element_readers.push_back( 417 element_readers.push_back(
417 new UploadBytesElementReader(kUploadData, kFileRangeOffset)); 418 new UploadBytesElementReader(kUploadData, kFileRangeOffset));
418 element_readers.push_back(new UploadFileElementReader( 419 element_readers.push_back(new UploadFileElementReader(
420 base::MessageLoopProxy::current(),
419 file_path, kFileRangeOffset, kFileRangeLength, base::Time())); 421 file_path, kFileRangeOffset, kFileRangeLength, base::Time()));
420 element_readers.push_back(new UploadBytesElementReader( 422 element_readers.push_back(new UploadBytesElementReader(
421 kUploadData + kFileRangeOffset + kFileRangeLength, 423 kUploadData + kFileRangeOffset + kFileRangeLength,
422 kUploadDataSize - (kFileRangeOffset + kFileRangeLength))); 424 kUploadDataSize - (kFileRangeOffset + kFileRangeLength)));
423 upload_data_stream_.reset(new UploadDataStream(&element_readers, 0)); 425 upload_data_stream_.reset(new UploadDataStream(&element_readers, 0));
424 426
425 google_post_request_.method = "POST"; 427 google_post_request_.method = "POST";
426 google_post_request_.url = GURL(kDefaultURL); 428 google_post_request_.url = GURL(kDefaultURL);
427 google_post_request_.upload_data_stream = upload_data_stream_.get(); 429 google_post_request_.upload_data_stream = upload_data_stream_.get();
428 google_post_request_initialized_ = true; 430 google_post_request_initialized_ = true;
(...skipping 5342 matching lines...) Expand 10 before | Expand all | Expand 10 after
5771 // And now we can allow everything else to run to completion. 5773 // And now we can allow everything else to run to completion.
5772 data.SetStop(10); 5774 data.SetStop(10);
5773 data.Run(); 5775 data.Run();
5774 EXPECT_EQ(OK, callback2.WaitForResult()); 5776 EXPECT_EQ(OK, callback2.WaitForResult());
5775 EXPECT_EQ(OK, callback3.WaitForResult()); 5777 EXPECT_EQ(OK, callback3.WaitForResult());
5776 5778
5777 helper.VerifyDataConsumed(); 5779 helper.VerifyDataConsumed();
5778 } 5780 }
5779 5781
5780 } // namespace net 5782 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698