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

Side by Side Diff: content/renderer/battery_status/battery_status_dispatcher.h

Issue 446603002: Refactor code listening to platform events in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webkitplatform_impl_start_stop
Patch Set: cleaner Created 6 years, 4 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
6 #define CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_ 6 #define CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
7 7
8 #include "content/public/renderer/render_process_observer.h" 8 #include "content/public/renderer/platform_event_observer.h"
9 9
10 namespace blink { 10 namespace blink {
11 class WebBatteryStatus; 11 class WebBatteryStatus;
12 class WebBatteryStatusListener; 12 class WebBatteryStatusListener;
13 } 13 }
14 14
15 namespace content { 15 namespace content {
16 class RenderThread; 16 class RenderThread;
17 17
18 class CONTENT_EXPORT BatteryStatusDispatcher : public RenderProcessObserver { 18 class CONTENT_EXPORT BatteryStatusDispatcher
19 : public PlatformEventObserver<blink::WebBatteryStatusListener> {
19 public: 20 public:
20 explicit BatteryStatusDispatcher(RenderThread* thread); 21 explicit BatteryStatusDispatcher(RenderThread* thread);
21 virtual ~BatteryStatusDispatcher(); 22 virtual ~BatteryStatusDispatcher();
22 23
23 // RenderProcessObserver method. 24 // PlatformEventObserver public methods.
24 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 25 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
25 26 virtual void SendFakeDataForTesting(void* data) OVERRIDE;
26 // Sets the listener to receive battery status updates. Returns true if the
27 // registration was successful.
28 bool SetListener(blink::WebBatteryStatusListener* listener);
29 27
30 protected: 28 protected:
31 virtual bool Start(); 29 // PlatformEventObserver protected methods.
32 virtual bool Stop(); 30 virtual void SendStartMessage() OVERRIDE;
31 virtual void SendStopMessage() OVERRIDE;
33 32
34 private: 33 private:
35 void OnDidChange(const blink::WebBatteryStatus& status); 34 void OnDidChange(const blink::WebBatteryStatus& status);
36 35
37 blink::WebBatteryStatusListener* listener_;
38
39 DISALLOW_COPY_AND_ASSIGN(BatteryStatusDispatcher); 36 DISALLOW_COPY_AND_ASSIGN(BatteryStatusDispatcher);
40 }; 37 };
41 38
42 } // namespace content 39 } // namespace content
43 40
44 #endif // CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_ 41 #endif // CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698