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/font_service_app.h" | 5 #include "components/font_service/font_service_app.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "mojo/public/cpp/system/platform_handle.h" | 11 #include "mojo/public/cpp/system/platform_handle.h" |
12 #include "services/service_manager/public/cpp/connection.h" | 12 #include "services/service_manager/public/cpp/connection.h" |
13 #include "services/service_manager/public/cpp/interface_registry.h" | |
14 #include "services/service_manager/public/cpp/service_context.h" | 13 #include "services/service_manager/public/cpp/service_context.h" |
15 | 14 |
16 static_assert( | 15 static_assert( |
17 static_cast<uint32_t>(SkFontStyle::kUpright_Slant) == | 16 static_cast<uint32_t>(SkFontStyle::kUpright_Slant) == |
18 static_cast<uint32_t>(font_service::mojom::TypefaceSlant::ROMAN), | 17 static_cast<uint32_t>(font_service::mojom::TypefaceSlant::ROMAN), |
19 "Skia and font service flags must match"); | 18 "Skia and font service flags must match"); |
20 static_assert( | 19 static_assert( |
21 static_cast<uint32_t>(SkFontStyle::kItalic_Slant) == | 20 static_cast<uint32_t>(SkFontStyle::kItalic_Slant) == |
22 static_cast<uint32_t>(font_service::mojom::TypefaceSlant::ITALIC), | 21 static_cast<uint32_t>(font_service::mojom::TypefaceSlant::ITALIC), |
23 "Skia and font service flags must match"); | 22 "Skia and font service flags must match"); |
(...skipping 10 matching lines...) Expand all Loading... |
34 | 33 |
35 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); | 34 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
36 LOG_IF(WARNING, !file.IsValid()) << "file not valid, path=" << path.value(); | 35 LOG_IF(WARNING, !file.IsValid()) << "file not valid, path=" << path.value(); |
37 return file; | 36 return file; |
38 } | 37 } |
39 | 38 |
40 } // namespace | 39 } // namespace |
41 | 40 |
42 namespace font_service { | 41 namespace font_service { |
43 | 42 |
44 FontServiceApp::FontServiceApp() {} | 43 FontServiceApp::FontServiceApp() { |
| 44 registry_.AddInterface(this); |
| 45 } |
45 | 46 |
46 FontServiceApp::~FontServiceApp() {} | 47 FontServiceApp::~FontServiceApp() {} |
47 | 48 |
48 void FontServiceApp::OnStart() { | 49 void FontServiceApp::OnStart() { |
49 tracing_.Initialize(context()->connector(), context()->identity().name()); | 50 tracing_.Initialize(context()->connector(), context()->identity().name()); |
50 } | 51 } |
51 | 52 |
52 bool FontServiceApp::OnConnect(const service_manager::ServiceInfo& remote_info, | 53 void FontServiceApp::OnBindInterface( |
53 service_manager::InterfaceRegistry* registry) { | 54 const service_manager::ServiceInfo& source_info, |
54 registry->AddInterface(this); | 55 const std::string& interface_name, |
55 return true; | 56 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 57 registry_.BindInterface(source_info.identity, interface_name, |
| 58 std::move(interface_pipe)); |
56 } | 59 } |
57 | 60 |
58 void FontServiceApp::Create( | 61 void FontServiceApp::Create( |
59 const service_manager::Identity& remote_identity, | 62 const service_manager::Identity& remote_identity, |
60 mojo::InterfaceRequest<mojom::FontService> request) { | 63 mojo::InterfaceRequest<mojom::FontService> request) { |
61 bindings_.AddBinding(this, std::move(request)); | 64 bindings_.AddBinding(this, std::move(request)); |
62 } | 65 } |
63 | 66 |
64 void FontServiceApp::MatchFamilyName(const std::string& family_name, | 67 void FontServiceApp::MatchFamilyName(const std::string& family_name, |
65 mojom::TypefaceStylePtr requested_style, | 68 mojom::TypefaceStylePtr requested_style, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int count = paths_.size(); | 119 int count = paths_.size(); |
117 for (int i = 0; i < count; ++i) { | 120 for (int i = 0; i < count; ++i) { |
118 if (path == paths_[i]) | 121 if (path == paths_[i]) |
119 return i; | 122 return i; |
120 } | 123 } |
121 paths_.emplace_back(path); | 124 paths_.emplace_back(path); |
122 return count; | 125 return count; |
123 } | 126 } |
124 | 127 |
125 } // namespace font_service | 128 } // namespace font_service |
OLD | NEW |