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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_ 5 #ifndef PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_
6 #define PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_ 6 #define PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_
7 7
8 #include "ipc/ipc_test_sink.h" 8 #include "ipc/ipc_test_sink.h"
9 #include "ppapi/c/pp_stdint.h"
9 10
10 namespace ppapi { 11 namespace ppapi {
11 namespace proxy { 12 namespace proxy {
12 13
13 class ResourceMessageCallParams; 14 class ResourceMessageCallParams;
14 class ResourceMessageReplyParams; 15 class ResourceMessageReplyParams;
15 16
16 // Extends IPC::TestSink to add extra capabilities for searching for and 17 // Extends IPC::TestSink to add extra capabilities for searching for and
17 // decoding resource messages. 18 // decoding resource messages.
18 class ResourceMessageTestSink : public IPC::TestSink { 19 class ResourceMessageTestSink : public IPC::TestSink {
19 public: 20 public:
20 ResourceMessageTestSink(); 21 ResourceMessageTestSink();
21 virtual ~ResourceMessageTestSink(); 22 virtual ~ResourceMessageTestSink();
22 23
24 // IPC::TestSink.
25 // Overridden to handle sync messages.
26 virtual bool Send(IPC::Message* msg) OVERRIDE;
27
28 // Sets the reply message that will be returned to the next sync message sent.
29 // This test sink owns any reply messages passed into this method.
30 void SetSyncReplyMessage(IPC::Message* reply_msg);
31
23 // Searches the queue for the first resource call message with a nested 32 // Searches the queue for the first resource call message with a nested
24 // message matching the given ID. On success, returns true and populates the 33 // message matching the given ID. On success, returns true and populates the
25 // givem params and nested message. 34 // givem params and nested message.
26 bool GetFirstResourceCallMatching( 35 bool GetFirstResourceCallMatching(
27 uint32 id, 36 uint32 id,
28 ResourceMessageCallParams* params, 37 ResourceMessageCallParams* params,
29 IPC::Message* nested_msg) const; 38 IPC::Message* nested_msg) const;
30 39
31 // Like GetFirstResourceCallMatching except for replies. 40 // Like GetFirstResourceCallMatching except for replies.
32 bool GetFirstResourceReplyMatching( 41 bool GetFirstResourceReplyMatching(
33 uint32 id, 42 uint32 id,
34 ResourceMessageReplyParams* params, 43 ResourceMessageReplyParams* params,
35 IPC::Message* nested_msg); 44 IPC::Message* nested_msg);
45
46 private:
47 scoped_ptr<IPC::Message> sync_reply_msg_;
48 };
49
50 // This is a message handler which generates reply messages for synchronous
51 // resource calls. This allows unit testing of the plugin side of resources
52 // which send sync messages. If you want to reply to a sync message type named
53 // |PpapiHostMsg_X_Y| with |PpapiPluginMsg_X_YReply| then usage would be as
54 // follows (from within |PluginProxyTest|s):
55 //
56 // PpapiHostMsg_X_YReply my_reply;
57 // ResourceSyncCallHandler handler(&sink(),
58 // PpapiHostMsg_X_Y::ID,
59 // PP_OK,
60 // my_reply);
61 // sink().AddFilter(&handler);
62 // // Do stuff to send a sync message ...
63 // // You can check handler.last_handled_msg() to ensure the correct message was
64 // // handled.
65 // sink().RemoveFilter(&handler);
66 class ResourceSyncCallHandler : public IPC::Listener {
67 public:
68 ResourceSyncCallHandler(ResourceMessageTestSink* test_sink,
69 uint32 incoming_type,
70 int32_t result,
71 const IPC::Message& reply_msg);
72 virtual ~ResourceSyncCallHandler();
73
74 // IPC::Listener.
75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
76
77 IPC::Message last_handled_msg() { return last_handled_msg_; }
78
79 private:
80 ResourceMessageTestSink* test_sink_;
81 uint32 incoming_type_;
82 int32_t result_;
83 IPC::Message reply_msg_;
84 IPC::Message last_handled_msg_;
36 }; 85 };
37 86
38 } // namespace proxy 87 } // namespace proxy
39 } // namespace ppapi 88 } // namespace ppapi
40 89
41 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_ 90 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_
OLDNEW
« 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