| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/resource_message_test_sink.h" | 5 #include "ppapi/proxy/resource_message_test_sink.h" |
| 6 | 6 |
| 7 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" |
| 8 #include "ppapi/proxy/resource_message_params.h" | 8 #include "ppapi/proxy/resource_message_params.h" |
| 9 #include "ppapi/proxy/serialized_handle.h" | 9 #include "ppapi/proxy/serialized_handle.h" |
| 10 | 10 |
| 11 namespace ppapi { | 11 namespace ppapi { |
| 12 namespace proxy { | 12 namespace proxy { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Backend for GetAllResource[Calls|Replies]Matching. | 16 // Backend for GetAllResource[Calls|Replies]Matching. |
| 17 template<class WrapperMessage, class Params> | 17 template<class WrapperMessage, class Params> |
| 18 std::vector<std::pair<Params, IPC::Message> > | 18 std::vector<std::pair<Params, IPC::Message> > |
| 19 GetAllResourceMessagesMatching(const ResourceMessageTestSink& sink, | 19 GetAllResourceMessagesMatching(const ResourceMessageTestSink& sink, |
| 20 uint32 id) { | 20 uint32 id) { |
| 21 std::vector<std::pair<Params, IPC::Message> > result; | 21 std::vector<std::pair<Params, IPC::Message> > result; |
| 22 for (size_t i = 0; i < sink.message_count(); i++) { | 22 for (size_t i = 0; i < sink.message_count(); i++) { |
| 23 const IPC::Message* msg = sink.GetMessageAt(i); | 23 const IPC::Message* msg = sink.GetMessageAt(i); |
| 24 if (msg->type() == WrapperMessage::ID) { | 24 if (msg->type() == WrapperMessage::ID) { |
| 25 Params cur_params; | 25 typename WrapperMessage::Param params; |
| 26 IPC::Message cur_msg; | 26 WrapperMessage::Read(msg, ¶ms); |
| 27 WrapperMessage::Read(msg, &cur_params, &cur_msg); | 27 Params cur_params = params.a; |
| 28 IPC::Message cur_msg = params.b; |
| 28 if (cur_msg.type() == id) { | 29 if (cur_msg.type() == id) { |
| 29 result.push_back(std::make_pair(cur_params, cur_msg)); | 30 result.push_back(std::make_pair(cur_params, cur_msg)); |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 return result; | 34 return result; |
| 34 } | 35 } |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| 37 | 38 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 wrapper_reply_msg, reply_params, reply_msg_); | 144 wrapper_reply_msg, reply_params, reply_msg_); |
| 144 test_sink_->SetSyncReplyMessage(wrapper_reply_msg); | 145 test_sink_->SetSyncReplyMessage(wrapper_reply_msg); |
| 145 | 146 |
| 146 // Stash a copy of the message for inspection later. | 147 // Stash a copy of the message for inspection later. |
| 147 last_handled_msg_ = call_msg; | 148 last_handled_msg_ = call_msg; |
| 148 return true; | 149 return true; |
| 149 } | 150 } |
| 150 | 151 |
| 151 } // namespace proxy | 152 } // namespace proxy |
| 152 } // namespace ppapi | 153 } // namespace ppapi |
| OLD | NEW |