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

Side by Side Diff: content/browser/download/download_browsertest.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 // This file contains download browser tests that are known to be runnable 5 // This file contains download browser tests that are known to be runnable
6 // in a pure content context. Over time tests should be migrated here. 6 // in a pure content context. Over time tests should be migrated here.
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/feature_list.h" 14 #include "base/feature_list.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
18 #include "base/format_macros.h" 18 #include "base/format_macros.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 scoped_ptr<DownloadSaveInfo> save_info, 192 scoped_ptr<DownloadSaveInfo> save_info,
193 const base::FilePath& default_download_directory, 193 const base::FilePath& default_download_directory,
194 const GURL& url, 194 const GURL& url,
195 const GURL& referrer_url, 195 const GURL& referrer_url,
196 bool calculate_hash, 196 bool calculate_hash,
197 scoped_ptr<ByteStreamReader> stream, 197 scoped_ptr<ByteStreamReader> stream,
198 const net::BoundNetLog& bound_net_log, 198 const net::BoundNetLog& bound_net_log,
199 scoped_ptr<PowerSaveBlocker> power_save_blocker, 199 scoped_ptr<PowerSaveBlocker> power_save_blocker,
200 base::WeakPtr<DownloadDestinationObserver> observer, 200 base::WeakPtr<DownloadDestinationObserver> observer,
201 base::WeakPtr<DownloadFileWithDelayFactory> owner) 201 base::WeakPtr<DownloadFileWithDelayFactory> owner)
202 : DownloadFileImpl( 202 : DownloadFileImpl(std::move(save_info),
203 save_info.Pass(), default_download_directory, url, referrer_url, 203 default_download_directory,
204 calculate_hash, stream.Pass(), bound_net_log, observer), 204 url,
205 referrer_url,
206 calculate_hash,
207 std::move(stream),
208 bound_net_log,
209 observer),
205 owner_(owner) {} 210 owner_(owner) {}
206 211
207 DownloadFileWithDelay::~DownloadFileWithDelay() {} 212 DownloadFileWithDelay::~DownloadFileWithDelay() {}
208 213
209 void DownloadFileWithDelay::RenameAndUniquify( 214 void DownloadFileWithDelay::RenameAndUniquify(
210 const base::FilePath& full_path, 215 const base::FilePath& full_path,
211 const RenameCompletionCallback& callback) { 216 const RenameCompletionCallback& callback) {
212 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 217 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
213 DownloadFileImpl::RenameAndUniquify( 218 DownloadFileImpl::RenameAndUniquify(
214 full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper, 219 full_path, base::Bind(DownloadFileWithDelay::RenameCallbackWrapper,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 const GURL& url, 252 const GURL& url,
248 const GURL& referrer_url, 253 const GURL& referrer_url,
249 bool calculate_hash, 254 bool calculate_hash,
250 scoped_ptr<ByteStreamReader> stream, 255 scoped_ptr<ByteStreamReader> stream,
251 const net::BoundNetLog& bound_net_log, 256 const net::BoundNetLog& bound_net_log,
252 base::WeakPtr<DownloadDestinationObserver> observer) { 257 base::WeakPtr<DownloadDestinationObserver> observer) {
253 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create( 258 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create(
254 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, 259 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
255 PowerSaveBlocker::kReasonOther, "Download in progress")); 260 PowerSaveBlocker::kReasonOther, "Download in progress"));
256 return new DownloadFileWithDelay( 261 return new DownloadFileWithDelay(
257 save_info.Pass(), default_download_directory, url, referrer_url, 262 std::move(save_info), default_download_directory, url, referrer_url,
258 calculate_hash, stream.Pass(), bound_net_log, 263 calculate_hash, std::move(stream), bound_net_log, std::move(psb),
259 psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr()); 264 observer, weak_ptr_factory_.GetWeakPtr());
260 } 265 }
261 266
262 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { 267 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) {
263 DCHECK_CURRENTLY_ON(BrowserThread::UI); 268 DCHECK_CURRENTLY_ON(BrowserThread::UI);
264 rename_callbacks_.push_back(callback); 269 rename_callbacks_.push_back(callback);
265 if (waiting_) 270 if (waiting_)
266 base::MessageLoopForUI::current()->QuitWhenIdle(); 271 base::MessageLoopForUI::current()->QuitWhenIdle();
267 } 272 }
268 273
269 void DownloadFileWithDelayFactory::GetAllRenameCallbacks( 274 void DownloadFileWithDelayFactory::GetAllRenameCallbacks(
270 std::vector<base::Closure>* results) { 275 std::vector<base::Closure>* results) {
271 DCHECK_CURRENTLY_ON(BrowserThread::UI); 276 DCHECK_CURRENTLY_ON(BrowserThread::UI);
272 results->swap(rename_callbacks_); 277 results->swap(rename_callbacks_);
273 } 278 }
274 279
275 void DownloadFileWithDelayFactory::WaitForSomeCallback() { 280 void DownloadFileWithDelayFactory::WaitForSomeCallback() {
276 DCHECK_CURRENTLY_ON(BrowserThread::UI); 281 DCHECK_CURRENTLY_ON(BrowserThread::UI);
277 282
278 if (rename_callbacks_.empty()) { 283 if (rename_callbacks_.empty()) {
279 waiting_ = true; 284 waiting_ = true;
280 RunMessageLoop(); 285 RunMessageLoop();
281 waiting_ = false; 286 waiting_ = false;
282 } 287 }
283 } 288 }
284 289
285 class CountingDownloadFile : public DownloadFileImpl { 290 class CountingDownloadFile : public DownloadFileImpl {
286 public: 291 public:
287 CountingDownloadFile( 292 CountingDownloadFile(scoped_ptr<DownloadSaveInfo> save_info,
288 scoped_ptr<DownloadSaveInfo> save_info, 293 const base::FilePath& default_downloads_directory,
289 const base::FilePath& default_downloads_directory, 294 const GURL& url,
290 const GURL& url, 295 const GURL& referrer_url,
291 const GURL& referrer_url, 296 bool calculate_hash,
292 bool calculate_hash, 297 scoped_ptr<ByteStreamReader> stream,
293 scoped_ptr<ByteStreamReader> stream, 298 const net::BoundNetLog& bound_net_log,
294 const net::BoundNetLog& bound_net_log, 299 scoped_ptr<PowerSaveBlocker> power_save_blocker,
295 scoped_ptr<PowerSaveBlocker> power_save_blocker, 300 base::WeakPtr<DownloadDestinationObserver> observer)
296 base::WeakPtr<DownloadDestinationObserver> observer) 301 : DownloadFileImpl(std::move(save_info),
297 : DownloadFileImpl(save_info.Pass(), default_downloads_directory, 302 default_downloads_directory,
298 url, referrer_url, calculate_hash, 303 url,
299 stream.Pass(), bound_net_log, observer) {} 304 referrer_url,
305 calculate_hash,
306 std::move(stream),
307 bound_net_log,
308 observer) {}
300 309
301 ~CountingDownloadFile() override { 310 ~CountingDownloadFile() override {
302 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 311 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
303 active_files_--; 312 active_files_--;
304 } 313 }
305 314
306 void Initialize(const InitializeCallback& callback) override { 315 void Initialize(const InitializeCallback& callback) override {
307 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 316 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
308 active_files_++; 317 active_files_++;
309 return DownloadFileImpl::Initialize(callback); 318 return DownloadFileImpl::Initialize(callback);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 const GURL& url, 354 const GURL& url,
346 const GURL& referrer_url, 355 const GURL& referrer_url,
347 bool calculate_hash, 356 bool calculate_hash,
348 scoped_ptr<ByteStreamReader> stream, 357 scoped_ptr<ByteStreamReader> stream,
349 const net::BoundNetLog& bound_net_log, 358 const net::BoundNetLog& bound_net_log,
350 base::WeakPtr<DownloadDestinationObserver> observer) override { 359 base::WeakPtr<DownloadDestinationObserver> observer) override {
351 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create( 360 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create(
352 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, 361 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
353 PowerSaveBlocker::kReasonOther, "Download in progress")); 362 PowerSaveBlocker::kReasonOther, "Download in progress"));
354 return new CountingDownloadFile( 363 return new CountingDownloadFile(
355 save_info.Pass(), default_downloads_directory, url, referrer_url, 364 std::move(save_info), default_downloads_directory, url, referrer_url,
356 calculate_hash, stream.Pass(), bound_net_log, 365 calculate_hash, std::move(stream), bound_net_log, std::move(psb),
357 psb.Pass(), observer); 366 observer);
358 } 367 }
359 }; 368 };
360 369
361 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { 370 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate {
362 public: 371 public:
363 TestShellDownloadManagerDelegate() 372 TestShellDownloadManagerDelegate()
364 : delay_download_open_(false) {} 373 : delay_download_open_(false) {}
365 ~TestShellDownloadManagerDelegate() override {} 374 ~TestShellDownloadManagerDelegate() override {}
366 375
367 bool ShouldOpenDownload( 376 bool ShouldOpenDownload(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendRedirectResponse( 449 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendRedirectResponse(
441 const std::string& relative_url, 450 const std::string& relative_url,
442 const GURL& target_url, 451 const GURL& target_url,
443 const net::test_server::HttpRequest& request) { 452 const net::test_server::HttpRequest& request) {
444 scoped_ptr<net::test_server::BasicHttpResponse> response; 453 scoped_ptr<net::test_server::BasicHttpResponse> response;
445 if (request.relative_url == relative_url) { 454 if (request.relative_url == relative_url) {
446 response.reset(new net::test_server::BasicHttpResponse); 455 response.reset(new net::test_server::BasicHttpResponse);
447 response->set_code(net::HTTP_FOUND); 456 response->set_code(net::HTTP_FOUND);
448 response->AddCustomHeader("Location", target_url.spec()); 457 response->AddCustomHeader("Location", target_url.spec());
449 } 458 }
450 return response.Pass(); 459 return std::move(response);
451 } 460 }
452 461
453 // Creates a request handler for EmbeddedTestServer that responds with a HTTP 462 // Creates a request handler for EmbeddedTestServer that responds with a HTTP
454 // 302 redirect if the request URL matches |relative_url|. 463 // 302 redirect if the request URL matches |relative_url|.
455 net::EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler( 464 net::EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler(
456 const std::string& relative_url, 465 const std::string& relative_url,
457 const GURL& target_url) { 466 const GURL& target_url) {
458 return base::Bind( 467 return base::Bind(
459 &HandleRequestAndSendRedirectResponse, relative_url, target_url); 468 &HandleRequestAndSendRedirectResponse, relative_url, target_url);
460 } 469 }
461 470
462 // Request handler to be used with CreateBasicResponseHandler(). 471 // Request handler to be used with CreateBasicResponseHandler().
463 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse( 472 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse(
464 const std::string& relative_url, 473 const std::string& relative_url,
465 const base::StringPairs& headers, 474 const base::StringPairs& headers,
466 const std::string& content_type, 475 const std::string& content_type,
467 const std::string& body, 476 const std::string& body,
468 const net::test_server::HttpRequest& request) { 477 const net::test_server::HttpRequest& request) {
469 scoped_ptr<net::test_server::BasicHttpResponse> response; 478 scoped_ptr<net::test_server::BasicHttpResponse> response;
470 if (request.relative_url == relative_url) { 479 if (request.relative_url == relative_url) {
471 response.reset(new net::test_server::BasicHttpResponse); 480 response.reset(new net::test_server::BasicHttpResponse);
472 for (const auto& pair : headers) 481 for (const auto& pair : headers)
473 response->AddCustomHeader(pair.first, pair.second); 482 response->AddCustomHeader(pair.first, pair.second);
474 response->set_content_type(content_type); 483 response->set_content_type(content_type);
475 response->set_content(body); 484 response->set_content(body);
476 } 485 }
477 return response.Pass(); 486 return std::move(response);
478 } 487 }
479 488
480 // Creates a request handler for an EmbeddedTestServer that response with an 489 // Creates a request handler for an EmbeddedTestServer that response with an
481 // HTTP 200 status code, a Content-Type header and a body. 490 // HTTP 200 status code, a Content-Type header and a body.
482 net::EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler( 491 net::EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler(
483 const std::string& relative_url, 492 const std::string& relative_url,
484 const base::StringPairs& headers, 493 const base::StringPairs& headers,
485 const std::string& content_type, 494 const std::string& content_type,
486 const std::string& body) { 495 const std::string& body) {
487 return base::Bind(&HandleRequestAndSendBasicResponse, relative_url, headers, 496 return base::Bind(&HandleRequestAndSendBasicResponse, relative_url, headers,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 596
588 void WaitForCompletion(DownloadItem* download) { 597 void WaitForCompletion(DownloadItem* download) {
589 DownloadUpdatedObserver( 598 DownloadUpdatedObserver(
590 download, base::Bind(&IsDownloadInState, DownloadItem::COMPLETE)) 599 download, base::Bind(&IsDownloadInState, DownloadItem::COMPLETE))
591 .WaitForEvent(); 600 .WaitForEvent();
592 } 601 }
593 602
594 // Note: Cannot be used with other alternative DownloadFileFactorys 603 // Note: Cannot be used with other alternative DownloadFileFactorys
595 void SetupEnsureNoPendingDownloads() { 604 void SetupEnsureNoPendingDownloads() {
596 DownloadManagerForShell(shell())->SetDownloadFileFactoryForTesting( 605 DownloadManagerForShell(shell())->SetDownloadFileFactoryForTesting(
597 scoped_ptr<DownloadFileFactory>( 606 scoped_ptr<DownloadFileFactory>(new CountingDownloadFileFactory()));
598 new CountingDownloadFileFactory()).Pass());
599 } 607 }
600 608
601 bool EnsureNoPendingDownloads() { 609 bool EnsureNoPendingDownloads() {
602 bool result = true; 610 bool result = true;
603 BrowserThread::PostTask( 611 BrowserThread::PostTask(
604 BrowserThread::IO, FROM_HERE, 612 BrowserThread::IO, FROM_HERE,
605 base::Bind(&EnsureNoPendingDownloadJobsOnIO, &result)); 613 base::Bind(&EnsureNoPendingDownloadJobsOnIO, &result));
606 base::MessageLoop::current()->Run(); 614 base::MessageLoop::current()->Run();
607 return result && 615 return result &&
608 (CountingDownloadFile::GetNumberActiveFilesFromFileThread() == 0); 616 (CountingDownloadFile::GetNumberActiveFilesFromFileThread() == 0);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 #endif 856 #endif
849 857
850 // Try to cancel just before we release the download file, by delaying final 858 // Try to cancel just before we release the download file, by delaying final
851 // rename callback. 859 // rename callback.
852 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) { 860 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtFinalRename) {
853 // Setup new factory. 861 // Setup new factory.
854 DownloadFileWithDelayFactory* file_factory = 862 DownloadFileWithDelayFactory* file_factory =
855 new DownloadFileWithDelayFactory(); 863 new DownloadFileWithDelayFactory();
856 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell())); 864 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
857 download_manager->SetDownloadFileFactoryForTesting( 865 download_manager->SetDownloadFileFactoryForTesting(
858 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); 866 scoped_ptr<DownloadFileFactory>(file_factory));
859 867
860 // Create a download 868 // Create a download
861 NavigateToURL(shell(), 869 NavigateToURL(shell(),
862 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib")); 870 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib"));
863 871
864 // Wait until the first (intermediate file) rename and execute the callback. 872 // Wait until the first (intermediate file) rename and execute the callback.
865 file_factory->WaitForSomeCallback(); 873 file_factory->WaitForSomeCallback();
866 std::vector<base::Closure> callbacks; 874 std::vector<base::Closure> callbacks;
867 file_factory->GetAllRenameCallbacks(&callbacks); 875 file_factory->GetAllRenameCallbacks(&callbacks);
868 ASSERT_EQ(1u, callbacks.size()); 876 ASSERT_EQ(1u, callbacks.size());
(...skipping 28 matching lines...) Expand all
897 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtRelease) { 905 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelAtRelease) {
898 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell())); 906 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
899 907
900 // Mark delegate for delayed open. 908 // Mark delegate for delayed open.
901 GetDownloadManagerDelegate()->SetDelayedOpen(true); 909 GetDownloadManagerDelegate()->SetDelayedOpen(true);
902 910
903 // Setup new factory. 911 // Setup new factory.
904 DownloadFileWithDelayFactory* file_factory = 912 DownloadFileWithDelayFactory* file_factory =
905 new DownloadFileWithDelayFactory(); 913 new DownloadFileWithDelayFactory();
906 download_manager->SetDownloadFileFactoryForTesting( 914 download_manager->SetDownloadFileFactoryForTesting(
907 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); 915 scoped_ptr<DownloadFileFactory>(file_factory));
908 916
909 // Create a download 917 // Create a download
910 NavigateToURL(shell(), 918 NavigateToURL(shell(),
911 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib")); 919 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib"));
912 920
913 // Wait until the first (intermediate file) rename and execute the callback. 921 // Wait until the first (intermediate file) rename and execute the callback.
914 file_factory->WaitForSomeCallback(); 922 file_factory->WaitForSomeCallback();
915 std::vector<base::Closure> callbacks; 923 std::vector<base::Closure> callbacks;
916 file_factory->GetAllRenameCallbacks(&callbacks); 924 file_factory->GetAllRenameCallbacks(&callbacks);
917 ASSERT_EQ(1u, callbacks.size()); 925 ASSERT_EQ(1u, callbacks.size());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownAtRelease) { 1016 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ShutdownAtRelease) {
1009 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell())); 1017 DownloadManagerImpl* download_manager(DownloadManagerForShell(shell()));
1010 1018
1011 // Mark delegate for delayed open. 1019 // Mark delegate for delayed open.
1012 GetDownloadManagerDelegate()->SetDelayedOpen(true); 1020 GetDownloadManagerDelegate()->SetDelayedOpen(true);
1013 1021
1014 // Setup new factory. 1022 // Setup new factory.
1015 DownloadFileWithDelayFactory* file_factory = 1023 DownloadFileWithDelayFactory* file_factory =
1016 new DownloadFileWithDelayFactory(); 1024 new DownloadFileWithDelayFactory();
1017 download_manager->SetDownloadFileFactoryForTesting( 1025 download_manager->SetDownloadFileFactoryForTesting(
1018 scoped_ptr<DownloadFileFactory>(file_factory).Pass()); 1026 scoped_ptr<DownloadFileFactory>(file_factory));
1019 1027
1020 // Create a download 1028 // Create a download
1021 NavigateToURL(shell(), 1029 NavigateToURL(shell(),
1022 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib")); 1030 net::URLRequestMockHTTPJob::GetMockUrl("download-test.lib"));
1023 1031
1024 // Wait until the first (intermediate file) rename and execute the callback. 1032 // Wait until the first (intermediate file) rename and execute the callback.
1025 file_factory->WaitForSomeCallback(); 1033 file_factory->WaitForSomeCallback();
1026 std::vector<base::Closure> callbacks; 1034 std::vector<base::Closure> callbacks;
1027 file_factory->GetAllRenameCallbacks(&callbacks); 1035 file_factory->GetAllRenameCallbacks(&callbacks);
1028 ASSERT_EQ(1u, callbacks.size()); 1036 ASSERT_EQ(1u, callbacks.size());
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 "/foo", cookie_header, "application/octet-stream", "abcd")); 1663 "/foo", cookie_header, "application/octet-stream", "abcd"));
1656 origin_two.RegisterRequestHandler( 1664 origin_two.RegisterRequestHandler(
1657 CreateRedirectHandler("/bar", origin_one.GetURL("/foo"))); 1665 CreateRedirectHandler("/bar", origin_one.GetURL("/foo")));
1658 1666
1659 // Download the file. 1667 // Download the file.
1660 SetupEnsureNoPendingDownloads(); 1668 SetupEnsureNoPendingDownloads();
1661 scoped_ptr<DownloadUrlParameters> download_parameters( 1669 scoped_ptr<DownloadUrlParameters> download_parameters(
1662 DownloadUrlParameters::FromWebContents(shell()->web_contents(), 1670 DownloadUrlParameters::FromWebContents(shell()->web_contents(),
1663 origin_two.GetURL("/bar"))); 1671 origin_two.GetURL("/bar")));
1664 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1)); 1672 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1));
1665 DownloadManagerForShell(shell())->DownloadUrl(download_parameters.Pass()); 1673 DownloadManagerForShell(shell())->DownloadUrl(std::move(download_parameters));
1666 observer->WaitForFinished(); 1674 observer->WaitForFinished();
1667 1675
1668 // Get the important info from other threads and check it. 1676 // Get the important info from other threads and check it.
1669 EXPECT_TRUE(EnsureNoPendingDownloads()); 1677 EXPECT_TRUE(EnsureNoPendingDownloads());
1670 1678
1671 std::vector<DownloadItem*> downloads; 1679 std::vector<DownloadItem*> downloads;
1672 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); 1680 DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
1673 ASSERT_EQ(1u, downloads.size()); 1681 ASSERT_EQ(1u, downloads.size());
1674 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); 1682 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState());
1675 1683
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 1810
1803 std::vector<DownloadItem*> downloads; 1811 std::vector<DownloadItem*> downloads;
1804 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); 1812 DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
1805 ASSERT_EQ(1u, downloads.size()); 1813 ASSERT_EQ(1u, downloads.size());
1806 1814
1807 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), 1815 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"),
1808 downloads[0]->GetTargetFilePath().BaseName().value()); 1816 downloads[0]->GetTargetFilePath().BaseName().value());
1809 } 1817 }
1810 1818
1811 } // namespace content 1819 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/base_file_unittest.cc ('k') | content/browser/download/download_create_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698