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

Side by Side Diff: components/font_service/public/cpp/font_service_thread.h

Issue 1916003002: Fixes possible deadlock in fontservice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | components/font_service/public/cpp/font_service_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_ 5 #ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_
6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_ 6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set>
11
10 #include "base/files/file.h" 12 #include "base/files/file.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
13 #include "components/font_service/public/interfaces/font_service.mojom.h" 16 #include "components/font_service/public/interfaces/font_service.mojom.h"
14 #include "third_party/skia/include/core/SkStream.h" 17 #include "third_party/skia/include/core/SkStream.h"
15 #include "third_party/skia/include/core/SkTypeface.h" 18 #include "third_party/skia/include/core/SkTypeface.h"
16 #include "third_party/skia/include/ports/SkFontConfigInterface.h" 19 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
17 20
18 namespace font_service { 21 namespace font_service {
19 namespace internal { 22 namespace internal {
20 23
21 class MappedFontFile; 24 class MappedFontFile;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 TypefaceStylePtr style); 75 TypefaceStylePtr style);
73 76
74 // Implementation of OpenStream; same threading restrictions as MatchFamily. 77 // Implementation of OpenStream; same threading restrictions as MatchFamily.
75 void OpenStreamImpl(base::WaitableEvent* done_event, 78 void OpenStreamImpl(base::WaitableEvent* done_event,
76 base::File* output_file, 79 base::File* output_file,
77 const uint32_t id_number); 80 const uint32_t id_number);
78 void OnOpenStreamComplete(base::WaitableEvent* done_event, 81 void OnOpenStreamComplete(base::WaitableEvent* done_event,
79 base::File* output_file, 82 base::File* output_file,
80 mojo::ScopedHandle handle); 83 mojo::ScopedHandle handle);
81 84
85 // Connection to |font_service_| has gone away. Called on the background
86 // thread.
87 void OnFontServiceConnectionError();
88
82 // base::Thread 89 // base::Thread
83 void Init() override; 90 void Init() override;
84 void CleanUp() override; 91 void CleanUp() override;
85 92
86 // This member is used to safely pass data from one thread to another. It is 93 // This member is used to safely pass data from one thread to another. It is
87 // set in the constructor and is consumed in Init(). 94 // set in the constructor and is consumed in Init().
88 mojo::InterfacePtrInfo<FontService> font_service_info_; 95 mojo::InterfacePtrInfo<FontService> font_service_info_;
89 96
90 // This member is set in Init(). It takes |font_service_info_|, which is 97 // This member is set in Init(). It takes |font_service_info_|, which is
91 // non-thread bound, and binds it to the newly created thread. 98 // non-thread bound, and binds it to the newly created thread.
92 mojo::InterfacePtr<FontService> font_service_; 99 mojo::InterfacePtr<FontService> font_service_;
93 100
101 // All WaitableEvents supplied to OpenStreamImpl() are added here while
102 // waiting on the response from the |font_service_| (FontService::OpenStream()
103 // was called, but the callback has not been processed yet). If
104 // |font_service_| gets an error during this time all events in
105 // |pending_waitable_events_| are signaled. This is necessary as when the
106 // pipe is closed the callbacks are never received.
107 std::set<base::WaitableEvent*> pending_waitable_events_;
108
109 base::WeakPtrFactory<FontServiceThread> weak_factory_;
110
94 DISALLOW_COPY_AND_ASSIGN(FontServiceThread); 111 DISALLOW_COPY_AND_ASSIGN(FontServiceThread);
95 }; 112 };
96 113
97 } // namespace internal 114 } // namespace internal
98 } // namespace font_service 115 } // namespace font_service
99 116
100 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_ 117 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_SERVICE_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | components/font_service/public/cpp/font_service_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698