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

Side by Side Diff: content/browser/background_sync/background_sync_power_observer.h

Issue 1617063002: [BackgroundSync Cleanup] Remove power observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Found more Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_POWER_OBSERVER_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_POWER_OBSERVER_H_
7
8 #include "base/bind.h"
9 #include "base/macros.h"
10 #include "base/power_monitor/power_observer.h"
11 #include "content/browser/background_sync/background_sync.pb.h"
12 #include "content/common/content_export.h"
13
14 namespace content {
15
16 // BackgroundSyncPowerObserver monitors the charging status of the device and
17 // determines if the power conditions of BackgroundSyncRegistrations are met.
18 class CONTENT_EXPORT BackgroundSyncPowerObserver : public base::PowerObserver {
19 public:
20 // Creates a BackgroundSyncPowerObserver. |power_callback| is run when the
21 // battery states changes asynchronously via PostMessage.
22 explicit BackgroundSyncPowerObserver(const base::Closure& power_callback);
23
24 ~BackgroundSyncPowerObserver() override;
25
26 // Returns true if the state of the battery (charging or not) meets the needs
27 // of |power_state|.
28 bool PowerSufficient(SyncPowerState power_state) const;
29
30 private:
31 friend class BackgroundSyncPowerObserverTest;
32
33 // PowerObserver overrides
34 void OnPowerStateChange(bool on_battery_power) override;
35
36 // |observing_power_monitor_| is true when the constructor is able to find and
37 // register an observer with the base::PowerMonitor. This should always be
38 // true except for tests in which the browser initialization isn't done.
39 bool observing_power_monitor_;
40
41 bool on_battery_;
42
43 // The callback to run when the battery state changes.
44 base::Closure power_changed_callback_;
45
46 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncPowerObserver);
47 };
48
49 } // namespace content
50
51 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_POWER_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698