| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 mojom::TypefaceStylePtr style(mojom::TypefaceStyle::New()); | 102 mojom::TypefaceStylePtr style(mojom::TypefaceStyle::New()); |
| 103 style->weight = requested_style.weight(); | 103 style->weight = requested_style.weight(); |
| 104 style->width = requested_style.width(); | 104 style->width = requested_style.width(); |
| 105 style->slant = static_cast<mojom::TypefaceSlant>(requested_style.slant()); | 105 style->slant = static_cast<mojom::TypefaceSlant>(requested_style.slant()); |
| 106 | 106 |
| 107 pending_waitable_events_.insert(done_event); | 107 pending_waitable_events_.insert(done_event); |
| 108 font_service_->MatchFamilyName( | 108 font_service_->MatchFamilyName( |
| 109 mojo::String(family_name), std::move(style), | 109 family_name, std::move(style), |
| 110 base::Bind(&FontServiceThread::OnMatchFamilyNameComplete, this, | 110 base::Bind(&FontServiceThread::OnMatchFamilyNameComplete, this, |
| 111 done_event, out_valid, out_font_identity, out_family_name, | 111 done_event, out_valid, out_font_identity, out_family_name, |
| 112 out_style)); | 112 out_style)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void FontServiceThread::OnMatchFamilyNameComplete( | 115 void FontServiceThread::OnMatchFamilyNameComplete( |
| 116 base::WaitableEvent* done_event, | 116 base::WaitableEvent* done_event, |
| 117 bool* out_valid, | 117 bool* out_valid, |
| 118 SkFontConfigInterface::FontIdentity* out_font_identity, | 118 SkFontConfigInterface::FontIdentity* out_font_identity, |
| 119 SkString* out_family_name, | 119 SkString* out_family_name, |
| 120 SkFontStyle* out_style, | 120 SkFontStyle* out_style, |
| 121 mojom::FontIdentityPtr font_identity, | 121 mojom::FontIdentityPtr font_identity, |
| 122 mojo::String family_name, | 122 const std::string& family_name, |
| 123 mojom::TypefaceStylePtr style) { | 123 mojom::TypefaceStylePtr style) { |
| 124 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId()); | 124 DCHECK_EQ(GetThreadId(), base::PlatformThread::CurrentId()); |
| 125 pending_waitable_events_.erase(done_event); | 125 pending_waitable_events_.erase(done_event); |
| 126 | 126 |
| 127 *out_valid = !font_identity.is_null(); | 127 *out_valid = !font_identity.is_null(); |
| 128 if (font_identity) { | 128 if (font_identity) { |
| 129 out_font_identity->fID = font_identity->id; | 129 out_font_identity->fID = font_identity->id; |
| 130 out_font_identity->fTTCIndex = font_identity->ttc_index; | 130 out_font_identity->fTTCIndex = font_identity->ttc_index; |
| 131 out_font_identity->fString = font_identity->str_representation.data(); | 131 out_font_identity->fString = font_identity->str_representation.data(); |
| 132 // TODO(erg): fStyle isn't set. This is rather odd, however it matches the | 132 // TODO(erg): fStyle isn't set. This is rather odd, however it matches the |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 base::Bind(&FontServiceThread::OnFontServiceConnectionError, | 183 base::Bind(&FontServiceThread::OnFontServiceConnectionError, |
| 184 weak_factory_.GetWeakPtr())); | 184 weak_factory_.GetWeakPtr())); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void FontServiceThread::CleanUp() { | 187 void FontServiceThread::CleanUp() { |
| 188 font_service_.reset(); | 188 font_service_.reset(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace internal | 191 } // namespace internal |
| 192 } // namespace font_service | 192 } // namespace font_service |
| OLD | NEW |