Commit 5f7fe46e authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Set proper PPAPI SandBoxSupport thread check

Replace current ThreadId check with a sequence checker.

We also add a test that tests font fallback, so
PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter
actually gets tested somewhere.

Bug: 866645
Change-Id: I743eb9cd6a1004c25074b907a50e9b4cf680f805
Reviewed-on: https://chromium-review.googlesource.com/1165312Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581302}
parent 4fc29843
...@@ -66,9 +66,9 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport { ...@@ -66,9 +66,9 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
// unicode code points. It needs this information frequently so we cache it // unicode code points. It needs this information frequently so we cache it
// here. // here.
std::map<int32_t, blink::WebFallbackFont> unicode_font_families_; std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
// For debugging crbug.com/312965
base::PlatformThreadId creation_thread_;
sk_sp<font_service::FontLoader> font_loader_; sk_sp<font_service::FontLoader> font_loader_;
// For debugging https://crbug.com/312965
base::SequenceCheckerImpl creation_thread_sequence_checker_;
#endif #endif
}; };
...@@ -86,9 +86,7 @@ bool PpapiBlinkPlatformImpl::SandboxSupport::LoadFont(CTFontRef src_font, ...@@ -86,9 +86,7 @@ bool PpapiBlinkPlatformImpl::SandboxSupport::LoadFont(CTFontRef src_font,
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() {}
: creation_thread_(base::PlatformThread::CurrentId()) {
}
void PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter( void PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter(
WebUChar32 character, WebUChar32 character,
...@@ -96,7 +94,7 @@ void PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter( ...@@ -96,7 +94,7 @@ void PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter(
blink::WebFallbackFont* fallbackFont) { blink::WebFallbackFont* fallbackFont) {
ppapi::ProxyLock::AssertAcquired(); ppapi::ProxyLock::AssertAcquired();
// For debugging crbug.com/312965 // For debugging crbug.com/312965
CHECK_EQ(creation_thread_, base::PlatformThread::CurrentId()); CHECK(creation_thread_sequence_checker_.CalledOnValidSequence());
const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter = const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
unicode_font_families_.find(character); unicode_font_families_.find(character);
if (iter != unicode_font_families_.end()) { if (iter != unicode_font_families_.end()) {
......
...@@ -54,8 +54,12 @@ std::string TestBrowserFont::TestMeasure() { ...@@ -54,8 +54,12 @@ std::string TestBrowserFont::TestMeasure() {
int32_t length1 = font.MeasureText(pp::BrowserFontTextRun("WWW")); int32_t length1 = font.MeasureText(pp::BrowserFontTextRun("WWW"));
ASSERT_TRUE(length1 > 0); ASSERT_TRUE(length1 > 0);
int32_t length2 = font.MeasureText(pp::BrowserFontTextRun("WWWWWWWW")); int32_t length2 = font.MeasureText(pp::BrowserFontTextRun("WWWWWWWW"));
ASSERT_TRUE(length2 >= length1 * 2); ASSERT_TRUE(length2 >= length1 * 2);
// Fallback font test.
int32_t length3 = font.MeasureText(pp::BrowserFontTextRun("こんにちは"));
ASSERT_TRUE(length3 > 0);
PASS(); PASS();
} }
......
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