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

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: Addressing vandebo's feedback, part 2 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/power_monitor/power_monitor_source.h"
10 #include "ipc/ipc_channel.h"
11 #include "ipc/ipc_channel_proxy.h"
12
13 namespace content {
14
15 // Receives Power Monitor IPC messages sent from the browser process and relays
16 // them to the PowerMonitor of the current process.
17 class PowerMonitorBroadcastSource : public base::PowerMonitorSource {
18 public:
19 PowerMonitorBroadcastSource();
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 explicit PowerMessageFilter(
30 base::WeakPtr<PowerMonitorBroadcastSource> source);
31
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33
34 private:
35 friend class base::RefCounted<PowerMessageFilter>;
36
37 virtual ~PowerMessageFilter();
38
39 void OnPowerStateChange(bool on_battery_power);
40 void OnSuspend();
41 void OnResume();
42
43 base::WeakPtr<PowerMonitorBroadcastSource> source_;
44
45 DISALLOW_COPY_AND_ASSIGN(PowerMessageFilter);
46 };
47
48 virtual bool IsOnBatteryPowerImpl() OVERRIDE;
49
50 void OnPowerStateChange(bool on_battery_power);
51 void OnSuspend();
52 void OnResume();
53
54 bool last_reported_battery_power_state_;
55 scoped_refptr<PowerMessageFilter> message_filter_;
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