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

Unified Diff: ppapi/proxy/resource_message_test_sink.h

Issue 11039012: Implement plugin side of sync EnumerateVideoCaptureDevices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/proxy/resource_message_test_sink.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/resource_message_test_sink.h
diff --git a/ppapi/proxy/resource_message_test_sink.h b/ppapi/proxy/resource_message_test_sink.h
index bf74becc27442589a6ff9383ab06c6a0f35cd275..7694fb0f8fd3fe4851f06fe39524471804a670ce 100644
--- a/ppapi/proxy/resource_message_test_sink.h
+++ b/ppapi/proxy/resource_message_test_sink.h
@@ -6,6 +6,7 @@
#define PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_
#include "ipc/ipc_test_sink.h"
+#include "ppapi/c/pp_stdint.h"
namespace ppapi {
namespace proxy {
@@ -20,6 +21,14 @@ class ResourceMessageTestSink : public IPC::TestSink {
ResourceMessageTestSink();
virtual ~ResourceMessageTestSink();
+ // IPC::TestSink.
+ // Overridden to handle sync messages.
+ virtual bool Send(IPC::Message* msg) OVERRIDE;
+
+ // Sets the reply message that will be returned to the next sync message sent.
+ // This test sink owns any reply messages passed into this method.
+ void SetSyncReplyMessage(IPC::Message* reply_msg);
+
// Searches the queue for the first resource call message with a nested
// message matching the given ID. On success, returns true and populates the
// givem params and nested message.
@@ -33,6 +42,46 @@ class ResourceMessageTestSink : public IPC::TestSink {
uint32 id,
ResourceMessageReplyParams* params,
IPC::Message* nested_msg);
+
+ private:
+ scoped_ptr<IPC::Message> sync_reply_msg_;
+};
+
+// This is a message handler which generates reply messages for synchronous
+// resource calls. This allows unit testing of the plugin side of resources
+// which send sync messages. If you want to reply to a sync message type named
+// |PpapiHostMsg_X_Y| with |PpapiPluginMsg_X_YReply| then usage would be as
+// follows (from within |PluginProxyTest|s):
+//
+// PpapiHostMsg_X_YReply my_reply;
+// ResourceSyncCallHandler handler(&sink(),
+// PpapiHostMsg_X_Y::ID,
+// PP_OK,
+// my_reply);
+// sink().AddFilter(&handler);
+// // Do stuff to send a sync message ...
+// // You can check handler.last_handled_msg() to ensure the correct message was
+// // handled.
+// sink().RemoveFilter(&handler);
+class ResourceSyncCallHandler : public IPC::Listener {
+ public:
+ ResourceSyncCallHandler(ResourceMessageTestSink* test_sink,
+ uint32 incoming_type,
+ int32_t result,
+ const IPC::Message& reply_msg);
+ virtual ~ResourceSyncCallHandler();
+
+ // IPC::Listener.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ IPC::Message last_handled_msg() { return last_handled_msg_; }
+
+ private:
+ ResourceMessageTestSink* test_sink_;
+ uint32 incoming_type_;
+ int32_t result_;
+ IPC::Message reply_msg_;
+ IPC::Message last_handled_msg_;
};
} // namespace proxy
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.cc ('k') | ppapi/proxy/resource_message_test_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698