Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / utility / font_cache_handler_win.cc
blobcf850c0798c97a0ef167bba37d323f9abf2ade3a
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
3 // found in the LICENSE file.
5 #include "chrome/utility/font_cache_handler_win.h"
7 #include "base/task_runner_util.h"
8 #include "base/threading/thread.h"
9 #include "chrome/common/chrome_utility_messages.h"
10 #include "content/public/common/dwrite_font_platform_win.h"
11 #include "content/public/utility/utility_thread.h"
13 FontCacheHandler::FontCacheHandler() {
16 FontCacheHandler::~FontCacheHandler() {
19 bool FontCacheHandler::OnMessageReceived(const IPC::Message& message) {
20 bool handled = true;
21 IPC_BEGIN_MESSAGE_MAP(FontCacheHandler, message)
22 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_BuildDirectWriteFontCache,
23 OnBuildFontCache)
24 IPC_MESSAGE_UNHANDLED(handled = false)
25 IPC_END_MESSAGE_MAP()
26 return handled;
29 void FontCacheHandler::OnBuildFontCache(const base::FilePath& full_path) {
30 DCHECK(!cache_thread_);
32 utility_task_runner_ = base::MessageLoop::current()->task_runner();
34 // Create worker thread for building font cache.
35 cache_thread_.reset(new base::Thread("font_cache_thread"));
36 if (!cache_thread_->Start()) {
37 NOTREACHED();
38 return;
40 cache_thread_->message_loop()->PostTask(
41 FROM_HERE, base::Bind(&FontCacheHandler::StartBuildingFontCache,
42 base::Unretained(this),
43 full_path));
46 void FontCacheHandler::StartBuildingFontCache(const base::FilePath& full_path) {
47 content::BuildFontCache(full_path);
48 utility_task_runner_->PostTask(FROM_HERE,
49 base::Bind(&FontCacheHandler::Cleanup,
50 base::Unretained(this)));
53 void FontCacheHandler::Cleanup() {
54 cache_thread_.reset();
55 content::UtilityThread::Get()->ReleaseProcessIfNeeded();