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

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: Windows fixes, Power messages posted to main GPU thread now 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/message_loop/message_loop_proxy.h"
9 #include "base/power_monitor/power_monitor_source.h"
10
11 #include "ipc/ipc_channel.h"
12 #include "ipc/ipc_channel_proxy.h"
13
14 namespace content {
15
16 class PowerMonitorBroadcastSource : public base::PowerMonitorSource {
17 public:
18 PowerMonitorBroadcastSource(
19 scoped_refptr<base::MessageLoopProxy> message_loop);
20 virtual ~PowerMonitorBroadcastSource();
21
22 IPC::ChannelProxy::MessageFilter* MessageFilter();
23
24 private:
25 friend class PowerMonitorMessageFilter;
26
27 class PowerMessageFilter : public IPC::ChannelProxy::MessageFilter {
28 public:
29 PowerMessageFilter(PowerMonitorBroadcastSource* source);
30
31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
32
33 private:
34 friend class base::RefCounted<PowerMessageFilter>;
35
36 virtual ~PowerMessageFilter();
37
38 void OnPowerStateChange(bool on_battery_power);
39 void OnSuspend();
40 void OnResume();
41
42 PowerMonitorBroadcastSource* source_;
43
44 DISALLOW_COPY_AND_ASSIGN(PowerMessageFilter);
45 };
46
47 virtual bool IsBatteryPower() OVERRIDE;
48
49 void OnPowerStateChange(bool on_battery_power);
50 void OnSuspend();
51 void OnResume();
52
53 bool on_battery_power_;
54 scoped_refptr<PowerMessageFilter> message_filter_;
55 scoped_refptr<base::MessageLoopProxy> message_loop_;
56 base::WeakPtrFactory<PowerMonitorBroadcastSource> weak_factory_;
57 };
58
59 } // namespace content
60
61 #endif // CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698