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

Unified Diff: components/font_service/public/cpp/font_service_thread.cc

Issue 1916003002: Fixes possible deadlock in fontservice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/font_service/public/cpp/font_service_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/font_service/public/cpp/font_service_thread.cc
diff --git a/components/font_service/public/cpp/font_service_thread.cc b/components/font_service/public/cpp/font_service_thread.cc
index 062aa93ed04aac61c7ff3238afda562d9d340e19..36ca646d5595709d73309f31a5045b7a3144da08 100644
--- a/components/font_service/public/cpp/font_service_thread.cc
+++ b/components/font_service/public/cpp/font_service_thread.cc
@@ -22,7 +22,8 @@ const char kFontThreadName[] = "Font_Proxy_Thread";
FontServiceThread::FontServiceThread(FontServicePtr font_service)
: base::Thread(kFontThreadName),
- font_service_info_(font_service.PassInterface()) {
+ font_service_info_(font_service.PassInterface()),
+ weak_factory_(this) {
base::Thread::Options options;
options.message_pump_factory =
base::Bind(&mojo::common::MessagePumpMojo::Create);
@@ -147,6 +148,7 @@ void FontServiceThread::OpenStreamImpl(base::WaitableEvent* done_event,
return;
}
+ pending_waitable_events_.insert(done_event);
font_service_->OpenStream(
id_number, base::Bind(&FontServiceThread::OnOpenStreamComplete, this,
done_event, output_file));
@@ -155,6 +157,7 @@ void FontServiceThread::OpenStreamImpl(base::WaitableEvent* done_event,
void FontServiceThread::OnOpenStreamComplete(base::WaitableEvent* done_event,
base::File* output_file,
mojo::ScopedHandle handle) {
+ pending_waitable_events_.erase(done_event);
if (handle.is_valid()) {
MojoPlatformHandle platform_handle;
CHECK(MojoExtractPlatformHandle(handle.release().value(),
@@ -165,8 +168,18 @@ void FontServiceThread::OnOpenStreamComplete(base::WaitableEvent* done_event,
done_event->Signal();
}
+void FontServiceThread::OnFontServiceConnectionError() {
+ std::set<base::WaitableEvent*> events;
+ events.swap(pending_waitable_events_);
+ for (base::WaitableEvent* event : events)
+ event->Signal();
+}
+
void FontServiceThread::Init() {
font_service_.Bind(std::move(font_service_info_));
+ font_service_.set_connection_error_handler(
+ base::Bind(&FontServiceThread::OnFontServiceConnectionError,
+ weak_factory_.GetWeakPtr()));
}
void FontServiceThread::CleanUp() {
« no previous file with comments | « components/font_service/public/cpp/font_service_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698