summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 23:39:06 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 23:39:06 +0000
commit09085fdb48ae2b3c094f0ee36f78172acf2b9f78 (patch)
tree78fc435cf85f5982efbb50e765c79d41aecf2755 /ppapi/proxy
parentb4d24f5e351cb94456584312a7a3862211f6d8ac (diff)
downloadchromium_src-09085fdb48ae2b3c094f0ee36f78172acf2b9f78.zip
chromium_src-09085fdb48ae2b3c094f0ee36f78172acf2b9f78.tar.gz
chromium_src-09085fdb48ae2b3c094f0ee36f78172acf2b9f78.tar.bz2
Perform GetLocalTimeZoneOffset in plugin process on Windows
Linux should be the only platform where the browser process is the only one that can determine the time zone offset, so on other platforms find the offset directly from the plugin process. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10494009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/ppb_flash_proxy.cc26
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,