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

Unified Diff: content/browser/download/download_request_core.cc

Issue 2874013002: Add GetWakeLockWithoutContext() in WakeLockContextProvider mojo interface. (Closed)
Patch Set: Addressed Colin's comments. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_request_core.cc
diff --git a/content/browser/download/download_request_core.cc b/content/browser/download/download_request_core.cc
index b30984bd52ad40c1776451ce961344c903206d33..8030338f03eb58a6faaffdb005b549467e84ff7d 100644
--- a/content/browser/download/download_request_core.cc
+++ b/content/browser/download/download_request_core.cc
@@ -24,6 +24,7 @@
#include "content/browser/download/download_request_handle.h"
#include "content/browser/download/download_stats.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
+#include "content/browser/service_manager/service_manager_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_item.h"
@@ -31,7 +32,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/web_contents.h"
-#include "device/power_save_blocker/power_save_blocker.h"
+#include "device/wake_lock/public/interfaces/wake_lock_provider.mojom.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/load_flags.h"
@@ -41,6 +42,8 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/url_request_context.h"
+#include "services/device/public/interfaces/constants.mojom.h"
+#include "services/service_manager/public/cpp/connector.h"
namespace content {
@@ -196,11 +199,24 @@ DownloadRequestCore::DownloadRequestCore(net::URLRequest* request,
DCHECK(delegate_);
if (!is_parallel_request)
RecordDownloadCount(UNTHROTTLED_COUNT);
- power_save_blocker_.reset(new device::PowerSaveBlocker(
- device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension,
- device::PowerSaveBlocker::kReasonOther, "Download in progress",
- BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
- BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
+
+ // Request Wake Lock.
+ service_manager::Connector* connector =
+ ServiceManagerContext::GetConnectorForIOThread();
+ // |connector| might be nullptr in some testing contexts, in which thei
David Trainor- moved to gerrit 2017/05/14 05:52:40 thei -> the?
ke.he 2017/05/14 12:05:00 Done.
+ // service manager connection isn't initialized.
+ if (connector) {
+ device::mojom::WakeLockProviderPtr wake_lock_provider;
+ connector->BindInterface(device::mojom::kServiceName,
+ mojo::MakeRequest(&wake_lock_provider));
+ wake_lock_provider->GetWakeLockWithoutContext(
+ device::mojom::WakeLockType::PreventAppSuspension,
+ device::mojom::WakeLockReason::ReasonOther, "Download in progress",
+ mojo::MakeRequest(&wake_lock_));
+
+ wake_lock_->RequestWakeLock();
+ }
+
DownloadRequestData* request_data = DownloadRequestData::Get(request_);
if (request_data) {
save_info_ = request_data->TakeSaveInfo();
« no previous file with comments | « content/browser/download/download_request_core.h ('k') | content/browser/wake_lock/wake_lock_context_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698