diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 15:58:42 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 15:58:42 +0000 |
commit | 2872d7d601be4141fd488c69f26d7718841c7462 (patch) | |
tree | 97b8f3b871671cb0c36b8a1bbe9a3f644f0886ba | |
parent | 83c0f7cc5aa3bba61e0b5cdc88635825fdef24c9 (diff) | |
download | chromium_src-2872d7d601be4141fd488c69f26d7718841c7462.zip chromium_src-2872d7d601be4141fd488c69f26d7718841c7462.tar.gz chromium_src-2872d7d601be4141fd488c69f26d7718841c7462.tar.bz2 |
Merge 82575 - Proxy time zone requests to the browser. This is because the current codecan't run in the sandbox on Linux.TEST=manualBUG=80176Review URL: http://codereview.chromium.org/6891001
TBR=brettw@chromium.org
TEST=80176
Review URL: http://codereview.chromium.org/6899026
git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@82655 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/pepper_message_filter.cc | 25 | ||||
-rw-r--r-- | content/browser/renderer_host/pepper_message_filter.h | 3 | ||||
-rw-r--r-- | content/common/pepper_messages.h | 3 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.cc | 7 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.h | 1 | ||||
-rw-r--r-- | ppapi/c/private/ppb_flash.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 37 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 1 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_flash_impl.cc | 23 |
13 files changed, 83 insertions, 35 deletions
diff --git a/content/browser/renderer_host/pepper_message_filter.cc b/content/browser/renderer_host/pepper_message_filter.cc index 061d1f4..9cec785 100644 --- a/content/browser/renderer_host/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper_message_filter.cc @@ -44,17 +44,17 @@ PepperMessageFilter::~PepperMessageFilter() {} bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg, bool* message_was_ok) { -#if defined(ENABLE_FLAPPER_HACKS) bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(PepperMessageFilter, msg, *message_was_ok) +#if defined(ENABLE_FLAPPER_HACKS) IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcp, OnConnectTcp) IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpAddress, OnConnectTcpAddress) +#endif // ENABLE_FLAPPER_HACKS + IPC_MESSAGE_HANDLER(PepperMsg_GetLocalTimeZoneOffset, + OnGetLocalTimeZoneOffset) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() return handled; -#else - return false; -#endif // ENABLE_FLAPPER_HACKS } #if defined(ENABLE_FLAPPER_HACKS) @@ -278,3 +278,20 @@ void PepperMessageFilter::ConnectTcpAddressOnWorkerThread( } #endif // ENABLE_FLAPPER_HACKS + +void PepperMessageFilter::OnGetLocalTimeZoneOffset(base::Time t, + double* result) { + // 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. + // + // The reason for this processing being in the browser process is that on + // Linux, the localtime calls require filesystem access prohibited by the + // sandbox. + base::Time::Exploded exploded; + t.LocalExplode(&exploded); + base::Time adj_time = base::Time::FromUTCExploded(exploded); + t.UTCExplode(&exploded); + base::Time cur = base::Time::FromUTCExploded(exploded); + *result = (adj_time - cur).InSecondsF(); +} diff --git a/content/browser/renderer_host/pepper_message_filter.h b/content/browser/renderer_host/pepper_message_filter.h index 3b7bc81..dbd2f77 100644 --- a/content/browser/renderer_host/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper_message_filter.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/process.h" +#include "base/time.h" #include "content/browser/browser_message_filter.h" #include "ppapi/c/private/ppb_flash_net_connector.h" @@ -64,6 +65,8 @@ class PepperMessageFilter : public BrowserMessageFilter { PP_Flash_NetAddress addr); #endif // ENABLE_FLAPPER_HACKS + void OnGetLocalTimeZoneOffset(base::Time t, double* result); + const content::ResourceContext* const resource_context_; }; diff --git a/content/common/pepper_messages.h b/content/common/pepper_messages.h index 440a2c8..5a84626 100644 --- a/content/common/pepper_messages.h +++ b/content/common/pepper_messages.h @@ -50,3 +50,6 @@ IPC_MESSAGE_CONTROL3(PepperMsg_ConnectTcpAddress, int /* request_id */, PP_Flash_NetAddress /* addr */) +IPC_SYNC_MESSAGE_CONTROL1_1(PepperMsg_GetLocalTimeZoneOffset, + base::Time /* t */, + double /* result */) diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index 31bdc50..b137536 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -1182,3 +1182,10 @@ P2PSocketDispatcher* PepperPluginDelegateImpl::GetP2PSocketDispatcher() { webkit_glue::P2PTransport* PepperPluginDelegateImpl::CreateP2PTransport() { return new P2PTransportImpl(render_view_->p2p_socket_dispatcher()); } + +double PepperPluginDelegateImpl::GetLocalTimeZoneOffset(base::Time t) { + double result = 0.0; + render_view_->Send(new PepperMsg_GetLocalTimeZoneOffset( + t, &result)); + return result; +} diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h index e337b2c..50f0824 100644 --- a/content/renderer/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper_plugin_delegate_impl.h @@ -252,6 +252,7 @@ class PepperPluginDelegateImpl virtual void SaveURLAs(const GURL& url); virtual P2PSocketDispatcher* GetP2PSocketDispatcher(); virtual webkit_glue::P2PTransport* CreateP2PTransport(); + virtual double GetLocalTimeZoneOffset(base::Time t); private: // Asynchronously attempts to create a PPAPI broker for the given plugin. diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h index cb33851..a46b813 100644 --- a/ppapi/c/private/ppb_flash.h +++ b/ppapi/c/private/ppb_flash.h @@ -13,7 +13,7 @@ #include "ppapi/c/pp_time.h" #include "ppapi/c/pp_var.h" -#define PPB_FLASH_INTERFACE "PPB_Flash;9" +#define PPB_FLASH_INTERFACE "PPB_Flash;10" struct PPB_Flash { // Sets or clears the rendering hint that the given plugin instance is always @@ -54,7 +54,7 @@ struct PPB_Flash { void (*QuitMessageLoop)(PP_Instance instance); // Retrieves the local time zone offset from GM time for the given UTC time. - double (*GetLocalTimeZoneOffset)(PP_Time t); + double (*GetLocalTimeZoneOffset)(PP_Instance instance, PP_Time t); }; #endif // PPAPI_C_PRIVATE_PPB_FLASH_H_ diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 8790c60..8f0eb6d 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -419,6 +419,10 @@ IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlash_RunMessageLoop, PP_Instance /* instance */) IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlash_QuitMessageLoop, PP_Instance /* instance */) +IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, + PP_Instance /* instance */, + PP_Time /* t */, + double /* offset */) // PPB_Flash_Clipboard. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlashClipboard_IsFormatAvailable, diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 83c9b63..1b93f36 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -115,7 +115,7 @@ void RunMessageLoop(PP_Instance instance) { if (!dispatcher) return; IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( - INTERFACE_ID_PPB_FLASH, instance); + INTERFACE_ID_PPB_FLASH, instance); msg->EnableMessagePumping(); dispatcher->Send(msg); } @@ -125,23 +125,24 @@ void QuitMessageLoop(PP_Instance instance) { if (!dispatcher) return; dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( - INTERFACE_ID_PPB_FLASH, 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. +double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return 0.0; + + // 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. // - // 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(); + // 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. + double result = 0; + dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( + INTERFACE_ID_PPB_FLASH, instance, t, &result)); + return result; } const PPB_Flash flash_interface = { @@ -260,5 +261,11 @@ void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { ppb_flash_target()->QuitMessageLoop(instance); } +void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, + PP_Time t, + double* result) { + *result = ppb_flash_target()->GetLocalTimeZoneOffset(instance, t); +} + } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index 9666e4b..4449bf5 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -10,6 +10,7 @@ #include "ipc/ipc_platform_file.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_time.h" #include "ppapi/proxy/host_resource.h" #include "ppapi/proxy/interface_proxy.h" @@ -51,6 +52,8 @@ class PPB_Flash_Proxy : public InterfaceProxy { int32_t* result); void OnMsgRunMessageLoop(PP_Instance instance); void OnMsgQuitMessageLoop(PP_Instance instance); + void OnMsgGetLocalTimeZoneOffset(PP_Instance instance, PP_Time t, + double* result); }; } // namespace proxy diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 4ac0a00..133226b 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -235,5 +235,9 @@ webkit_glue::P2PTransport* MockPluginDelegate::CreateP2PTransport() { return NULL; } +double MockPluginDelegate::GetLocalTimeZoneOffset(base::Time t) { + return 0.0; +} + } // namespace ppapi } // namespace webkit diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 32b80c7..4c3d740 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -102,6 +102,7 @@ class MockPluginDelegate : public PluginDelegate { virtual void SaveURLAs(const GURL& url); virtual P2PSocketDispatcher* GetP2PSocketDispatcher(); virtual webkit_glue::P2PTransport* CreateP2PTransport(); + virtual double GetLocalTimeZoneOffset(base::Time t); }; } // namespace ppapi diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index eefb1e6..761a808 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -13,6 +13,7 @@ #include "base/platform_file.h" #include "base/shared_memory.h" #include "base/sync_socket.h" +#include "base/time.h" #include "googleurl/src/gurl.h" #include "media/video/video_decode_accelerator.h" #include "ppapi/c/pp_completion_callback.h" @@ -387,6 +388,8 @@ class PluginDelegate { // Creates P2PTransport object. virtual webkit_glue::P2PTransport* CreateP2PTransport() = 0; + + virtual double GetLocalTimeZoneOffset(base::Time t) = 0; }; } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index db9be46..8599d9c 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -73,20 +73,15 @@ void QuitMessageLoop(PP_Instance instance) { MessageLoop::current()->QuitNow(); } -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_proxy.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(); +double GetLocalTimeZoneOffset(PP_Instance pp_instance, PP_Time t) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + if (!instance) + return 0.0; + + // We can't do the conversion here because on Linux, the localtime calls + // require filesystem access prohibited by the sandbox. + return instance->delegate()->GetLocalTimeZoneOffset( + base::Time::FromDoubleT(t)); } const PPB_Flash ppb_flash = { |