diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 19:18:45 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-20 19:18:45 +0000 |
commit | 6fc87e0160e55c5ea05ea7f9834a146598685458 (patch) | |
tree | c5d2d6987e4ab9fe5710cc965a95b2e993141086 /ppapi/proxy | |
parent | b31580d250c3813b99fdd88a03e27d07fca9e236 (diff) | |
download | chromium_src-6fc87e0160e55c5ea05ea7f9834a146598685458.zip chromium_src-6fc87e0160e55c5ea05ea7f9834a146598685458.tar.gz chromium_src-6fc87e0160e55c5ea05ea7f9834a146598685458.tar.bz2 |
Hook up the PPB_Flash.PreloadFontWin function to our font loading infrastructure.
TEST=manual
Review URL: http://codereview.chromium.org/8979002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115158 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 14 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.h | 24 | ||||
-rw-r--r-- | ppapi/proxy/plugin_globals.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/plugin_globals.h | 11 | ||||
-rw-r--r-- | ppapi/proxy/plugin_proxy_delegate.h | 37 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_proxy_test.cc | 18 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_proxy_test.h | 23 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 8 | ||||
-rw-r--r-- | ppapi/proxy/ppb_font_proxy.cc | 10 | ||||
-rw-r--r-- | ppapi/proxy/ppb_tcp_socket_private_proxy.cc | 11 | ||||
-rw-r--r-- | ppapi/proxy/ppb_udp_socket_private_proxy.cc | 11 |
11 files changed, 102 insertions, 69 deletions
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index 3da15e9..c1eca3f 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -193,20 +193,6 @@ InstanceData* PluginDispatcher::GetInstanceData(PP_Instance instance) { return (it == instance_map_.end()) ? NULL : &it->second; } -void PluginDispatcher::PostToWebKitThread( - const tracked_objects::Location& from_here, - const base::Closure& task) { - return plugin_delegate_->PostToWebKitThread(from_here, task); -} - -bool PluginDispatcher::SendToBrowser(IPC::Message* msg) { - return plugin_delegate_->SendToBrowser(msg); -} - -WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { - return plugin_delegate_->GetWebKitForwarding(); -} - FunctionGroupBase* PluginDispatcher::GetFunctionAPI(ApiID id) { return GetInterfaceProxy(id); } diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h index fcfacfb..31fe221 100644 --- a/ppapi/proxy/plugin_dispatcher.h +++ b/ppapi/proxy/plugin_dispatcher.h @@ -50,20 +50,6 @@ class PPAPI_PROXY_EXPORT PluginDispatcher : public Dispatcher { // DEREFERENCE ONLY ON THE I/O THREAD. virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() = 0; - // Returns the WebKit forwarding object used to make calls into WebKit. - // Necessary only on the plugin side. - virtual WebKitForwarding* GetWebKitForwarding() = 0; - - // Posts the given task to the WebKit thread associated with this plugin - // process. The WebKit thread should be lazily created if it does not - // exist yet. - virtual void PostToWebKitThread(const tracked_objects::Location& from_here, - const base::Closure& task) = 0; - - // Sends the given message to the browser. Identical semantics to - // IPC::Message::Sender interface. - virtual bool SendToBrowser(IPC::Message* msg) = 0; - // Registers the plugin dispatcher and returns an ID. // Plugin dispatcher IDs will be used to dispatch messages from the browser. // Each call to Register() has to be matched with a call to Unregister(). @@ -120,16 +106,6 @@ class PPAPI_PROXY_EXPORT PluginDispatcher : public Dispatcher { // correspond to a known instance. InstanceData* GetInstanceData(PP_Instance instance); - // Posts the given task to the WebKit thread. - void PostToWebKitThread(const tracked_objects::Location& from_here, - const base::Closure& task); - - // Calls the PluginDelegate.SendToBrowser function. - bool SendToBrowser(IPC::Message* msg); - - // Returns the WebKitForwarding object used to forward events to WebKit. - WebKitForwarding* GetWebKitForwarding(); - // Returns the Preferences. const Preferences& preferences() const { return preferences_; } diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc index 6fad009..e5acc4c0 100644 --- a/ppapi/proxy/plugin_globals.cc +++ b/ppapi/proxy/plugin_globals.cc @@ -11,7 +11,9 @@ namespace proxy { PluginGlobals* PluginGlobals::plugin_globals_ = NULL; -PluginGlobals::PluginGlobals() : ppapi::PpapiGlobals() { +PluginGlobals::PluginGlobals() + : ppapi::PpapiGlobals(), + plugin_proxy_delegate_(NULL) { DCHECK(!plugin_globals_); plugin_globals_ = this; } diff --git a/ppapi/proxy/plugin_globals.h b/ppapi/proxy/plugin_globals.h index 9192c92..a76b7f0 100644 --- a/ppapi/proxy/plugin_globals.h +++ b/ppapi/proxy/plugin_globals.h @@ -14,6 +14,8 @@ namespace ppapi { namespace proxy { +class PluginProxyDelegate; + class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { public: PluginGlobals(); @@ -39,9 +41,18 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { return &plugin_var_tracker_; } + // The embedder should call set_proxy_delegate during startup. + PluginProxyDelegate* plugin_proxy_delegate() { + return plugin_proxy_delegate_; + } + void set_plugin_proxy_delegate(PluginProxyDelegate* d) { + plugin_proxy_delegate_ = d; + } + private: static PluginGlobals* plugin_globals_; + PluginProxyDelegate* plugin_proxy_delegate_; PluginResourceTracker plugin_resource_tracker_; PluginVarTracker plugin_var_tracker_; diff --git a/ppapi/proxy/plugin_proxy_delegate.h b/ppapi/proxy/plugin_proxy_delegate.h new file mode 100644 index 0000000..07287ed --- /dev/null +++ b/ppapi/proxy/plugin_proxy_delegate.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_PLUGIN_PROXY_DELEGATE_H_ +#define PPAPI_PROXY_PLUGIN_PROXY_DELEGATE_H_ + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT PluginProxyDelegate { + public: + virtual ~PluginProxyDelegate() {} + + // Returns the WebKit forwarding object used to make calls into WebKit. + // Necessary only on the plugin side. + virtual WebKitForwarding* GetWebKitForwarding() = 0; + + // Posts the given task to the WebKit thread associated with this plugin + // process. The WebKit thread should be lazily created if it does not + // exist yet. + virtual void PostToWebKitThread(const tracked_objects::Location& from_here, + const base::Closure& task) = 0; + + // Sends the given message to the browser. Identical semantics to + // IPC::Message::Sender interface. + virtual bool SendToBrowser(IPC::Message* msg) = 0; + + // Performs Windows-specific font caching in the browser for the given + // LOGFONTW. Does nothing on non-Windows platforms. + virtual void PreCacheFont(const void* logfontw) = 0; +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PLUGIN_PROXY_DELEGATE_H_ diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc index 484253b..8ab8c36 100644 --- a/ppapi/proxy/ppapi_proxy_test.cc +++ b/ppapi/proxy/ppapi_proxy_test.cc @@ -200,6 +200,15 @@ PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() { return &instance_id_set_; } +uint32 PluginProxyTestHarness::PluginDelegateMock::Register( + PluginDispatcher* plugin_dispatcher) { + return 0; +} + +void PluginProxyTestHarness::PluginDelegateMock::Unregister( + uint32 plugin_dispatcher_id) { +} + ppapi::WebKitForwarding* PluginProxyTestHarness::PluginDelegateMock::GetWebKitForwarding() { NOTREACHED(); @@ -217,13 +226,8 @@ bool PluginProxyTestHarness::PluginDelegateMock::SendToBrowser( return false; } -uint32 PluginProxyTestHarness::PluginDelegateMock::Register( - PluginDispatcher* plugin_dispatcher) { - return 0; -} - -void PluginProxyTestHarness::PluginDelegateMock::Unregister( - uint32 plugin_dispatcher_id) { +void PluginProxyTestHarness::PluginDelegateMock::PreCacheFont( + const void* logfontw) { } // PluginProxyTest ------------------------------------------------------------- diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h index cf71a5e..2a612ed 100644 --- a/ppapi/proxy/ppapi_proxy_test.h +++ b/ppapi/proxy/ppapi_proxy_test.h @@ -14,6 +14,7 @@ #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/plugin_var_tracker.h" #include "testing/gtest/include/gtest/gtest.h" @@ -95,7 +96,8 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase { bool is_client); virtual void TearDownHarness(); - class PluginDelegateMock : public PluginDispatcher::PluginDelegate { + class PluginDelegateMock : public PluginDispatcher::PluginDelegate, + public PluginProxyDelegate { public: PluginDelegateMock() : ipc_message_loop_(NULL), shutdown_event_() {} virtual ~PluginDelegateMock() {} @@ -107,17 +109,20 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase { } // ProxyChannel::Delegate implementation. - virtual base::MessageLoopProxy* GetIPCMessageLoop(); - virtual base::WaitableEvent* GetShutdownEvent(); + virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; + virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; // PluginDispatcher::PluginDelegate implementation. - virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet(); - virtual ppapi::WebKitForwarding* GetWebKitForwarding(); + virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE; + virtual uint32 Register(PluginDispatcher* plugin_dispatcher) OVERRIDE; + virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE; + + // PluginPepperDelegate implementation. + virtual ppapi::WebKitForwarding* GetWebKitForwarding() OVERRIDE; virtual void PostToWebKitThread(const tracked_objects::Location& from_here, - const base::Closure& task); - virtual bool SendToBrowser(IPC::Message* msg); - virtual uint32 Register(PluginDispatcher* plugin_dispatcher); - virtual void Unregister(uint32 plugin_dispatcher_id); + const base::Closure& task) OVERRIDE; + virtual bool SendToBrowser(IPC::Message* msg) OVERRIDE; + virtual void PreCacheFont(const void* logfontw) OVERRIDE; private: base::MessageLoopProxy* ipc_message_loop_; // Weak diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index ae12cd0..97f7711e 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -14,6 +14,8 @@ #include "ppapi/c/private/ppb_flash.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/proxy_module.h" #include "ppapi/proxy/serialized_var.h" @@ -183,8 +185,8 @@ PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { return StringVar::StringToPPVar(args); } -void PreLoadFontInWindows(const void* logfontw) { - // TODO(brettw) implement this. +void PreLoadFontWin(const void* logfontw) { + PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw); } const PPB_Flash_11 flash_interface_11 = { @@ -207,7 +209,7 @@ const PPB_Flash flash_interface_12 = { &QuitMessageLoop, &GetLocalTimeZoneOffset, &GetCommandLineArgs, - &PreLoadFontInWindows + &PreLoadFontWin }; } // namespace diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index e411981..49d3892 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -8,6 +8,8 @@ #include "base/debug/trace_event.h" #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/serialized_var.h" @@ -61,7 +63,7 @@ PP_Var PPB_Font_Proxy::GetFontFamilies(PP_Instance instance) { // Assume the font families don't change, so we can cache the result globally. CR_DEFINE_STATIC_LOCAL(std::string, families, ()); if (families.empty()) { - dispatcher->SendToBrowser( + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( new PpapiHostMsg_PPBFont_GetFontFamilies(&families)); } @@ -85,7 +87,8 @@ Font::Font(const HostResource& resource, PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); if (!dispatcher) return; - WebKitForwarding* forwarding = dispatcher->GetWebKitForwarding(); + WebKitForwarding* forwarding = + PluginGlobals::Get()->plugin_proxy_delegate()->GetWebKitForwarding(); RunOnWebKitThread(true, base::Bind(&WebKitForwarding::CreateFontForwarding, @@ -214,7 +217,8 @@ int32_t Font::PixelOffsetForCharacter(const PP_TextRun_Dev* text, } void Font::RunOnWebKitThread(bool blocking, const base::Closure& task) { - PluginDispatcher::GetForResource(this)->PostToWebKitThread(FROM_HERE, task); + PluginGlobals::Get()->plugin_proxy_delegate()->PostToWebKitThread( + FROM_HERE, task); if (blocking) webkit_event_.Wait(); } diff --git a/ppapi/proxy/ppb_tcp_socket_private_proxy.cc b/ppapi/proxy/ppb_tcp_socket_private_proxy.cc index b943889..42420e3 100644 --- a/ppapi/proxy/ppb_tcp_socket_private_proxy.cc +++ b/ppapi/proxy/ppb_tcp_socket_private_proxy.cc @@ -8,6 +8,8 @@ #include "base/logging.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" @@ -86,7 +88,7 @@ void TCPSocket::SendDisconnect() { } void TCPSocket::SendToBrowser(IPC::Message* msg) { - PluginDispatcher::GetForResource(this)->SendToBrowser(msg); + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); } } // namespace @@ -108,9 +110,10 @@ PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResource( return 0; uint32 socket_id = 0; - dispatcher->SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Create( - API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), - &socket_id)); + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PpapiHostMsg_PPBTCPSocket_Create( + API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), + &socket_id)); if (socket_id == 0) return 0; return (new TCPSocket(HostResource::MakeInstanceOnly(instance), diff --git a/ppapi/proxy/ppb_udp_socket_private_proxy.cc b/ppapi/proxy/ppb_udp_socket_private_proxy.cc index 444a7da..0716033 100644 --- a/ppapi/proxy/ppb_udp_socket_private_proxy.cc +++ b/ppapi/proxy/ppb_udp_socket_private_proxy.cc @@ -8,6 +8,8 @@ #include "base/logging.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/private/udp_socket_private_impl.h" @@ -73,7 +75,7 @@ void UDPSocket::SendClose() { } void UDPSocket::SendToBrowser(IPC::Message* msg) { - PluginDispatcher::GetForResource(this)->SendToBrowser(msg); + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(msg); } } // namespace @@ -95,9 +97,10 @@ PP_Resource PPB_UDPSocket_Private_Proxy::CreateProxyResource( return 0; uint32 socket_id = 0; - dispatcher->SendToBrowser(new PpapiHostMsg_PPBUDPSocket_Create( - API_ID_PPB_UDPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), - &socket_id)); + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PpapiHostMsg_PPBUDPSocket_Create( + API_ID_PPB_UDPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), + &socket_id)); if (socket_id == 0) return 0; |