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" | |
8 #include "base/threading/thread.h" | |
7 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
8 #include "content/public/common/dwrite_font_platform_win.h" | 10 #include "content/public/common/dwrite_font_platform_win.h" |
9 #include "content/public/utility/utility_thread.h" | 11 #include "content/public/utility/utility_thread.h" |
10 | 12 |
11 bool FontCacheHandler::OnMessageReceived(const IPC::Message& message) { | 13 bool FontCacheHandler::OnMessageReceived(const IPC::Message& message) { |
12 bool handled = true; | 14 bool handled = true; |
13 IPC_BEGIN_MESSAGE_MAP(FontCacheHandler, message) | 15 IPC_BEGIN_MESSAGE_MAP(FontCacheHandler, message) |
14 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_BuildDirectWriteFontCache, | 16 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_BuildDirectWriteFontCache, |
15 OnBuildFontCache) | 17 OnBuildFontCache) |
16 IPC_MESSAGE_UNHANDLED(handled = false) | 18 IPC_MESSAGE_UNHANDLED(handled = false) |
17 IPC_END_MESSAGE_MAP() | 19 IPC_END_MESSAGE_MAP() |
18 return handled; | 20 return handled; |
19 } | 21 } |
20 | 22 |
21 void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { | 23 void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) { |
24 DCHECK(!cache_thread_); | |
25 | |
26 utility_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); | |
scottmg
2015/03/17 05:28:17
This is in preparation for a cancellation message?
| |
27 | |
28 // Create worker thread for building font cache. | |
29 cache_thread_.reset(new base::Thread("cache_thread")); | |
30 if (!cache_thread_->Start()) { | |
31 NOTREACHED(); | |
32 return; | |
33 } | |
34 cache_thread_->message_loop()->PostTask( | |
35 FROM_HERE, base::Bind(&FontCacheHandler::StartBuildingFontCache, | |
36 base::Unretained(this), | |
37 full_path)); | |
38 } | |
39 | |
40 void FontCacheHandler::StartBuildingFontCache(const base::FilePath& full_path) { | |
22 content::BuildFontCache(full_path); | 41 content::BuildFontCache(full_path); |
42 utility_task_runner_->PostTask(FROM_HERE, | |
43 base::Bind(&FontCacheHandler::Cleanup, | |
44 base::Unretained(this))); | |
45 } | |
46 | |
47 void FontCacheHandler::Cleanup() { | |
48 cache_thread_.reset(); | |
23 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 49 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
24 } | 50 } |
OLD | NEW |