OLD | NEW |
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 "components/font_service/public/cpp/font_service_thread.h" | 5 #include "components/font_service/public/cpp/font_service_thread.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const char family_name[], | 30 const char family_name[], |
31 SkFontStyle requested_style, | 31 SkFontStyle requested_style, |
32 SkFontConfigInterface::FontIdentity* out_font_identity, | 32 SkFontConfigInterface::FontIdentity* out_font_identity, |
33 SkString* out_family_name, | 33 SkString* out_family_name, |
34 SkFontStyle* out_style) { | 34 SkFontStyle* out_style) { |
35 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId()); | 35 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId()); |
36 | 36 |
37 bool out_valid = false; | 37 bool out_valid = false; |
38 // This proxies to the other thread, which proxies to mojo. Only on the reply | 38 // This proxies to the other thread, which proxies to mojo. Only on the reply |
39 // from mojo do we return from this. | 39 // from mojo do we return from this. |
40 base::WaitableEvent done_event(false, false); | 40 base::WaitableEvent done_event( |
| 41 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 42 base::WaitableEvent::InitialState::NOT_SIGNALED); |
41 task_runner()->PostTask( | 43 task_runner()->PostTask( |
42 FROM_HERE, | 44 FROM_HERE, |
43 base::Bind(&FontServiceThread::MatchFamilyNameImpl, this, &done_event, | 45 base::Bind(&FontServiceThread::MatchFamilyNameImpl, this, &done_event, |
44 family_name, requested_style, &out_valid, out_font_identity, | 46 family_name, requested_style, &out_valid, out_font_identity, |
45 out_family_name, out_style)); | 47 out_family_name, out_style)); |
46 done_event.Wait(); | 48 done_event.Wait(); |
47 | 49 |
48 return out_valid; | 50 return out_valid; |
49 } | 51 } |
50 | 52 |
51 scoped_refptr<MappedFontFile> FontServiceThread::OpenStream( | 53 scoped_refptr<MappedFontFile> FontServiceThread::OpenStream( |
52 const SkFontConfigInterface::FontIdentity& identity) { | 54 const SkFontConfigInterface::FontIdentity& identity) { |
53 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId()); | 55 DCHECK_NE(GetThreadId(), base::PlatformThread::CurrentId()); |
54 | 56 |
55 base::File stream_file; | 57 base::File stream_file; |
56 // This proxies to the other thread, which proxies to mojo. Only on the reply | 58 // This proxies to the other thread, which proxies to mojo. Only on the reply |
57 // from mojo do we return from this. | 59 // from mojo do we return from this. |
58 base::WaitableEvent done_event(false, false); | 60 base::WaitableEvent done_event( |
| 61 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 62 base::WaitableEvent::InitialState::NOT_SIGNALED); |
59 task_runner()->PostTask(FROM_HERE, | 63 task_runner()->PostTask(FROM_HERE, |
60 base::Bind(&FontServiceThread::OpenStreamImpl, this, | 64 base::Bind(&FontServiceThread::OpenStreamImpl, this, |
61 &done_event, &stream_file, identity.fID)); | 65 &done_event, &stream_file, identity.fID)); |
62 done_event.Wait(); | 66 done_event.Wait(); |
63 | 67 |
64 if (!stream_file.IsValid()) { | 68 if (!stream_file.IsValid()) { |
65 // The font-service may have been killed. | 69 // The font-service may have been killed. |
66 return nullptr; | 70 return nullptr; |
67 } | 71 } |
68 | 72 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 base::Bind(&FontServiceThread::OnFontServiceConnectionError, | 183 base::Bind(&FontServiceThread::OnFontServiceConnectionError, |
180 weak_factory_.GetWeakPtr())); | 184 weak_factory_.GetWeakPtr())); |
181 } | 185 } |
182 | 186 |
183 void FontServiceThread::CleanUp() { | 187 void FontServiceThread::CleanUp() { |
184 font_service_.reset(); | 188 font_service_.reset(); |
185 } | 189 } |
186 | 190 |
187 } // namespace internal | 191 } // namespace internal |
188 } // namespace font_service | 192 } // namespace font_service |
OLD | NEW |