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 "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "mojo/application/public/cpp/application_connection.h" | 9 #include "mojo/application/public/cpp/application_connection.h" |
10 #include "mojo/platform_handle/platform_handle_functions.h" | 10 #include "mojo/platform_handle/platform_handle_functions.h" |
11 | 11 |
12 COMPILE_ASSERT(static_cast<uint32>(SkTypeface::kNormal) == | 12 static_assert(static_cast<uint32>(SkTypeface::kNormal) == |
13 static_cast<uint32>(font_service::TYPEFACE_STYLE_NORMAL), | 13 static_cast<uint32>(font_service::TYPEFACE_STYLE_NORMAL), |
14 typeface_flags_should_match); | 14 "Skia and font service flags must match"); |
15 COMPILE_ASSERT(static_cast<uint32>(SkTypeface::kBold) == | 15 static_assert(static_cast<uint32>(SkTypeface::kBold) == |
16 static_cast<uint32>(font_service::TYPEFACE_STYLE_BOLD), | 16 static_cast<uint32>(font_service::TYPEFACE_STYLE_BOLD), |
17 typeface_flags_should_match); | 17 "Skia and font service flags must match"); |
18 COMPILE_ASSERT(static_cast<uint32>(SkTypeface::kItalic) == | 18 static_assert(static_cast<uint32>(SkTypeface::kItalic) == |
19 static_cast<uint32>(font_service::TYPEFACE_STYLE_ITALIC), | 19 static_cast<uint32>(font_service::TYPEFACE_STYLE_ITALIC), |
20 typeface_flags_should_match); | 20 "Skia and font service flags must match"); |
21 COMPILE_ASSERT( | 21 static_assert(static_cast<uint32>(SkTypeface::kBoldItalic) == |
22 static_cast<uint32>(SkTypeface::kBoldItalic) == | 22 static_cast<uint32>(font_service::TYPEFACE_STYLE_BOLD_ITALIC), |
23 static_cast<uint32>(font_service::TYPEFACE_STYLE_BOLD_ITALIC), | 23 "Skia and font service flags must match"); |
24 typeface_flags_should_match); | |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 mojo::ScopedHandle GetHandleForPath(const base::FilePath& path) { | 27 mojo::ScopedHandle GetHandleForPath(const base::FilePath& path) { |
29 if (path.empty()) | 28 if (path.empty()) |
30 return mojo::ScopedHandle(); | 29 return mojo::ScopedHandle(); |
31 | 30 |
32 mojo::ScopedHandle to_pass; | 31 mojo::ScopedHandle to_pass; |
33 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); | 32 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
34 if (!file.IsValid()) { | 33 if (!file.IsValid()) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int count = paths_.count(); | 115 int count = paths_.count(); |
117 for (int i = 0; i < count; ++i) { | 116 for (int i = 0; i < count; ++i) { |
118 if (path == *paths_[i]) | 117 if (path == *paths_[i]) |
119 return i; | 118 return i; |
120 } | 119 } |
121 *paths_.append() = new SkString(path); | 120 *paths_.append() = new SkString(path); |
122 return count; | 121 return count; |
123 } | 122 } |
124 | 123 |
125 } // namespace font_service | 124 } // namespace font_service |
OLD | NEW |