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

Unified Diff: content/browser/media/capture/aura_window_capture_machine.cc

Issue 2881143003: Convert //content/browser/media to be clients of WakeLock mojo service. (Closed)
Patch Set: wake lock bindinterface should only be executed once. 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/media/capture/aura_window_capture_machine.cc
diff --git a/content/browser/media/capture/aura_window_capture_machine.cc b/content/browser/media/capture/aura_window_capture_machine.cc
index a28c1c0f8aee8e5cca21d94d0b08d3b75a7bfb15..25d9f4f7ba0538edf27b434ebdf223133012f2ac 100644
--- a/content/browser/media/capture/aura_window_capture_machine.cc
+++ b/content/browser/media/capture/aura_window_capture_machine.cc
@@ -15,11 +15,14 @@
#include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/public/browser/browser_thread.h"
-#include "device/power_save_blocker/power_save_blocker.h"
+#include "content/public/common/service_manager_connection.h"
+#include "device/wake_lock/public/interfaces/wake_lock_provider.mojom.h"
#include "media/base/video_util.h"
#include "media/capture/content/thread_safe_capture_oracle.h"
#include "media/capture/content/video_capture_oracle.h"
#include "media/capture/video_capture_types.h"
+#include "services/device/public/interfaces/constants.mojom.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/client/screen_position_client.h"
@@ -86,11 +89,25 @@ bool AuraWindowCaptureMachine::InternalStart(
return false;
compositor->AddAnimationObserver(this);
- power_save_blocker_.reset(new device::PowerSaveBlocker(
- device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
- device::PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running",
- BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
- BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
+ if (!wake_lock_) {
Sergey Ulanov 2017/05/17 18:47:55 I don't think InternalStart() can be called more t
ke.he 2017/05/18 05:32:58 Done.
+ device::mojom::WakeLockServiceRequest request =
+ mojo::MakeRequest(&wake_lock_);
+ // In some testing contexts, the service manager connection isn't
+ // initialized.
+ if (ServiceManagerConnection::GetForProcess()) {
+ service_manager::Connector* connector =
+ ServiceManagerConnection::GetForProcess()->GetConnector();
+ DCHECK(connector);
+ device::mojom::WakeLockProviderPtr wake_lock_provider;
+ connector->BindInterface(device::mojom::kServiceName,
+ mojo::MakeRequest(&wake_lock_provider));
+ wake_lock_provider->GetWakeLockWithoutContext(
+ device::mojom::WakeLockType::PreventDisplaySleep,
+ device::mojom::WakeLockReason::ReasonOther,
+ "Desktop capturer is running", std::move(request));
+ }
+ }
+ wake_lock_->RequestWakeLock();
return true;
}
@@ -137,8 +154,8 @@ void AuraWindowCaptureMachine::InternalStop(const base::Closure& callback) {
// Cancel any and all outstanding callbacks owned by external modules.
weak_factory_.InvalidateWeakPtrs();
- power_save_blocker_.reset();
-
+ if (wake_lock_)
+ wake_lock_->CancelWakeLock();
// Stop observing compositor and window events.
if (desktop_window_) {
if (aura::WindowTreeHost* host = desktop_window_->GetHost()) {

Powered by Google App Engine
This is Rietveld 408576698