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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc

Issue 13458002: Use sequenced workers for the getting the system's font list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use sequenced workers Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/renderer_host/pepper/pepper_truetype_font_list_host.h" 5 #include "content/browser/renderer_host/pepper/pepper_truetype_font_list_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/safe_numerics.h" 9 #include "base/safe_numerics.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h" 11 #include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
12 #include "content/common/font_list.h"
12 #include "content/public/browser/browser_ppapi_host.h" 13 #include "content/public/browser/browser_ppapi_host.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "ppapi/host/dispatch_host_message.h" 15 #include "ppapi/host/dispatch_host_message.h"
15 #include "ppapi/host/host_message_context.h" 16 #include "ppapi/host/host_message_context.h"
16 #include "ppapi/host/resource_message_filter.h" 17 #include "ppapi/host/resource_message_filter.h"
17 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
(...skipping 20 matching lines...) Expand all
42 }; 43 };
43 44
44 FontMessageFilter::FontMessageFilter() { 45 FontMessageFilter::FontMessageFilter() {
45 } 46 }
46 47
47 FontMessageFilter::~FontMessageFilter() { 48 FontMessageFilter::~FontMessageFilter() {
48 } 49 }
49 50
50 scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage( 51 scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage(
51 const IPC::Message& msg) { 52 const IPC::Message& msg) {
52 // Use the blocking pool to get the font list (currently the only message 53 // Use the blocking pool to get the font list (currently the only message)
53 // so we can always just return it). 54 // Since getting the font list is non-threadsafe on Linux (for versions of
54 return scoped_refptr<base::TaskRunner>(BrowserThread::GetBlockingPool()); 55 // Pango predating 2013), use a sequenced task runner.
56 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
57 return pool->GetSequencedTaskRunner(
58 pool->GetNamedSequenceToken(kFontListSequenceToken));
55 } 59 }
56 60
57 int32_t FontMessageFilter::OnResourceMessageReceived( 61 int32_t FontMessageFilter::OnResourceMessageReceived(
58 const IPC::Message& msg, 62 const IPC::Message& msg,
59 ppapi::host::HostMessageContext* context) { 63 ppapi::host::HostMessageContext* context) {
60 IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg) 64 IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg)
61 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( 65 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
62 PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies, 66 PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies,
63 OnHostMsgGetFontFamilies) 67 OnHostMsgGetFontFamilies)
64 IPC_END_MESSAGE_MAP() 68 IPC_END_MESSAGE_MAP()
(...skipping 25 matching lines...) Expand all
90 PP_Resource resource) 94 PP_Resource resource)
91 : ResourceHost(host->GetPpapiHost(), instance, resource) { 95 : ResourceHost(host->GetPpapiHost(), instance, resource) {
92 AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>( 96 AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>(
93 new FontMessageFilter())); 97 new FontMessageFilter()));
94 } 98 }
95 99
96 PepperTrueTypeFontListHost::~PepperTrueTypeFontListHost() { 100 PepperTrueTypeFontListHost::~PepperTrueTypeFontListHost() {
97 } 101 }
98 102
99 } // namespace content 103 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698