Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Unified Diff: content/common/child_process_host.h

Issue 7866019: New implementation of font precache on Windows. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update per code review Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_message_filter.cc ('k') | content/common/child_process_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ef659405444cf142bc9d691a2fabb121bae1e5aa 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,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
#include "content/common/content_notification_types.h"
#include "ipc/ipc_channel_proxy.h"
@@ -86,7 +88,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 ReleaseCachedFonts(int pid);
#endif // defined(OS_WIN)
// IPC::Message::Sender implementation.
@@ -148,6 +151,35 @@ class 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_;
+ };
+
+ FontCache(); // Make Singleton<> happy.
rvargas (doing something else) 2011/09/14 03:05:05 nit: remove the comment.
arthurhsu 2011/09/14 20:25:48 Done.
+ ~FontCache();
+
+ std::map<std::wstring, CacheElement> cache_;
+ std::map<int, std::vector<std::wstring> > pid_font_map_;
+ base::Lock mutex_;
+
+ DISALLOW_COPY_AND_ASSIGN(FontCache);
rvargas (doing something else) 2011/09/14 03:05:05 This should be the last item on the class... struc
arthurhsu 2011/09/14 20:25:48 Done.
+ friend struct DefaultSingletonTraits<FontCache>;
+ };
+#endif
+
bool opening_channel_; // True while we're waiting the channel to be opened.
scoped_ptr<IPC::Channel> channel_;
std::string channel_id_;
« no previous file with comments | « content/browser/renderer_host/render_message_filter.cc ('k') | content/common/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698