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