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 "components/font_service/public/cpp/font_service_thread.h" | 7 #include "components/font_service/public/cpp/font_service_thread.h" |
8 #include "mojo/application/public/cpp/application_impl.h" | 8 #include "mojo/application/public/cpp/application_impl.h" |
9 #include "mojo/application/public/cpp/connect.h" | |
10 #include "mojo/application/public/interfaces/shell.mojom.h" | |
11 | 9 |
12 namespace font_service { | 10 namespace font_service { |
13 | 11 |
14 FontLoader::FontLoader(mojo::Shell* shell) { | |
15 mojo::ServiceProviderPtr font_service_provider; | |
16 mojo::URLRequestPtr request(mojo::URLRequest::New()); | |
17 request->url = mojo::String::From("mojo:font_service"); | |
18 FontServicePtr font_service; | |
19 shell->ConnectToApplication(request.Pass(), | |
20 GetProxy(&font_service_provider), | |
21 nullptr, | |
22 nullptr); | |
23 mojo::ConnectToService(font_service_provider.get(), &font_service); | |
24 | |
25 thread_ = new internal::FontServiceThread(font_service.Pass()); | |
26 } | |
27 | |
28 FontLoader::FontLoader(mojo::ApplicationImpl* application_impl) { | 12 FontLoader::FontLoader(mojo::ApplicationImpl* application_impl) { |
29 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 13 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
30 request->url = mojo::String::From("mojo:font_service"); | 14 request->url = mojo::String::From("mojo:font_service"); |
31 FontServicePtr font_service; | 15 FontServicePtr font_service; |
32 application_impl->ConnectToService(request.Pass(), &font_service); | 16 application_impl->ConnectToService(request.Pass(), &font_service); |
33 | 17 |
34 thread_ = new internal::FontServiceThread(font_service.Pass()); | 18 thread_ = new internal::FontServiceThread(font_service.Pass()); |
35 } | 19 } |
36 | 20 |
37 FontLoader::~FontLoader() {} | 21 FontLoader::~FontLoader() {} |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return mapped_font_files_it->second->CreateMemoryStream(); | 54 return mapped_font_files_it->second->CreateMemoryStream(); |
71 } | 55 } |
72 } | 56 } |
73 | 57 |
74 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) { | 58 void FontLoader::OnMappedFontFileDestroyed(internal::MappedFontFile* f) { |
75 base::AutoLock lock(lock_); | 59 base::AutoLock lock(lock_); |
76 mapped_font_files_.erase(f->font_id()); | 60 mapped_font_files_.erase(f->font_id()); |
77 } | 61 } |
78 | 62 |
79 } // namespace font_service | 63 } // namespace font_service |
OLD | NEW |