diff options
Diffstat (limited to 'ppapi/proxy/ppb_flash_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 55dc897..632c40a 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -31,6 +31,7 @@ #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/resource_tracker.h" #include "ppapi/shared_impl/scoped_pp_resource.h" +#include "ppapi/shared_impl/time_conversion.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_instance_api.h" @@ -541,16 +542,31 @@ void PPB_Flash_Proxy::QuitMessageLoop(PP_Instance instance) { double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { - // TODO(brettw) on Windows it should be possible to do the time calculation - // in-process since it doesn't need to read files on disk. This will improve - // performance. +#if defined(OS_LINUX) + // On Linux localtime needs access to the filesystem, which is prohibited + // by the sandbox. It would be better to go directly to the browser process + // for this message rather than proxy it through some instance in a renderer. // - // On Linux, it would be better to go directly to the browser process for - // this message rather than proxy it through some instance in a renderer. + // Or we could cache the offset and whether DST is active, similar to what + // V8 does. double result = 0; dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( API_ID_PPB_FLASH, instance, t, &result)); return result; +#else + base::Time cur = PPTimeToTime(t); + base::Time::Exploded exploded = { 0 }; + base::Time::Exploded utc_exploded = { 0 }; + cur.LocalExplode(&exploded); + cur.UTCExplode(&utc_exploded); + if (exploded.HasValidValues() && utc_exploded.HasValidValues()) { + base::Time adj_time = base::Time::FromUTCExploded(exploded); + base::Time cur = base::Time::FromUTCExploded(utc_exploded); + return (adj_time - cur).InSecondsF(); + } else { + return 0.0; + } +#endif } PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, |