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 "content/test/dwrite_font_fake_sender_win.h" | 5 #include "content/test/dwrite_font_fake_sender_win.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 | 8 |
9 #include "content/common/dwrite_font_proxy_messages.h" | 9 #include "content/common/dwrite_font_proxy_messages.h" |
10 | 10 |
(...skipping 50 matching lines...) Loading... |
61 | 61 |
62 IPC::Sender* FakeFontCollection::GetTrackingSender() { | 62 IPC::Sender* FakeFontCollection::GetTrackingSender() { |
63 return new FakeSender(this, true /* track_messages */); | 63 return new FakeSender(this, true /* track_messages */); |
64 } | 64 } |
65 | 65 |
66 FakeFontCollection::ReplySender::ReplySender(FakeFontCollection* collection) | 66 FakeFontCollection::ReplySender::ReplySender(FakeFontCollection* collection) |
67 : collection_(collection) {} | 67 : collection_(collection) {} |
68 | 68 |
69 FakeFontCollection::ReplySender::~ReplySender() = default; | 69 FakeFontCollection::ReplySender::~ReplySender() = default; |
70 | 70 |
71 scoped_ptr<IPC::Message>& FakeFontCollection::ReplySender::OnMessageReceived( | 71 std::unique_ptr<IPC::Message>& |
72 const IPC::Message& msg) { | 72 FakeFontCollection::ReplySender::OnMessageReceived(const IPC::Message& msg) { |
73 reply_.reset(); | 73 reply_.reset(); |
74 bool handled = true; | 74 bool handled = true; |
75 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg) | 75 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg) |
76 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily) | 76 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily) |
77 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount) | 77 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount) |
78 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames) | 78 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames) |
79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles) | 79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles) |
80 IPC_MESSAGE_UNHANDLED(handled = false) | 80 IPC_MESSAGE_UNHANDLED(handled = false) |
81 IPC_END_MESSAGE_MAP() | 81 IPC_END_MESSAGE_MAP() |
82 return reply_; | 82 return reply_; |
(...skipping 32 matching lines...) Loading... |
115 | 115 |
116 FakeFontCollection::FakeSender::~FakeSender() = default; | 116 FakeFontCollection::FakeSender::~FakeSender() = default; |
117 | 117 |
118 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) { | 118 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) { |
119 std::unique_ptr<IPC::Message> incoming_message; | 119 std::unique_ptr<IPC::Message> incoming_message; |
120 if (track_messages_) | 120 if (track_messages_) |
121 collection_->messages_.emplace_back(message); | 121 collection_->messages_.emplace_back(message); |
122 else | 122 else |
123 incoming_message.reset(message); // Ensure message is deleted. | 123 incoming_message.reset(message); // Ensure message is deleted. |
124 std::unique_ptr<ReplySender> sender = collection_->GetReplySender(); | 124 std::unique_ptr<ReplySender> sender = collection_->GetReplySender(); |
125 scoped_ptr<IPC::Message> reply; | 125 std::unique_ptr<IPC::Message> reply; |
126 reply.swap(sender->OnMessageReceived(*message)); | 126 reply.swap(sender->OnMessageReceived(*message)); |
127 | 127 |
128 IPC::SyncMessage* sync_message = reinterpret_cast<IPC::SyncMessage*>(message); | 128 IPC::SyncMessage* sync_message = reinterpret_cast<IPC::SyncMessage*>(message); |
129 scoped_ptr<IPC::MessageReplyDeserializer> serializer( | 129 std::unique_ptr<IPC::MessageReplyDeserializer> serializer( |
130 sync_message->GetReplyDeserializer()); | 130 sync_message->GetReplyDeserializer()); |
131 serializer->SerializeOutputParameters(*(reply.get())); | 131 serializer->SerializeOutputParameters(*(reply.get())); |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 void FakeFontCollection::OnFindFamily(const base::string16& family_name, | 135 void FakeFontCollection::OnFindFamily(const base::string16& family_name, |
136 uint32_t* index) { | 136 uint32_t* index) { |
137 for (size_t n = 0; n < fonts_.size(); n++) { | 137 for (size_t n = 0; n < fonts_.size(); n++) { |
138 if (_wcsicmp(family_name.data(), fonts_[n].font_name_.data()) == 0) { | 138 if (_wcsicmp(family_name.data(), fonts_[n].font_name_.data()) == 0) { |
139 *index = n; | 139 *index = n; |
(...skipping 25 matching lines...) Loading... |
165 | 165 |
166 std::unique_ptr<FakeFontCollection::ReplySender> | 166 std::unique_ptr<FakeFontCollection::ReplySender> |
167 FakeFontCollection::GetReplySender() { | 167 FakeFontCollection::GetReplySender() { |
168 return std::unique_ptr<FakeFontCollection::ReplySender>( | 168 return std::unique_ptr<FakeFontCollection::ReplySender>( |
169 new FakeFontCollection::ReplySender(this)); | 169 new FakeFontCollection::ReplySender(this)); |
170 } | 170 } |
171 | 171 |
172 FakeFontCollection::~FakeFontCollection() = default; | 172 FakeFontCollection::~FakeFontCollection() = default; |
173 | 173 |
174 } // namespace content | 174 } // namespace content |
OLD | NEW |