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

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc

Issue 2182213004: Use ChildThreadImpl::thread_safe_sender in font proxy if available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h"
6 6
7 #include <dwrite.h> 7 #include <dwrite.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DWORD get_proc_address_get_last_error = GetLastError(); 53 DWORD get_proc_address_get_last_error = GetLastError();
54 base::debug::Alias(&dwrite_create_factory_proc); 54 base::debug::Alias(&dwrite_create_factory_proc);
55 base::debug::Alias(&get_proc_address_get_last_error); 55 base::debug::Alias(&get_proc_address_get_last_error);
56 CHECK(false); 56 CHECK(false);
57 } 57 }
58 CHECK(SUCCEEDED(dwrite_create_factory_proc( 58 CHECK(SUCCEEDED(dwrite_create_factory_proc(
59 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), 59 DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory),
60 reinterpret_cast<IUnknown**>(factory)))); 60 reinterpret_cast<IUnknown**>(factory))));
61 } 61 }
62 62
63 // Needed as a function for Bind()
64 IPC::Sender* GetSenderOverride() {
65 return g_sender_override;
66 }
67
63 } // namespace 68 } // namespace
64 69
65 void InitializeDWriteFontProxy() { 70 void InitializeDWriteFontProxy(
71 const base::Callback<IPC::Sender*(void)>& sender) {
66 mswr::ComPtr<IDWriteFactory> factory; 72 mswr::ComPtr<IDWriteFactory> factory;
67 73
68 CreateDirectWriteFactory(&factory); 74 CreateDirectWriteFactory(&factory);
69 75
70 if (!g_font_collection) { 76 if (!g_font_collection) {
71 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( 77 if (g_sender_override) {
72 &g_font_collection, factory.Get(), g_sender_override); 78 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
79 &g_font_collection, factory.Get(), base::Bind(&GetSenderOverride));
80 } else {
81 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(&g_font_collection,
82 factory.Get(), sender);
83 }
73 } 84 }
74 85
75 mswr::ComPtr<IDWriteFontFallback> font_fallback; 86 mswr::ComPtr<IDWriteFontFallback> font_fallback;
76 mswr::ComPtr<IDWriteFactory2> factory2; 87 mswr::ComPtr<IDWriteFactory2> factory2;
77 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) { 88 if (SUCCEEDED(factory.As(&factory2)) && factory2.Get()) {
78 mswr::MakeAndInitialize<FontFallback>( 89 mswr::MakeAndInitialize<FontFallback>(
79 &font_fallback, g_font_collection.Get(), g_sender_override); 90 &font_fallback, g_font_collection.Get(), g_sender_override);
80 } 91 }
81 92
82 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( 93 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite(
(...skipping 21 matching lines...) Expand all
104 void UninitializeDWriteFontProxy() { 115 void UninitializeDWriteFontProxy() {
105 if (g_font_collection) 116 if (g_font_collection)
106 g_font_collection->Unregister(); 117 g_font_collection->Unregister();
107 } 118 }
108 119
109 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { 120 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) {
110 g_sender_override = sender; 121 g_sender_override = sender;
111 } 122 }
112 123
113 } // namespace content 124 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698