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

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

Issue 946643002: Use PowerSaveBlocker for audio and video on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply nits Created 5 years, 10 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 "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 DownloadFile* DownloadFileWithDelayFactory::CreateFile( 236 DownloadFile* DownloadFileWithDelayFactory::CreateFile(
237 scoped_ptr<DownloadSaveInfo> save_info, 237 scoped_ptr<DownloadSaveInfo> save_info,
238 const base::FilePath& default_download_directory, 238 const base::FilePath& default_download_directory,
239 const GURL& url, 239 const GURL& url,
240 const GURL& referrer_url, 240 const GURL& referrer_url,
241 bool calculate_hash, 241 bool calculate_hash,
242 scoped_ptr<ByteStreamReader> stream, 242 scoped_ptr<ByteStreamReader> stream,
243 const net::BoundNetLog& bound_net_log, 243 const net::BoundNetLog& bound_net_log,
244 base::WeakPtr<DownloadDestinationObserver> observer) { 244 base::WeakPtr<DownloadDestinationObserver> observer) {
245 scoped_ptr<PowerSaveBlocker> psb( 245 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create(
246 PowerSaveBlocker::Create( 246 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
247 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, 247 PowerSaveBlocker::kReasonOther, "Download in progress"));
248 "Download in progress"));
249 return new DownloadFileWithDelay( 248 return new DownloadFileWithDelay(
250 save_info.Pass(), default_download_directory, url, referrer_url, 249 save_info.Pass(), default_download_directory, url, referrer_url,
251 calculate_hash, stream.Pass(), bound_net_log, 250 calculate_hash, stream.Pass(), bound_net_log,
252 psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr()); 251 psb.Pass(), observer, weak_ptr_factory_.GetWeakPtr());
253 } 252 }
254 253
255 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) { 254 void DownloadFileWithDelayFactory::AddRenameCallback(base::Closure callback) {
256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
257 rename_callbacks_.push_back(callback); 256 rename_callbacks_.push_back(callback);
258 if (waiting_) 257 if (waiting_)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // DownloadFileFactory interface. 334 // DownloadFileFactory interface.
336 DownloadFile* CreateFile( 335 DownloadFile* CreateFile(
337 scoped_ptr<DownloadSaveInfo> save_info, 336 scoped_ptr<DownloadSaveInfo> save_info,
338 const base::FilePath& default_downloads_directory, 337 const base::FilePath& default_downloads_directory,
339 const GURL& url, 338 const GURL& url,
340 const GURL& referrer_url, 339 const GURL& referrer_url,
341 bool calculate_hash, 340 bool calculate_hash,
342 scoped_ptr<ByteStreamReader> stream, 341 scoped_ptr<ByteStreamReader> stream,
343 const net::BoundNetLog& bound_net_log, 342 const net::BoundNetLog& bound_net_log,
344 base::WeakPtr<DownloadDestinationObserver> observer) override { 343 base::WeakPtr<DownloadDestinationObserver> observer) override {
345 scoped_ptr<PowerSaveBlocker> psb( 344 scoped_ptr<PowerSaveBlocker> psb(PowerSaveBlocker::Create(
346 PowerSaveBlocker::Create( 345 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
347 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, 346 PowerSaveBlocker::kReasonOther, "Download in progress"));
348 "Download in progress"));
349 return new CountingDownloadFile( 347 return new CountingDownloadFile(
350 save_info.Pass(), default_downloads_directory, url, referrer_url, 348 save_info.Pass(), default_downloads_directory, url, referrer_url,
351 calculate_hash, stream.Pass(), bound_net_log, 349 calculate_hash, stream.Pass(), bound_net_log,
352 psb.Pass(), observer); 350 psb.Pass(), observer);
353 } 351 }
354 }; 352 };
355 353
356 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate { 354 class TestShellDownloadManagerDelegate : public ShellDownloadManagerDelegate {
357 public: 355 public:
358 TestShellDownloadManagerDelegate() 356 TestShellDownloadManagerDelegate()
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); 1809 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady());
1812 1810
1813 GURL url = test_server.GetURL("/empty.bin"); 1811 GURL url = test_server.GetURL("/empty.bin");
1814 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); 1812 test_server.ServeFilesFromDirectory(GetTestFilePath("download", ""));
1815 1813
1816 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); 1814 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE);
1817 // That's it. This should work without crashing. 1815 // That's it. This should work without crashing.
1818 } 1816 }
1819 1817
1820 } // namespace content 1818 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | content/browser/download/download_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698