 Chromium Code Reviews
 Chromium Code Reviews Issue 11039012:
  Implement plugin side of sync EnumerateVideoCaptureDevices  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 11039012:
  Implement plugin side of sync EnumerateVideoCaptureDevices  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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..8c3e59eb5f423e72541b309d6ba6fa634f4d5e44 100644 | 
| --- a/ppapi/proxy/resource_message_test_sink.h | 
| +++ b/ppapi/proxy/resource_message_test_sink.h | 
| @@ -10,6 +10,7 @@ | 
| namespace ppapi { | 
| namespace proxy { | 
| +class PpapiHostMsg_ResourceSyncCall; | 
| class ResourceMessageCallParams; | 
| class ResourceMessageReplyParams; | 
| @@ -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: | 
| + 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 |PpapiHostMsg_X_YReply| then usage would be as | 
| 
yzshen1
2012/10/05 18:16:46
nit: I thought the convention would be to use Ppap
 
raymes
2012/10/08 17:08:50
Done.
 | 
| +// 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 |