| Index: ppapi/proxy/resource_message_test_sink.cc
|
| diff --git a/ppapi/proxy/resource_message_test_sink.cc b/ppapi/proxy/resource_message_test_sink.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0ce53e4b529e62a21328ecf18f71561a0f6d8da5
|
| --- /dev/null
|
| +++ b/ppapi/proxy/resource_message_test_sink.cc
|
| @@ -0,0 +1,64 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ppapi/proxy/resource_message_test_sink.h"
|
| +
|
| +#include "ppapi/proxy/ppapi_messages.h"
|
| +#include "ppapi/proxy/resource_message_params.h"
|
| +
|
| +namespace ppapi {
|
| +namespace proxy {
|
| +
|
| +namespace {
|
| +
|
| +// Backend for GetFirstResource[Call|Reply]Matching.
|
| +template<class WrapperMessage, class Params>
|
| +bool GetFirstResourceMessageMatching(const ResourceMessageTestSink& sink,
|
| + uint32 id,
|
| + Params* params,
|
| + IPC::Message* nested_msg) {
|
| + for (size_t i = 0; i < sink.message_count(); i++) {
|
| + const IPC::Message* msg = sink.GetMessageAt(i);
|
| + if (msg->type() == WrapperMessage::ID) {
|
| + Params cur_params;
|
| + IPC::Message cur_msg;
|
| + WrapperMessage::Read(msg, &cur_params, &cur_msg);
|
| + if (cur_msg.type() == id) {
|
| + *params = cur_params;
|
| + *nested_msg = cur_msg;
|
| + return true;
|
| + }
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +ResourceMessageTestSink::ResourceMessageTestSink() {
|
| +}
|
| +
|
| +ResourceMessageTestSink::~ResourceMessageTestSink() {
|
| +}
|
| +
|
| +bool ResourceMessageTestSink::GetFirstResourceCallMatching(
|
| + uint32 id,
|
| + ResourceMessageCallParams* params,
|
| + IPC::Message* nested_msg) const {
|
| + return GetFirstResourceMessageMatching<PpapiHostMsg_ResourceCall,
|
| + ResourceMessageCallParams>(
|
| + *this, id, params, nested_msg);
|
| +}
|
| +
|
| +bool ResourceMessageTestSink::GetFirstResourceReplyMatching(
|
| + uint32 id,
|
| + ResourceMessageReplyParams* params,
|
| + IPC::Message* nested_msg) {
|
| + return GetFirstResourceMessageMatching<PpapiPluginMsg_ResourceReply,
|
| + ResourceMessageReplyParams>(
|
| + *this, id, params, nested_msg);
|
| +}
|
| +
|
| +} // namespace proxy
|
| +} // namespace ppapi
|
|
|