diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 23:11:00 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 23:11:00 +0000 |
commit | a1d19d7439593f3bca7a0b4b8cc3be442a3c1272 (patch) | |
tree | c5283d114b189c1b49e360ec6f4c826a0c698dcf /ppapi | |
parent | 5d0e7c20c442eb9c375b9dfd74c267f0ed90f04c (diff) | |
download | chromium_src-a1d19d7439593f3bca7a0b4b8cc3be442a3c1272.zip chromium_src-a1d19d7439593f3bca7a0b4b8cc3be442a3c1272.tar.gz chromium_src-a1d19d7439593f3bca7a0b4b8cc3be442a3c1272.tar.bz2 |
Add a function to the Flash interface to get the current time zone offset.
TEST=manual
BUG=none
Review URL: http://codereview.chromium.org/6881059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/private/ppb_flash.h | 6 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 18 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h index dbea227..cb33851 100644 --- a/ppapi/c/private/ppb_flash.h +++ b/ppapi/c/private/ppb_flash.h @@ -10,9 +10,10 @@ #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" -#define PPB_FLASH_INTERFACE "PPB_Flash;8" +#define PPB_FLASH_INTERFACE "PPB_Flash;9" struct PPB_Flash { // Sets or clears the rendering hint that the given plugin instance is always @@ -51,6 +52,9 @@ struct PPB_Flash { // Posts a quit message for the outermost nested message loop. Use this to // exit and return back to the caller after you call RunMessageLoop. void (*QuitMessageLoop)(PP_Instance instance); + + // Retrieves the local time zone offset from GM time for the given UTC time. + double (*GetLocalTimeZoneOffset)(PP_Time t); }; #endif // PPAPI_C_PRIVATE_PPB_FLASH_H_ diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 6e3fcd6..83c9b63 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/message_loop.h" +#include "base/time.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_resource.h" @@ -127,6 +128,22 @@ void QuitMessageLoop(PP_Instance instance) { INTERFACE_ID_PPB_FLASH, instance)); } +double GetLocalTimeZoneOffset(PP_Time t) { + // Somewhat horrible: Explode it to local time and then unexplode it as if + // it were UTC. Also explode it to UTC and unexplode it (this avoids + // mismatching rounding or lack thereof). The time zone offset is their + // difference. + // + // TODO(brettw) this is duplicated in ppb_flash_impl.cc, unify these! + base::Time cur = base::Time::FromDoubleT(t); + base::Time::Exploded exploded; + cur.LocalExplode(&exploded); + base::Time adj_time = base::Time::FromUTCExploded(exploded); + cur.UTCExplode(&exploded); + cur = base::Time::FromUTCExploded(exploded); + return (adj_time - cur).InSecondsF(); +} + const PPB_Flash flash_interface = { &SetInstanceAlwaysOnTop, &DrawGlyphs, @@ -134,6 +151,7 @@ const PPB_Flash flash_interface = { &Navigate, &RunMessageLoop, &QuitMessageLoop, + &GetLocalTimeZoneOffset }; InterfaceProxy* CreateFlashProxy(Dispatcher* dispatcher, |