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_loader.h" | 5 #include "components/font_service/public/cpp/font_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/font_service/public/cpp/font_service_thread.h" | 8 #include "components/font_service/public/cpp/font_service_thread.h" |
9 #include "mojo/application/public/cpp/application_impl.h" | 9 #include "mojo/application/public/cpp/application_impl.h" |
10 #include "mojo/application/public/cpp/connect.h" | 10 #include "mojo/application/public/cpp/connect.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 32 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
33 request->url = mojo::String::From("mojo:font_service"); | 33 request->url = mojo::String::From("mojo:font_service"); |
34 FontServicePtr font_service; | 34 FontServicePtr font_service; |
35 application_impl->ConnectToService(request.Pass(), &font_service); | 35 application_impl->ConnectToService(request.Pass(), &font_service); |
36 | 36 |
37 thread_ = new internal::FontServiceThread(font_service.Pass()); | 37 thread_ = new internal::FontServiceThread(font_service.Pass()); |
38 } | 38 } |
39 | 39 |
40 FontLoader::~FontLoader() {} | 40 FontLoader::~FontLoader() {} |
41 | 41 |
| 42 void FontLoader::Shutdown() { |
| 43 thread_->Stop(); |
| 44 thread_ = nullptr; |
| 45 } |
| 46 |
42 bool FontLoader::matchFamilyName(const char family_name[], | 47 bool FontLoader::matchFamilyName(const char family_name[], |
43 SkTypeface::Style requested, | 48 SkTypeface::Style requested, |
44 FontIdentity* out_font_identifier, | 49 FontIdentity* out_font_identifier, |
45 SkString* out_family_name, | 50 SkString* out_family_name, |
46 SkTypeface::Style* out_style) { | 51 SkTypeface::Style* out_style) { |
47 return thread_->MatchFamilyName(family_name, requested, out_font_identifier, | 52 return thread_->MatchFamilyName(family_name, requested, out_font_identifier, |
48 out_family_name, out_style); | 53 out_family_name, out_style); |
49 } | 54 } |
50 | 55 |
51 SkStreamAsset* FontLoader::openStream(const FontIdentity& identity) { | 56 SkStreamAsset* FontLoader::openStream(const FontIdentity& identity) { |
(...skipping 21 matching lines...) Expand all Loading... |
73 return mapped_font_files_it->second->CreateMemoryStream(); | 78 return mapped_font_files_it->second->CreateMemoryStream(); |
74 } | 79 } |
75 } | 80 } |
76 | 81 |
77 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) { | 82 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) { |
78 base::AutoLock lock(lock_); | 83 base::AutoLock lock(lock_); |
79 mapped_font_files_.erase(f->font_id()); | 84 mapped_font_files_.erase(f->font_id()); |
80 } | 85 } |
81 | 86 |
82 } // namespace font_service | 87 } // namespace font_service |
OLD | NEW |