Changeset 160444 in webkit


Ignore:
Timestamp:
Dec 11, 2013 10:16:48 AM (10 years ago)
Author:
zandobersek@gmail.com
Message:

[GTK] Add a UPower-based BatteryProvider
https://bugs.webkit.org/show_bug.cgi?id=115719

Reviewed by Martin Robinson.

Source/Platform:

  • GNUmakefile.am: Add the Source/WebCore/platform/glib directory to the list of directories searched

for header inclusion. Add the upower-glib dependency CFLAGS to the list of libPlatform's CPPFLAGS.

Source/WebCore:

Introduce the BatteryProviderUPower, a provider of the system's battery status that produces the information
using the upower-glib library.

The BatteryProviderUPower creates a new UPower client when the provider should start emitting updates and hooks
up to device alteration signals. These only fire recalculation of the battery status when a battery device is altered.

When recalculating, every battery device is taken into account, accumulating the energy capacities when both empty
and full, the current rate of energy charging/discharging, and the battery status (whether the device is charging or
discharging). This gives a set of data that covers the overall battery status of the system.

This data is then used to calculate the battery status as perceived by the WebCore implementation. Charging is determined
by examining the integral sign of the current combined energy rate. Charging and discharging times are calculated, when
appropriate, by dividing the chargable/dischargable capacity with the current combined energy rate. The battery level is
calculated by dividing the current energy capacity with the full energy capacity (i.e. the combined capacity of all
the batteries that the system possesses). The status is (indirectly) passed onto BatteryManager by invoking the
updateBatteryStatus method on the client, with the first parameter representing the battery charging/discharging state,
the second parameter representing the time left until the battery is fully charged (when charging) or fully
depleted (when discharging), and the third parameter representing the current battery level.

Whenever the implementation cannot provide any information about the battery status of the system, the client's
updateBatteryStatus method is invoked with the first parameter reporting the unavailability of any information
about the battery status. The other two parameters can be omitted as they default to 0 when not given and are neither
available nor useful in such circumstances. The client should handle such an update by reporting the 'default' battery
status - charging, the battery level being at 1.0 and both the charging and discharging time having the value of
the positive infinity (as per the Battery Status API specification).

The implementation is heavily inspired by a similar approach to calculating battery status in GNOME Settings Daemon.

No new tests - no new functionality. The feature is not yet enabled. When enabled, the relevant tests pass.

  • GNUmakefile.list.am: Add the BatteryProviderUPower(Client) build targets.
  • platform/glib/BatteryProviderUPower.cpp: Added.

(powerDeviceAlterationCallback):
(BatteryProviderUPower::BatteryProviderUPower):
(BatteryProviderUPower::startUpdating):
(BatteryProviderUPower::stopUpdating):
(BatteryProviderUPower::updateBatteryStatus):

  • platform/glib/BatteryProviderUPower.h: Added.

(WebCore):
(BatteryProviderUPower):

  • platform/glib/BatteryProviderUPowerClient.h: Added.

(WebCore):
(BatteryProviderUPowerClient):

Source/WebKit/gtk:

  • GNUmakefile.am: Link the libwebkigtk library against the upower-glib library.

Source/WebKit2:

  • GNUmakefile.am: Link the libwebkit2gtk library against the upower-glib library.
Location:
trunk/Source
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r159971 r160444  
     12013-12-11  José Dapena Paz  <jdapena@igalia.com> and Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK] Add a UPower-based BatteryProvider
     4        https://bugs.webkit.org/show_bug.cgi?id=115719
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Add the Source/WebCore/platform/glib directory to the list of directories searched
     9        for header inclusion. Add the upower-glib dependency CFLAGS to the list of libPlatform's CPPFLAGS.
     10
    1112013-12-02  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
    212
  • trunk/Source/Platform/GNUmakefile.am

    r158848 r160444  
    2929        -I$(srcdir)/Source/WebCore/platform/cairo \
    3030        -I$(srcdir)/Source/WebCore/platform/geoclue \
     31        -I$(srcdir)/Source/WebCore/platform/glib \
    3132        -I$(srcdir)/Source/WebCore/platform/graphics \
    3233        -I$(srcdir)/Source/WebCore/platform/graphics/cairo \
     
    9697        $(GEOCLUE_CFLAGS) \
    9798        $(GSTREAMER_CFLAGS) \
    98         $(LIBSOUP_CFLAGS)
     99        $(LIBSOUP_CFLAGS) \
     100        $(UPOWER_GLIB_CFLAGS)
    99101
    100102libPlatformGtk_la_SOURCES = \
  • trunk/Source/WebCore/ChangeLog

    r160436 r160444  
     12013-12-11  José Dapena Paz  <jdapena@igalia.com> and Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK] Add a UPower-based BatteryProvider
     4        https://bugs.webkit.org/show_bug.cgi?id=115719
     5
     6        Reviewed by Martin Robinson.
     7
     8        Introduce the BatteryProviderUPower, a provider of the system's battery status that produces the information
     9        using the upower-glib library.
     10
     11        The BatteryProviderUPower creates a new UPower client when the provider should start emitting updates and hooks
     12        up to device alteration signals. These only fire recalculation of the battery status when a battery device is altered.
     13
     14        When recalculating, every battery device is taken into account, accumulating the energy capacities when both empty
     15        and full, the current rate of energy charging/discharging, and the battery status (whether the device is charging or
     16        discharging). This gives a set of data that covers the overall battery status of the system.
     17
     18        This data is then used to calculate the battery status as perceived by the WebCore implementation. Charging is determined
     19        by examining the integral sign of the current combined energy rate. Charging and discharging times are calculated, when
     20        appropriate, by dividing the chargable/dischargable capacity with the current combined energy rate. The battery level is
     21        calculated by dividing the current energy capacity with the full energy capacity (i.e. the combined capacity of all
     22        the batteries that the system possesses). The status is (indirectly) passed onto BatteryManager by invoking the
     23        updateBatteryStatus method on the client, with the first parameter representing the battery charging/discharging state,
     24        the second parameter representing the time left until the battery is fully charged (when charging) or fully
     25        depleted (when discharging), and the third parameter representing the current battery level.
     26
     27        Whenever the implementation cannot provide any information about the battery status of the system, the client's
     28        updateBatteryStatus method is invoked with the first parameter reporting the unavailability of any information
     29        about the battery status. The other two parameters can be omitted as they default to 0 when not given and are neither
     30        available nor useful in such circumstances. The client should handle such an update by reporting the 'default' battery
     31        status - charging, the battery level being at 1.0 and both the charging and discharging time having the value of
     32        the positive infinity (as per the Battery Status API specification).
     33
     34        The implementation is heavily inspired by a similar approach to calculating battery status in GNOME Settings Daemon.
     35
     36        No new tests - no new functionality. The feature is not yet enabled. When enabled, the relevant tests pass.
     37
     38        * GNUmakefile.list.am: Add the BatteryProviderUPower(Client) build targets.
     39        * platform/glib/BatteryProviderUPower.cpp: Added.
     40        (powerDeviceAlterationCallback):
     41        (BatteryProviderUPower::BatteryProviderUPower):
     42        (BatteryProviderUPower::startUpdating):
     43        (BatteryProviderUPower::stopUpdating):
     44        (BatteryProviderUPower::updateBatteryStatus):
     45        * platform/glib/BatteryProviderUPower.h: Added.
     46        (WebCore):
     47        (BatteryProviderUPower):
     48        * platform/glib/BatteryProviderUPowerClient.h: Added.
     49        (WebCore):
     50        (BatteryProviderUPowerClient):
     51
    1522013-12-11  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
    253
  • trunk/Source/WebCore/GNUmakefile.list.am

    r160336 r160444  
    55865586        Source/WebCore/platform/geoclue/GeolocationProviderGeoclue.cpp \
    55875587        Source/WebCore/platform/geoclue/GeolocationProviderGeoclueClient.h \
     5588        Source/WebCore/platform/glib/BatteryProviderUPowerClient.h \
     5589        Source/WebCore/platform/glib/BatteryProviderUPower.cpp \
     5590        Source/WebCore/platform/glib/BatteryProviderUPower.h \
    55885591        Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp \
    55895592        Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp \
  • trunk/Source/WebKit/gtk/ChangeLog

    r160437 r160444  
     12013-12-11  José Dapena Paz  <jdapena@igalia.com> and Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK] Add a UPower-based BatteryProvider
     4        https://bugs.webkit.org/show_bug.cgi?id=115719
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Link the libwebkigtk library against the upower-glib library.
     9
    1102013-12-11  José Dapena Paz  <jdapena@igalia.com> and Zan Dobersek  <zdobersek@igalia.com>
    211
  • trunk/Source/WebKit/gtk/GNUmakefile.am

    r160437 r160444  
    127127        $(SQLITE3_LIBS) \
    128128        $(UNICODE_LIBS) \
     129        $(UPOWER_GLIB_LIBS) \
    129130        $(WEBP_LIBS) \
    130131        $(XCOMPOSITE_LIBS) \
  • trunk/Source/WebKit2/ChangeLog

    r160435 r160444  
     12013-12-11  José Dapena Paz  <jdapena@igalia.com> and Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK] Add a UPower-based BatteryProvider
     4        https://bugs.webkit.org/show_bug.cgi?id=115719
     5
     6        Reviewed by Martin Robinson.
     7
     8        * GNUmakefile.am: Link the libwebkit2gtk library against the upower-glib library.
     9
    1102013-12-11  Gustavo Noronha Silva  <gns@gnome.org>
    211
  • trunk/Source/WebKit2/GNUmakefile.am

    r160304 r160444  
    286286        $(SQLITE3_LIBS) \
    287287        $(UNICODE_LIBS) \
     288        $(UPOWER_GLIB_LIBS) \
    288289        $(WEBP_LIBS) \
    289290        $(XRENDER_LIBS) \
Note: See TracChangeset for help on using the changeset viewer.