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

Unified Diff: ppapi/proxy/resource_message_test_sink.cc

Issue 10560030: Add resource message call and reply infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
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
« ppapi/proxy/resource_message_params.cc ('K') | « ppapi/proxy/resource_message_test_sink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698