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

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

Issue 2874013002: Add GetWakeLockWithoutContext() in WakeLockContextProvider mojo interface. (Closed)
Patch Set: Add GetWakeLockWithoutContext in WakeLockContextProvider mojo interface. 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..83648b08237074aad9c28adb6769ec4895723eb2 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,8 @@
#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_context.mojom.h"
blundell 2017/05/12 12:42:18 Not needed now.
ke.he 2017/05/12 16:09:38 Done.
+#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 +43,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 +200,22 @@ 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();
+ if (connector) {
blundell 2017/05/12 12:42:18 I think we should elide this instead you have evid
ke.he 2017/05/12 16:09:38 I noticed in wake_lock_context_host.cc, line 35, t
+ 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();

Powered by Google App Engine
This is Rietveld 408576698