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

Unified Diff: content/browser/power_save_blocker_android.cc

Issue 2075153002: Reland of 'Move content/browser/power_save_blocker to //device/power_save_blocker' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing libs for component mac Created 4 years, 6 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
« no previous file with comments | « content/browser/power_save_blocker_android.h ('k') | content/browser/power_save_blocker_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/power_save_blocker_android.cc
diff --git a/content/browser/power_save_blocker_android.cc b/content/browser/power_save_blocker_android.cc
deleted file mode 100644
index 6b46bc3dd8d79fa9d389285f4e0988d6764cfc92..0000000000000000000000000000000000000000
--- a/content/browser/power_save_blocker_android.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/android/jni_android.h"
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "content/browser/power_save_blocker_impl.h"
-#include "jni/PowerSaveBlocker_jni.h"
-#include "ui/android/view_android.h"
-
-namespace content {
-
-using base::android::AttachCurrentThread;
-
-class PowerSaveBlockerImpl::Delegate
- : public base::RefCountedThreadSafe<PowerSaveBlockerImpl::Delegate> {
- public:
- Delegate(base::WeakPtr<ui::ViewAndroid> view_android,
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
-
- // Does the actual work to apply or remove the desired power save block.
- void ApplyBlock();
- void RemoveBlock();
-
- private:
- friend class base::RefCountedThreadSafe<Delegate>;
- ~Delegate();
-
- base::WeakPtr<ui::ViewAndroid> view_android_;
-
- base::android::ScopedJavaGlobalRef<jobject> java_power_save_blocker_;
-
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(Delegate);
-};
-
-PowerSaveBlockerImpl::Delegate::Delegate(
- base::WeakPtr<ui::ViewAndroid> view_android,
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
- : view_android_(view_android), ui_task_runner_(ui_task_runner) {
- JNIEnv* env = AttachCurrentThread();
- java_power_save_blocker_.Reset(Java_PowerSaveBlocker_create(env));
-}
-
-PowerSaveBlockerImpl::Delegate::~Delegate() {
-}
-
-void PowerSaveBlockerImpl::Delegate::ApplyBlock() {
- DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
-
- ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_);
- JNIEnv* env = AttachCurrentThread();
- if (view_android_) {
- Java_PowerSaveBlocker_applyBlock(
- env, obj.obj(), view_android_->GetViewAndroidDelegate().obj());
- }
-}
-
-void PowerSaveBlockerImpl::Delegate::RemoveBlock() {
- DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
- ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_);
- JNIEnv* env = AttachCurrentThread();
- if (view_android_) {
- Java_PowerSaveBlocker_removeBlock(
- env, obj.obj(), view_android_->GetViewAndroidDelegate().obj());
- }
-}
-
-PowerSaveBlockerImpl::PowerSaveBlockerImpl(
- PowerSaveBlockerType type,
- Reason reason,
- const std::string& description,
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner)
- : ui_task_runner_(ui_task_runner),
- blocking_task_runner_(blocking_task_runner) {
- // Don't support kPowerSaveBlockPreventAppSuspension
-}
-
-PowerSaveBlockerImpl::~PowerSaveBlockerImpl() {
- if (delegate_.get()) {
- ui_task_runner_->PostTask(FROM_HERE,
- base::Bind(&Delegate::RemoveBlock, delegate_));
- }
-}
-
-void PowerSaveBlockerImpl::InitDisplaySleepBlocker(
- const base::WeakPtr<ui::ViewAndroid>& view_android) {
- DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
- if (!view_android)
- return;
-
- delegate_ = new Delegate(view_android, ui_task_runner_);
- delegate_->ApplyBlock();
-}
-
-bool RegisterPowerSaveBlocker(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-} // namespace content
« no previous file with comments | « content/browser/power_save_blocker_android.h ('k') | content/browser/power_save_blocker_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698