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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 1476443002: Remove ScopedVector from ElementsUploadDataStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 5 years 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
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 5441 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 TestDelegate d; 5452 TestDelegate d;
5453 { 5453 {
5454 scoped_ptr<URLRequest> r(default_context_.CreateRequest( 5454 scoped_ptr<URLRequest> r(default_context_.CreateRequest(
5455 http_test_server()->GetURL("/echo"), DEFAULT_PRIORITY, &d)); 5455 http_test_server()->GetURL("/echo"), DEFAULT_PRIORITY, &d));
5456 r->set_method("POST"); 5456 r->set_method("POST");
5457 5457
5458 base::FilePath dir; 5458 base::FilePath dir;
5459 PathService::Get(base::DIR_EXE, &dir); 5459 PathService::Get(base::DIR_EXE, &dir);
5460 base::SetCurrentDirectory(dir); 5460 base::SetCurrentDirectory(dir);
5461 5461
5462 ScopedVector<UploadElementReader> element_readers; 5462 std::vector<scoped_ptr<UploadElementReader>> element_readers;
5463 5463
5464 base::FilePath path; 5464 base::FilePath path;
5465 PathService::Get(base::DIR_SOURCE_ROOT, &path); 5465 PathService::Get(base::DIR_SOURCE_ROOT, &path);
5466 path = path.Append(kTestFilePath); 5466 path = path.Append(kTestFilePath);
5467 path = path.Append(FILE_PATH_LITERAL("with-headers.html")); 5467 path = path.Append(FILE_PATH_LITERAL("with-headers.html"));
5468 element_readers.push_back( 5468 element_readers.push_back(make_scoped_ptr(
5469 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(), 5469 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(),
5470 path, 0, kuint64max, base::Time())); 5470 path, 0, kuint64max, base::Time())));
5471 r->set_upload(make_scoped_ptr<UploadDataStream>( 5471 r->set_upload(make_scoped_ptr<UploadDataStream>(
5472 new ElementsUploadDataStream(element_readers.Pass(), 0))); 5472 new ElementsUploadDataStream(std::move(element_readers), 0)));
5473 5473
5474 r->Start(); 5474 r->Start();
5475 EXPECT_TRUE(r->is_pending()); 5475 EXPECT_TRUE(r->is_pending());
5476 5476
5477 base::RunLoop().Run(); 5477 base::RunLoop().Run();
5478 5478
5479 int64 size64 = 0; 5479 int64 size64 = 0;
5480 ASSERT_EQ(true, base::GetFileSize(path, &size64)); 5480 ASSERT_EQ(true, base::GetFileSize(path, &size64));
5481 ASSERT_LE(size64, std::numeric_limits<int>::max()); 5481 ASSERT_LE(size64, std::numeric_limits<int>::max());
5482 int size = static_cast<int>(size64); 5482 int size = static_cast<int>(size64);
(...skipping 14 matching lines...) Expand all
5497 5497
5498 TEST_F(URLRequestTestHTTP, PostUnreadableFileTest) { 5498 TEST_F(URLRequestTestHTTP, PostUnreadableFileTest) {
5499 ASSERT_TRUE(http_test_server()->Start()); 5499 ASSERT_TRUE(http_test_server()->Start());
5500 5500
5501 TestDelegate d; 5501 TestDelegate d;
5502 { 5502 {
5503 scoped_ptr<URLRequest> r(default_context_.CreateRequest( 5503 scoped_ptr<URLRequest> r(default_context_.CreateRequest(
5504 http_test_server()->GetURL("/echo"), DEFAULT_PRIORITY, &d)); 5504 http_test_server()->GetURL("/echo"), DEFAULT_PRIORITY, &d));
5505 r->set_method("POST"); 5505 r->set_method("POST");
5506 5506
5507 ScopedVector<UploadElementReader> element_readers; 5507 std::vector<scoped_ptr<UploadElementReader>> element_readers;
5508 5508
5509 element_readers.push_back(new UploadFileElementReader( 5509 element_readers.push_back(make_scoped_ptr(new UploadFileElementReader(
5510 base::ThreadTaskRunnerHandle::Get().get(), 5510 base::ThreadTaskRunnerHandle::Get().get(),
5511 base::FilePath(FILE_PATH_LITERAL( 5511 base::FilePath(FILE_PATH_LITERAL(
5512 "c:\\path\\to\\non\\existant\\file.randomness.12345")), 5512 "c:\\path\\to\\non\\existant\\file.randomness.12345")),
5513 0, kuint64max, base::Time())); 5513 0, kuint64max, base::Time())));
5514 r->set_upload(make_scoped_ptr<UploadDataStream>( 5514 r->set_upload(make_scoped_ptr<UploadDataStream>(
5515 new ElementsUploadDataStream(element_readers.Pass(), 0))); 5515 new ElementsUploadDataStream(std::move(element_readers), 0)));
5516 5516
5517 r->Start(); 5517 r->Start();
5518 EXPECT_TRUE(r->is_pending()); 5518 EXPECT_TRUE(r->is_pending());
5519 5519
5520 base::RunLoop().Run(); 5520 base::RunLoop().Run();
5521 5521
5522 EXPECT_TRUE(d.request_failed()); 5522 EXPECT_TRUE(d.request_failed());
5523 EXPECT_FALSE(d.received_data_before_response()); 5523 EXPECT_FALSE(d.received_data_before_response());
5524 EXPECT_EQ(0, d.bytes_received()); 5524 EXPECT_EQ(0, d.bytes_received());
5525 EXPECT_EQ(URLRequestStatus::FAILED, r->status().status()); 5525 EXPECT_EQ(URLRequestStatus::FAILED, r->status().status());
(...skipping 4179 matching lines...) Expand 10 before | Expand all | Expand 10 after
9705 9705
9706 req->Start(); 9706 req->Start();
9707 req->Cancel(); 9707 req->Cancel();
9708 job->DetachRequest(); 9708 job->DetachRequest();
9709 base::RunLoop().RunUntilIdle(); 9709 base::RunLoop().RunUntilIdle();
9710 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); 9710 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status());
9711 EXPECT_EQ(0, d.received_redirect_count()); 9711 EXPECT_EQ(0, d.received_redirect_count());
9712 } 9712 }
9713 9713
9714 } // namespace net 9714 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698