• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
6 #define CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
7 
8 #include "content/public/renderer/render_process_observer.h"
9 
10 namespace blink {
11 class WebBatteryStatus;
12 class WebBatteryStatusListener;
13 }
14 
15 namespace content {
16 class RenderThread;
17 
18 class CONTENT_EXPORT BatteryStatusDispatcher : public RenderProcessObserver {
19  public:
20   explicit BatteryStatusDispatcher(RenderThread* thread);
21   virtual ~BatteryStatusDispatcher();
22 
23   // RenderProcessObserver method.
24   virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
25 
26   // Sets the listener to receive battery status updates. Returns true if the
27   // registration was successful.
28   bool SetListener(blink::WebBatteryStatusListener* listener);
29 
30  protected:
31   virtual bool Start();
32   virtual bool Stop();
33 
34  private:
35   void OnDidChange(const blink::WebBatteryStatus& status);
36 
37   blink::WebBatteryStatusListener* listener_;
38 
39   DISALLOW_COPY_AND_ASSIGN(BatteryStatusDispatcher);
40 };
41 
42 }  // namespace content
43 
44 #endif  // CONTENT_RENDERER_BATTERY_STATUS_BATTERY_STATUS_DISPATCHER_H_
45