OLD | NEW |
---|---|
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_listener.h" | 8 #include "ipc/ipc_listener.h" |
9 #include "ipc/ipc_test_sink.h" | 9 #include "ipc/ipc_test_sink.h" |
10 #include "ppapi/c/pp_stdint.h" | 10 #include "ppapi/c/pp_stdint.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // IPC::TestSink. | 26 // IPC::TestSink. |
27 // Overridden to handle sync messages. | 27 // Overridden to handle sync messages. |
28 virtual bool Send(IPC::Message* msg) OVERRIDE; | 28 virtual bool Send(IPC::Message* msg) OVERRIDE; |
29 | 29 |
30 // Sets the reply message that will be returned to the next sync message sent. | 30 // Sets the reply message that will be returned to the next sync message sent. |
31 // This test sink owns any reply messages passed into this method. | 31 // This test sink owns any reply messages passed into this method. |
32 void SetSyncReplyMessage(IPC::Message* reply_msg); | 32 void SetSyncReplyMessage(IPC::Message* reply_msg); |
33 | 33 |
34 // Searches the queue for the first resource call message with a nested | 34 // Searches the queue for the first resource call message with a nested |
35 // message matching the given ID. On success, returns true and populates the | 35 // message matching the given ID. On success, returns true and populates the |
36 // givem params and nested message. | 36 // given params and nested message. |
37 bool GetFirstResourceCallMatching( | 37 bool GetFirstResourceCallMatching( |
38 uint32 id, | 38 uint32 id, |
39 ResourceMessageCallParams* params, | 39 ResourceMessageCallParams* params, |
40 IPC::Message* nested_msg) const; | 40 IPC::Message* nested_msg) const; |
41 | 41 |
42 // Like GetFirstResourceCallMatching except for replies. | 42 // Like GetFirstResourceCallMatching except for replies. |
43 bool GetFirstResourceReplyMatching( | 43 bool GetFirstResourceReplyMatching( |
raymes
2014/01/08 02:21:22
Can we get rid of these two methods now? Can't we
bbudge
2014/01/08 03:05:17
It won't be so simple for callers, since the vecto
| |
44 uint32 id, | 44 uint32 id, |
45 ResourceMessageReplyParams* params, | 45 ResourceMessageReplyParams* params, |
46 IPC::Message* nested_msg); | 46 IPC::Message* nested_msg); |
47 | 47 |
48 // Searches the queue for the next resource call message with a nested | 48 // Searches the queue for all resource call messages with a nested message |
49 // message matching the given ID. On success, returns true and populates the | 49 // matching the given ID. |
50 // givem params and nested message. The first time this is called, it is | 50 typedef std::pair<ResourceMessageCallParams, IPC::Message> ResourceCall; |
51 // equivalent to GetFirstResourceCallMatching. | 51 typedef std::vector<ResourceCall> ResourceCallVector; |
52 bool GetNextResourceCallMatching( | 52 ResourceCallVector GetAllResourceCallsMatching(uint32 id); |
53 uint32 id, | |
54 ResourceMessageCallParams* params, | |
55 IPC::Message* nested_msg); | |
56 | 53 |
57 // Like GetNextResourceCallMatching except for replies. | 54 // Like GetAllResourceCallsMatching except for replies. |
58 bool GetNextResourceReplyMatching( | 55 typedef std::pair<ResourceMessageReplyParams, IPC::Message> ResourceReply; |
59 uint32 id, | 56 typedef std::vector<ResourceReply> ResourceReplyVector; |
60 ResourceMessageReplyParams* params, | 57 ResourceReplyVector GetAllResourceRepliesMatching(uint32 id); |
61 IPC::Message* nested_msg); | |
62 | 58 |
63 private: | 59 private: |
64 scoped_ptr<IPC::Message> sync_reply_msg_; | 60 scoped_ptr<IPC::Message> sync_reply_msg_; |
65 int next_resource_call_; | |
66 int next_resource_reply_; | |
67 }; | 61 }; |
68 | 62 |
69 // This is a message handler which generates reply messages for synchronous | 63 // This is a message handler which generates reply messages for synchronous |
70 // resource calls. This allows unit testing of the plugin side of resources | 64 // resource calls. This allows unit testing of the plugin side of resources |
71 // which send sync messages. If you want to reply to a sync message type named | 65 // which send sync messages. If you want to reply to a sync message type named |
72 // |PpapiHostMsg_X_Y| with |PpapiPluginMsg_X_YReply| then usage would be as | 66 // |PpapiHostMsg_X_Y| with |PpapiPluginMsg_X_YReply| then usage would be as |
73 // follows (from within |PluginProxyTest|s): | 67 // follows (from within |PluginProxyTest|s): |
74 // | 68 // |
75 // PpapiHostMsg_X_YReply my_reply; | 69 // PpapiHostMsg_X_YReply my_reply; |
76 // ResourceSyncCallHandler handler(&sink(), | 70 // ResourceSyncCallHandler handler(&sink(), |
(...skipping 30 matching lines...) Expand all Loading... | |
107 int32_t result_; | 101 int32_t result_; |
108 const SerializedHandle* serialized_handle_; // Non-owning pointer. | 102 const SerializedHandle* serialized_handle_; // Non-owning pointer. |
109 IPC::Message reply_msg_; | 103 IPC::Message reply_msg_; |
110 IPC::Message last_handled_msg_; | 104 IPC::Message last_handled_msg_; |
111 }; | 105 }; |
112 | 106 |
113 } // namespace proxy | 107 } // namespace proxy |
114 } // namespace ppapi | 108 } // namespace ppapi |
115 | 109 |
116 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_ | 110 #endif // PPAPI_PROXY_RESOURCE_MESSAGE_TEST_SINK_H_ |
OLD | NEW |