Chromium Code Reviews| Index: content/common/child_process_host.h |
| diff --git a/content/common/child_process_host.h b/content/common/child_process_host.h |
| index 5b965b9132ffad7835ca31500fd55504be2e8a35..e8e808c87b33c507f0569800b9739c6c5f28d8ba 100644 |
| --- a/content/common/child_process_host.h |
| +++ b/content/common/child_process_host.h |
| @@ -8,6 +8,7 @@ |
| #include <string> |
| #include <vector> |
| +#include <map> |
| #include "build/build_config.h" |
| @@ -17,6 +18,8 @@ |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/singleton.h" |
| +#include "base/string16.h" |
| #include "content/common/content_export.h" |
| #include "content/common/content_notification_types.h" |
| #include "ipc/ipc_channel_proxy.h" |
| @@ -87,7 +90,8 @@ class CONTENT_EXPORT ChildProcessHost : public IPC::Channel::Listener, |
| #if defined(OS_WIN) |
| // See comments in the cc file. This is a common hack needed for a process |
| // hosting a sandboxed child process. Hence it lives in this file. |
| - static void PreCacheFont(LOGFONT font); |
| + static void PreCacheFont(LOGFONT font, int pid); |
|
jam
2011/09/19 21:27:49
nit: here and below, and also in the cc file, thes
arthurhsu
2011/09/19 22:47:32
Done.
|
| + static void ReleaseCachedFonts(int pid); |
| #endif // defined(OS_WIN) |
| // IPC::Message::Sender implementation. |
| @@ -156,6 +160,35 @@ class CONTENT_EXPORT ChildProcessHost : public IPC::Channel::Listener, |
| ListenerHook listener_; |
| +#if defined (OS_WIN) |
| + class FontCache { |
| + public: |
| + static FontCache* GetInstance(); |
| + void PreCacheFont(LOGFONT font, int pid); |
| + void ReleaseCachedFonts(int pid); |
| + |
| + private: |
| + struct CacheElement { |
| + CacheElement(); |
| + ~CacheElement(); |
| + |
| + HFONT font_; |
| + HDC dc_; |
| + int ref_count_; |
| + }; |
| + friend struct DefaultSingletonTraits<FontCache>; |
| + |
| + FontCache(); |
| + ~FontCache(); |
| + |
| + std::map<string16, CacheElement> cache_; |
| + std::map<int, std::vector<string16> > pid_font_map_; |
| + base::Lock mutex_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FontCache); |
| + }; |
| +#endif |
| + |
| bool opening_channel_; // True while we're waiting the channel to be opened. |
| scoped_ptr<IPC::Channel> channel_; |
| std::string channel_id_; |