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

Side by Side Diff: content/common/power_monitor_broadcast_source.h

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Killing Nits Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_COMMON_POWER_MONITOR_BROADCAST_SOURCE_H_
6 #define CONTENT_COMMON_POWER_MONITOR_BROADCAST_SOURCE_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop.h"
10 #include "base/power_monitor/power_monitor_source.h"
11 #include "content/common/content_export.h"
12 #include "ipc/ipc_channel.h"
13 #include "ipc/ipc_channel_proxy.h"
14
15 namespace content {
16
17 // Receives Power Monitor IPC messages sent from the browser process and relays
18 // them to the PowerMonitor of the current process.
19 class CONTENT_EXPORT PowerMonitorBroadcastSource :
20 public base::PowerMonitorSource {
21 public:
22 PowerMonitorBroadcastSource(
jar (doing other things) 2013/07/16 17:15:33 nit: explicit
23 scoped_refptr<base::MessageLoopProxy> message_loop);
24 virtual ~PowerMonitorBroadcastSource();
25
26 IPC::ChannelProxy::MessageFilter* MessageFilter();
27
28 private:
29 friend class PowerMonitorMessageFilter;
30
31 class PowerMessageFilter : public IPC::ChannelProxy::MessageFilter {
32 public:
33 explicit PowerMessageFilter(
jar (doing other things) 2013/07/16 17:15:33 nit: no need for explicit
34 base::WeakPtr<PowerMonitorBroadcastSource> source,
35 scoped_refptr<base::MessageLoopProxy> message_loop);
36
37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
38
39 private:
40 friend class base::RefCounted<PowerMessageFilter>;
41
42 virtual ~PowerMessageFilter();
43
44 void OnPowerStateChange(bool on_battery_power);
45 void OnSuspend();
46 void OnResume();
47
48 base::WeakPtr<PowerMonitorBroadcastSource> source_;
49 scoped_refptr<base::MessageLoopProxy> message_loop_;
50
51 DISALLOW_COPY_AND_ASSIGN(PowerMessageFilter);
52 };
53
54 virtual bool IsOnBatteryPowerImpl() OVERRIDE;
55
56 void OnPowerStateChange(bool on_battery_power);
57 void OnSuspend();
58 void OnResume();
59
60 bool last_reported_battery_power_state_;
61 scoped_refptr<PowerMessageFilter> message_filter_;
62 base::WeakPtrFactory<PowerMonitorBroadcastSource> weak_factory_;
63
64 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698