diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 21:46:26 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 21:46:26 +0000 |
commit | 077ecfd462a0dc97e2042275cf770a5b3d447ee3 (patch) | |
tree | 01395a25a92d97683b84d9048e54f6fa5c5365bc /ppapi/proxy/resource_message_test_sink.cc | |
parent | c290833eb0eb7e8d6316672d6f9ec59d22d0a5a8 (diff) | |
download | chromium_src-077ecfd462a0dc97e2042275cf770a5b3d447ee3.zip chromium_src-077ecfd462a0dc97e2042275cf770a5b3d447ee3.tar.gz chromium_src-077ecfd462a0dc97e2042275cf770a5b3d447ee3.tar.bz2 |
Add resource message call and reply infrastructure.
These messages are not yet used. They will allow us to route messages directly to a resource implementation in the proxy or the host using information in a common header. The actual content of the message (as interpreted by the specifi resource in the plugin or class in the host) is a nested message.
TEST=none
BUT=none
Review URL: https://chromiumcodereview.appspot.com/10560030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/resource_message_test_sink.cc')
-rw-r--r-- | ppapi/proxy/resource_message_test_sink.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ppapi/proxy/resource_message_test_sink.cc b/ppapi/proxy/resource_message_test_sink.cc new file mode 100644 index 0000000..7daf435 --- /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 |