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

Side by Side Diff: chrome/browser/battery_status_provider_chromeos.cc

Issue 10024013: chromeos: Add support for the battery status API on chromeos. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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) 2012 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 #include "chrome/browser/battery_status_provider_chromeos.h"
6
7 #include "chromeos/dbus/dbus_thread_manager.h"
8 #include "content/public/browser/battery_status_provider.h"
9
10 using namespace chromeos;
11
12 BatteryStatusProviderChromeos* BatteryStatusProviderChromeos::GetInstance() {
13 return Singleton<BatteryStatusProviderChromeos>::get();
14 }
15
16 BatteryStatusProviderChromeos::BatteryStatusProviderChromeos() {
17 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
18 }
19
20 BatteryStatusProviderChromeos::~BatteryStatusProviderChromeos() {
21 // By the time this singleton gets destroyed, the DBusThreadManager has
22 // already been destroyed. so do not remove the observer here.
23 }
24
25 void BatteryStatusProviderChromeos::PowerChanged(
26 const PowerSupplyStatus& status) {
27 content::PowerSupplyStatus content_status;
28 content_status.line_power_on = status.line_power_on;
29 content_status.battery_is_present = status.battery_is_present;
30 content_status.battery_is_full = status.battery_is_full;
31 content_status.battery_seconds_to_empty = status.battery_seconds_to_empty;
32 content_status.battery_seconds_to_full = status.battery_seconds_to_full;
33 content_status.battery_percentage = status.battery_percentage;
34 content_status.is_calculating_battery_time =
35 status.is_calculating_battery_time;
36 content::BatteryStatusProvider::GetInstance()->SendUpdate(content_status);
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698