Chromium Code Reviews| Index: chrome/utility/font_cache_handler_win.cc |
| diff --git a/chrome/utility/font_cache_handler_win.cc b/chrome/utility/font_cache_handler_win.cc |
| index 19e097ba542694d5ec274f978125cf00fc6a727b..de4df0b40936c0e4c2dc3bab2dff4646a320802a 100644 |
| --- a/chrome/utility/font_cache_handler_win.cc |
| +++ b/chrome/utility/font_cache_handler_win.cc |
| @@ -4,6 +4,8 @@ |
| #include "chrome/utility/font_cache_handler_win.h" |
| +#include "base/task_runner_util.h" |
| +#include "base/threading/thread.h" |
| #include "chrome/common/chrome_utility_messages.h" |
| #include "content/public/common/dwrite_font_platform_win.h" |
| #include "content/public/utility/utility_thread.h" |
| @@ -19,6 +21,30 @@ bool FontCacheHandler::OnMessageReceived(const IPC::Message& message) { |
| } |
| void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { |
| + DCHECK(!cache_thread_); |
| + |
| + utility_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); |
|
scottmg
2015/03/17 05:28:17
This is in preparation for a cancellation message?
|
| + |
| + // Create worker thread for building font cache. |
| + cache_thread_.reset(new base::Thread("cache_thread")); |
| + if (!cache_thread_->Start()) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + cache_thread_->message_loop()->PostTask( |
| + FROM_HERE, base::Bind(&FontCacheHandler::StartBuildingFontCache, |
| + base::Unretained(this), |
| + full_path)); |
| +} |
| + |
| +void FontCacheHandler::StartBuildingFontCache(const base::FilePath& full_path) { |
| content::BuildFontCache(full_path); |
| + utility_task_runner_->PostTask(FROM_HERE, |
| + base::Bind(&FontCacheHandler::Cleanup, |
| + base::Unretained(this))); |
| +} |
| + |
| +void FontCacheHandler::Cleanup() { |
| + cache_thread_.reset(); |
| content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| } |