Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: content/test/dwrite_font_fake_sender_win.h

Issue 2153343002: Implement support for loading font files from outside system directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some more comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 5 #ifndef CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
6 #define CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 6 #define CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wrl.h> 10 #include <wrl.h>
11 11
12 #include <memory> 12 #include <memory>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "ipc/ipc_message.h" 19 #include "ipc/ipc_message.h"
20 #include "ipc/ipc_platform_file.h"
20 #include "ipc/ipc_sender.h" 21 #include "ipc/ipc_sender.h"
21 22
22 struct DWriteFontStyle; 23 struct DWriteFontStyle;
23 struct MapCharactersResult; 24 struct MapCharactersResult;
24 25
25 namespace content { 26 namespace content {
26 27
27 class FakeFontCollection; 28 class FakeFontCollection;
28 29
29 // Creates a new FakeFontCollection, seeded with some basic data, and returns a 30 // Creates a new FakeFontCollection, seeded with some basic data, and returns a
30 // Sender that can be used to interact with the collection. 31 // Sender that can be used to interact with the collection.
31 IPC::Sender* CreateFakeCollectionSender(); 32 IPC::Sender* CreateFakeCollectionSender();
32 33
33 // Helper class for describing a font object. Use FakeFontCollection instead. 34 // Helper class for describing a font object. Use FakeFontCollection instead.
34 class FakeFont { 35 class FakeFont {
35 public: 36 public:
36 explicit FakeFont(const base::string16& name); 37 explicit FakeFont(const base::string16& name);
37 38
38 FakeFont(const FakeFont& other); 39 FakeFont(const FakeFont& other);
39 40
40 ~FakeFont(); 41 ~FakeFont();
41 42
42 FakeFont& AddFilePath(const base::string16& file_path) { 43 FakeFont& AddFilePath(const base::string16& file_path) {
43 file_paths_.push_back(file_path); 44 file_paths_.push_back(file_path);
44 return *this; 45 return *this;
45 } 46 }
46 47
48 FakeFont& AddFileHandle(IPC::PlatformFileForTransit handle) {
49 file_handles_.push_back(handle);
50 return *this;
51 }
52
47 FakeFont& AddFamilyName(const base::string16& locale, 53 FakeFont& AddFamilyName(const base::string16& locale,
48 const base::string16& family_name) { 54 const base::string16& family_name) {
49 family_names_.emplace_back(locale, family_name); 55 family_names_.emplace_back(locale, family_name);
50 return *this; 56 return *this;
51 } 57 }
52 58
53 const base::string16& font_name() { return font_name_; } 59 const base::string16& font_name() { return font_name_; }
54 60
55 private: 61 private:
56 friend FakeFontCollection; 62 friend FakeFontCollection;
57 base::string16 font_name_; 63 base::string16 font_name_;
58 std::vector<base::string16> file_paths_; 64 std::vector<base::string16> file_paths_;
65 std::vector<IPC::PlatformFileForTransit> file_handles_;
59 std::vector<std::pair<base::string16, base::string16>> family_names_; 66 std::vector<std::pair<base::string16, base::string16>> family_names_;
60 67
61 DISALLOW_ASSIGN(FakeFont); 68 DISALLOW_ASSIGN(FakeFont);
62 }; 69 };
63 70
64 // Implements a font collection that supports interaction through sending IPC 71 // Implements a font collection that supports interaction through sending IPC
65 // messages from dwrite_font_proxy_messages.h. 72 // messages from dwrite_font_proxy_messages.h.
66 // Usage: 73 // Usage:
67 // Create a new FakeFontCollection. 74 // Create a new FakeFontCollection.
68 // Call AddFont() to add fonts. 75 // Call AddFont() to add fonts.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 117
111 private: 118 private:
112 void OnFindFamily(const base::string16& family_name, uint32_t* index); 119 void OnFindFamily(const base::string16& family_name, uint32_t* index);
113 120
114 void OnGetFamilyCount(uint32_t* count); 121 void OnGetFamilyCount(uint32_t* count);
115 122
116 void OnGetFamilyNames( 123 void OnGetFamilyNames(
117 uint32_t family_index, 124 uint32_t family_index,
118 std::vector<std::pair<base::string16, base::string16>>* family_names); 125 std::vector<std::pair<base::string16, base::string16>>* family_names);
119 void OnGetFontFiles(uint32_t family_index, 126 void OnGetFontFiles(uint32_t family_index,
120 std::vector<base::string16>* file_paths_); 127 std::vector<base::string16>* file_paths,
128 std::vector<IPC::PlatformFileForTransit>* file_handles);
121 129
122 void OnMapCharacters(const base::string16& text, 130 void OnMapCharacters(const base::string16& text,
123 const DWriteFontStyle& font_style, 131 const DWriteFontStyle& font_style,
124 const base::string16& locale_name, 132 const base::string16& locale_name,
125 uint32_t reading_direction, 133 uint32_t reading_direction,
126 const base::string16& base_family_name, 134 const base::string16& base_family_name,
127 MapCharactersResult* result); 135 MapCharactersResult* result);
128 136
129 private: 137 private:
130 scoped_refptr<FakeFontCollection> collection_; 138 scoped_refptr<FakeFontCollection> collection_;
(...skipping 20 matching lines...) Expand all
151 159
152 void OnFindFamily(const base::string16& family_name, uint32_t* index); 160 void OnFindFamily(const base::string16& family_name, uint32_t* index);
153 161
154 void OnGetFamilyCount(uint32_t* count); 162 void OnGetFamilyCount(uint32_t* count);
155 163
156 void OnGetFamilyNames( 164 void OnGetFamilyNames(
157 uint32_t family_index, 165 uint32_t family_index,
158 std::vector<std::pair<base::string16, base::string16>>* family_names); 166 std::vector<std::pair<base::string16, base::string16>>* family_names);
159 167
160 void OnGetFontFiles(uint32_t family_index, 168 void OnGetFontFiles(uint32_t family_index,
161 std::vector<base::string16>* file_paths); 169 std::vector<base::string16>* file_paths,
170 std::vector<IPC::PlatformFileForTransit>* file_handles);
162 171
163 void OnMapCharacters(const base::string16& text, 172 void OnMapCharacters(const base::string16& text,
164 const DWriteFontStyle& font_style, 173 const DWriteFontStyle& font_style,
165 const base::string16& locale_name, 174 const base::string16& locale_name,
166 uint32_t reading_direction, 175 uint32_t reading_direction,
167 const base::string16& base_family_name, 176 const base::string16& base_family_name,
168 MapCharactersResult* result); 177 MapCharactersResult* result);
169 178
170 std::unique_ptr<ReplySender> GetReplySender(); 179 std::unique_ptr<ReplySender> GetReplySender();
171 180
172 private: 181 private:
173 friend class base::RefCounted<FakeFontCollection>; 182 friend class base::RefCounted<FakeFontCollection>;
174 ~FakeFontCollection(); 183 ~FakeFontCollection();
175 184
176 std::vector<FakeFont> fonts_; 185 std::vector<FakeFont> fonts_;
177 std::vector<std::unique_ptr<IPC::Message>> messages_; 186 std::vector<std::unique_ptr<IPC::Message>> messages_;
178 187
179 DISALLOW_COPY_AND_ASSIGN(FakeFontCollection); 188 DISALLOW_COPY_AND_ASSIGN(FakeFontCollection);
180 }; 189 };
181 190
182 } // namespace content 191 } // namespace content
183 192
184 #endif // CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 193 #endif // CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698