| Index: content/common/child_process_host.h
|
| diff --git a/content/common/child_process_host.h b/content/common/child_process_host.h
|
| index 8637c184c9cf9cc3fce8128d51cc1d53f7ba7504..da9edfb5d71463590ae4ace4e66685a586efd6f7 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"
|
|
|
| @@ -27,6 +28,12 @@ namespace IPC {
|
| class Message;
|
| }
|
|
|
| +#if defined(OS_WIN)
|
| +// Types used in PreCacheFont
|
| +typedef std::vector<std::wstring> FontNameVector;
|
| +typedef std::map<int, FontNameVector> PidToFontNames;
|
| +#endif // defined(OS_WIN)
|
| +
|
| // Provides common functionality for hosting a child process and processing IPC
|
| // messages between the host and the child process. Subclasses are responsible
|
| // for the actual launching and terminating of the child processes.
|
| @@ -86,7 +93,8 @@ class 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);
|
| + static void ReleaseCachedFont(int pid);
|
| #endif // defined(OS_WIN)
|
|
|
| // IPC::Message::Sender implementation.
|
| @@ -143,6 +151,33 @@ class ChildProcessHost : public IPC::Channel::Listener,
|
|
|
| ListenerHook listener_;
|
|
|
| +#if defined (OS_WIN)
|
| + class FontCache {
|
| + public:
|
| + FontCache() {} // Make Singleton<> happy.
|
| + ~FontCache() {}
|
| +
|
| + static FontCache* GetInstance();
|
| + void PreCacheFont(LOGFONT font, int pid);
|
| + void ReleaseCachedFont(int pid);
|
| +
|
| + private:
|
| + struct CacheElement {
|
| + CacheElement();
|
| + ~CacheElement();
|
| +
|
| + HFONT font_;
|
| + HDC dc_;
|
| + int ref_count_;
|
| + };
|
| + std::map<std::wstring, CacheElement> cache_;
|
| + PidToFontNames 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_;
|
|
|