| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/utility/font_cache_handler_win.h" | 5 #include "chrome/utility/font_cache_handler_win.h" |
| 6 | 6 |
| 7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
| 10 #include "content/public/common/dwrite_font_platform_win.h" | 10 #include "content/public/common/dwrite_font_platform_win.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_BuildDirectWriteFontCache, | 22 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_BuildDirectWriteFontCache, |
| 23 OnBuildFontCache) | 23 OnBuildFontCache) |
| 24 IPC_MESSAGE_UNHANDLED(handled = false) | 24 IPC_MESSAGE_UNHANDLED(handled = false) |
| 25 IPC_END_MESSAGE_MAP() | 25 IPC_END_MESSAGE_MAP() |
| 26 return handled; | 26 return handled; |
| 27 } | 27 } |
| 28 | 28 |
| 29 void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { | 29 void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { |
| 30 DCHECK(!cache_thread_); | 30 DCHECK(!cache_thread_); |
| 31 | 31 |
| 32 utility_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); | 32 utility_task_runner_ = base::MessageLoop::current()->task_runner(); |
| 33 | 33 |
| 34 // Create worker thread for building font cache. | 34 // Create worker thread for building font cache. |
| 35 cache_thread_.reset(new base::Thread("font_cache_thread")); | 35 cache_thread_.reset(new base::Thread("font_cache_thread")); |
| 36 if (!cache_thread_->Start()) { | 36 if (!cache_thread_->Start()) { |
| 37 NOTREACHED(); | 37 NOTREACHED(); |
| 38 return; | 38 return; |
| 39 } | 39 } |
| 40 cache_thread_->message_loop()->PostTask( | 40 cache_thread_->message_loop()->PostTask( |
| 41 FROM_HERE, base::Bind(&FontCacheHandler::StartBuildingFontCache, | 41 FROM_HERE, base::Bind(&FontCacheHandler::StartBuildingFontCache, |
| 42 base::Unretained(this), | 42 base::Unretained(this), |
| 43 full_path)); | 43 full_path)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void FontCacheHandler::StartBuildingFontCache(const base::FilePath& full_path) { | 46 void FontCacheHandler::StartBuildingFontCache(const base::FilePath& full_path) { |
| 47 content::BuildFontCache(full_path); | 47 content::BuildFontCache(full_path); |
| 48 utility_task_runner_->PostTask(FROM_HERE, | 48 utility_task_runner_->PostTask(FROM_HERE, |
| 49 base::Bind(&FontCacheHandler::Cleanup, | 49 base::Bind(&FontCacheHandler::Cleanup, |
| 50 base::Unretained(this))); | 50 base::Unretained(this))); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void FontCacheHandler::Cleanup() { | 53 void FontCacheHandler::Cleanup() { |
| 54 cache_thread_.reset(); | 54 cache_thread_.reset(); |
| 55 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 55 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 56 } | 56 } |
| OLD | NEW |