Index: content/common/child_process_host.h |
diff --git a/content/common/child_process_host.h b/content/common/child_process_host.h |
index 20708c254ca7acb6f48a51a0dfd902695ced6b69..16f962ed147367a70e3b41e2c835c2894880397a 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 |
rvargas (doing something else)
2011/09/13 23:40:30
Comments should end with period.
These are fairly
arthurhsu
2011/09/14 02:06:56
Done.
|
+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); |
rvargas (doing something else)
2011/09/13 23:40:30
This doesn't release a font... releases all fonts
arthurhsu
2011/09/14 02:06:56
Done.
|
#endif // defined(OS_WIN) |
// IPC::Message::Sender implementation. |
@@ -148,6 +156,33 @@ class ChildProcessHost : public IPC::Channel::Listener, |
ListenerHook listener_; |
+#if defined (OS_WIN) |
+ class FontCache { |
+ public: |
+ FontCache() {} // Make Singleton<> happy. |
rvargas (doing something else)
2011/09/13 23:40:30
friend struct DefaultSingletonTraits<FontCache>;
arthurhsu
2011/09/14 02:06:56
Done.
|
+ ~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_; |