Skip to content

Commit

Permalink
Set proper PPAPI SandBoxSupport thread check
Browse files Browse the repository at this point in the history
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/1165312
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581302}
  • Loading branch information
Fernando Serboncini authored and Commit Bot committed Aug 7, 2018
1 parent 4fc2984 commit 5f7fe46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 4 additions & 6 deletions content/ppapi_plugin/ppapi_blink_platform_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class PpapiBlinkPlatformImpl::SandboxSupport : public WebSandboxSupport {
// unicode code points. It needs this information frequently so we cache it
// here.
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_;
// For debugging https://crbug.com/312965
base::SequenceCheckerImpl creation_thread_sequence_checker_;
#endif
};

Expand All @@ -86,17 +86,15 @@ bool PpapiBlinkPlatformImpl::SandboxSupport::LoadFont(CTFontRef src_font,

#elif defined(OS_POSIX)

PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport()
: creation_thread_(base::PlatformThread::CurrentId()) {
}
PpapiBlinkPlatformImpl::SandboxSupport::SandboxSupport() {}

void PpapiBlinkPlatformImpl::SandboxSupport::GetFallbackFontForCharacter(
WebUChar32 character,
const char* preferred_locale,
blink::WebFallbackFont* fallbackFont) {
ppapi::ProxyLock::AssertAcquired();
// 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 =
unicode_font_families_.find(character);
if (iter != unicode_font_families_.end()) {
Expand Down
6 changes: 5 additions & 1 deletion ppapi/tests/test_browser_font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ std::string TestBrowserFont::TestMeasure() {
int32_t length1 = font.MeasureText(pp::BrowserFontTextRun("WWW"));
ASSERT_TRUE(length1 > 0);
int32_t length2 = font.MeasureText(pp::BrowserFontTextRun("WWWWWWWW"));

ASSERT_TRUE(length2 >= length1 * 2);

// Fallback font test.
int32_t length3 = font.MeasureText(pp::BrowserFontTextRun("こんにちは"));
ASSERT_TRUE(length3 > 0);

PASS();
}

Expand Down

0 comments on commit 5f7fe46

Please sign in to comment.