Commit 0e244ee9 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Share DWriteFontProxyImpl TaskRunner to DWriteFontLookupTableBuilder

Preparation for a follow-up CL that actually making queries for the font
lookup table asynchronous. In that CL, DWriteFontLookupTableBuilder
needs the task runner to run the Mojo message callback on the same task
runner on which DWriteFontProxyImpl received it.

Move scheduling the lookup table construction to
common_browser_interfaces.cc which is still around the same time in
startup as before, but makes it much easier to share the same task
runner.

Bug: 960263, 889864
Tbr: avi
Change-Id: I8be6d4a4d29014967d38f20ccf8a94948a7b8a1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626865
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663021}
parent c9a367be
......@@ -1420,11 +1420,6 @@ int BrowserMainLoop::BrowserThreadsStarted() {
switches::kDisableGpuProcessForDX12VulkanInfoCollection)) {
GpuDataManagerImpl::GetInstance()->RequestGpuSupportedRuntimeVersion();
}
if (base::FeatureList::IsEnabled(features::kFontSrcLocalMatching)) {
content::DWriteFontLookupTableBuilder::GetInstance()
->SchedulePrepareFontUniqueNameTableIfNeeded();
}
#endif
if (MediaKeysListenerManager::IsMediaKeysListenerManagerEnabled()) {
......
......@@ -17,8 +17,10 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/singleton.h"
#include "base/optional.h"
#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
......@@ -44,6 +46,13 @@ class CONTENT_EXPORT DWriteFontLookupTableBuilder {
public:
static DWriteFontLookupTableBuilder* GetInstance();
// Configure the task runner that will be used for posting tasks to when
// executing Mojo result callbacks that were passed from DWriteFontProxyImpl.
void SetCallbackTaskRunner(
scoped_refptr<base::SequencedTaskRunner> callback_task_runner) {
callback_task_runner_ = callback_task_runner;
}
// Retrieve the prepared memory region if it is available.
// EnsureFontUniqueNameTable() must be checked before.
base::ReadOnlySharedMemoryRegion DuplicateMemoryRegion();
......@@ -191,6 +200,7 @@ class CONTENT_EXPORT DWriteFontLookupTableBuilder {
bool caching_enabled_ = true;
base::Optional<base::WaitableEvent> hang_event_for_testing_;
base::CancelableOnceCallback<void()> timeout_callback_;
scoped_refptr<base::SequencedTaskRunner> callback_task_runner_;
DISALLOW_COPY_AND_ASSIGN(DWriteFontLookupTableBuilder);
};
......
......@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "base/task/post_task.h"
#include "base/task_runner.h"
......@@ -23,6 +24,7 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/connection_filter.h"
#include "content/public/common/content_features.h"
#include "content/public/common/service_manager_connection.h"
#include "content/public/common/service_names.mojom.h"
#include "mojo/public/cpp/bindings/interface_request.h"
......@@ -45,10 +47,19 @@ class ConnectionFilterImpl : public ConnectionFilter {
ConnectionFilterImpl() {
#if defined(OS_WIN)
registry_.AddInterface(base::BindRepeating(&FontCacheDispatcher::Create));
registry_.AddInterface(
base::BindRepeating(&DWriteFontProxyImpl::Create),
auto dwrite_font_proxy_task_runner =
base::CreateSequencedTaskRunnerWithTraits(
{base::TaskPriority::USER_BLOCKING, base::MayBlock()}));
{base::TaskPriority::USER_BLOCKING, base::MayBlock()});
registry_.AddInterface(base::BindRepeating(&DWriteFontProxyImpl::Create),
dwrite_font_proxy_task_runner);
if (base::FeatureList::IsEnabled(features::kFontSrcLocalMatching)) {
content::DWriteFontLookupTableBuilder::GetInstance()
->SetCallbackTaskRunner(dwrite_font_proxy_task_runner);
content::DWriteFontLookupTableBuilder::GetInstance()
->SchedulePrepareFontUniqueNameTableIfNeeded();
}
#elif defined(OS_MACOSX)
registry_.AddInterface(
base::BindRepeating(&SandboxSupportMacImpl::BindRequest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment