| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_browser_font_singleton_hos
t.h" | 5 #include "content/browser/renderer_host/pepper/pepper_browser_font_singleton_hos
t.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "content/common/font_list.h" | 12 #include "content/common/font_list.h" |
| 14 #include "content/public/browser/browser_ppapi_host.h" | 13 #include "content/public/browser/browser_ppapi_host.h" |
| 15 #include "content/public/browser/browser_thread.h" | |
| 16 #include "ppapi/host/dispatch_host_message.h" | 14 #include "ppapi/host/dispatch_host_message.h" |
| 17 #include "ppapi/host/resource_message_filter.h" | 15 #include "ppapi/host/resource_message_filter.h" |
| 18 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 19 | 17 |
| 20 namespace content { | 18 namespace content { |
| 21 | 19 |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 // Handles the font list request on the blocking pool. | 22 // Handles the font list request on the blocking pool. |
| 25 class FontMessageFilter : public ppapi::host::ResourceMessageFilter { | 23 class FontMessageFilter : public ppapi::host::ResourceMessageFilter { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 41 | 39 |
| 42 DISALLOW_COPY_AND_ASSIGN(FontMessageFilter); | 40 DISALLOW_COPY_AND_ASSIGN(FontMessageFilter); |
| 43 }; | 41 }; |
| 44 | 42 |
| 45 FontMessageFilter::FontMessageFilter() {} | 43 FontMessageFilter::FontMessageFilter() {} |
| 46 | 44 |
| 47 FontMessageFilter::~FontMessageFilter() {} | 45 FontMessageFilter::~FontMessageFilter() {} |
| 48 | 46 |
| 49 scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage( | 47 scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage( |
| 50 const IPC::Message& msg) { | 48 const IPC::Message& msg) { |
| 51 // Use the blocking pool to get the font list (currently the only message) | 49 // Use the font list SequencedTaskRunner to get the font list (currently the |
| 52 // Since getting the font list is non-threadsafe on Linux (for versions of | 50 // only message) since getting the font list is non-threadsafe on Linux (for |
| 53 // Pango predating 2013), use a sequenced task runner. | 51 // versions of Pango predating 2013). |
| 54 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 52 return GetFontListTaskRunner(); |
| 55 return pool->GetSequencedTaskRunner( | |
| 56 pool->GetNamedSequenceToken(kFontListSequenceToken)); | |
| 57 } | 53 } |
| 58 | 54 |
| 59 int32_t FontMessageFilter::OnResourceMessageReceived( | 55 int32_t FontMessageFilter::OnResourceMessageReceived( |
| 60 const IPC::Message& msg, | 56 const IPC::Message& msg, |
| 61 ppapi::host::HostMessageContext* context) { | 57 ppapi::host::HostMessageContext* context) { |
| 62 PPAPI_BEGIN_MESSAGE_MAP(FontMessageFilter, msg) | 58 PPAPI_BEGIN_MESSAGE_MAP(FontMessageFilter, msg) |
| 63 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( | 59 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( |
| 64 PpapiHostMsg_BrowserFontSingleton_GetFontFamilies, | 60 PpapiHostMsg_BrowserFontSingleton_GetFontFamilies, |
| 65 OnHostMsgGetFontFamilies) | 61 OnHostMsgGetFontFamilies) |
| 66 PPAPI_END_MESSAGE_MAP() | 62 PPAPI_END_MESSAGE_MAP() |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 PP_Instance instance, | 99 PP_Instance instance, |
| 104 PP_Resource resource) | 100 PP_Resource resource) |
| 105 : ResourceHost(host->GetPpapiHost(), instance, resource) { | 101 : ResourceHost(host->GetPpapiHost(), instance, resource) { |
| 106 AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>( | 102 AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>( |
| 107 new FontMessageFilter())); | 103 new FontMessageFilter())); |
| 108 } | 104 } |
| 109 | 105 |
| 110 PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() {} | 106 PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() {} |
| 111 | 107 |
| 112 } // namespace content | 108 } // namespace content |
| OLD | NEW |