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

Unified Diff: ppapi/proxy/resource_message_test_sink.cc

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
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
index 7daf43570794a76cf9adab620d2b31082d49929a..0e8dbe82e7d687b1085060a87029ec251036e61f 100644
--- a/ppapi/proxy/resource_message_test_sink.cc
+++ b/ppapi/proxy/resource_message_test_sink.cc
@@ -36,12 +36,33 @@ bool GetFirstResourceMessageMatching(const ResourceMessageTestSink& sink,
} // namespace
-ResourceMessageTestSink::ResourceMessageTestSink() {
+ResourceMessageTestSink::ResourceMessageTestSink()
+ : sync_reply_msg_(NULL) {
}
ResourceMessageTestSink::~ResourceMessageTestSink() {
}
+bool ResourceMessageTestSink::Send(IPC::Message* msg) {
+ IPC::MessageReplyDeserializer* reply_deserializer;
yzshen1 2012/10/05 18:16:46 You should init it.
raymes 2012/10/08 17:08:50 Done.
+ if (msg->is_sync()) {
+ reply_deserializer =
yzshen1 2012/10/05 18:16:46 Are we leaking reply_deserializer?
raymes 2012/10/08 17:08:50 Done.
+ static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer();
+ }
+ bool result = IPC::TestSink::Send(msg);
+ if (sync_reply_msg_) {
yzshen1 2012/10/05 18:16:46 is it true that msg->is_sync() <==> sync_reply_msg
raymes 2012/10/08 17:08:50 I'm quite sure it is because this is done in other
+ reply_deserializer->SerializeOutputParameters(*sync_reply_msg_);
+ delete sync_reply_msg_;
+ sync_reply_msg_ = NULL;
+ }
+ return result;
+}
+
+void ResourceMessageTestSink::SetSyncReplyMessage(IPC::Message* reply_msg) {
+ DCHECK(!sync_reply_msg_);
+ sync_reply_msg_ = reply_msg;
yzshen1 2012/10/05 18:16:46 Is it possible that we leak sync_reply_msg_?
raymes 2012/10/08 17:08:50 Done. Used a scoped_ptr to make sure we never leak
+}
+
bool ResourceMessageTestSink::GetFirstResourceCallMatching(
uint32 id,
ResourceMessageCallParams* params,
@@ -60,5 +81,43 @@ bool ResourceMessageTestSink::GetFirstResourceReplyMatching(
*this, id, params, nested_msg);
}
+ResourceSyncCallHandler::ResourceSyncCallHandler(
+ ResourceMessageTestSink* test_sink,
+ uint32 incoming_type,
+ int32_t result,
+ const IPC::Message& reply_msg)
+ : test_sink_(test_sink),
+ incoming_type_(incoming_type),
+ result_(result),
+ reply_msg_(reply_msg) {
+}
+
+ResourceSyncCallHandler::~ResourceSyncCallHandler() {
+}
+
+bool ResourceSyncCallHandler::OnMessageReceived(const IPC::Message& msg) {
+ if (msg.type() != ::PpapiHostMsg_ResourceSyncCall::ID)
+ return false;
+ ::PpapiHostMsg_ResourceSyncCall::Schema::SendParam send_params;
yzshen1 2012/10/05 18:16:46 nit: :: is not necessary.
raymes 2012/10/08 17:08:50 Done.
+ DCHECK(::PpapiHostMsg_ResourceSyncCall::ReadSendParam(
+ &msg, &send_params));
+ ResourceMessageCallParams call_params = send_params.a;
+ IPC::Message call_msg = send_params.b;
+ if (call_msg.type() != incoming_type_)
+ return false;
+ IPC::Message* wrapper_reply_msg = IPC::SyncMessage::GenerateReply(&msg);
+ ResourceMessageReplyParams reply_params(call_params.pp_resource(),
+ call_params.sequence());
+ reply_params.set_result(result_);
+ ::PpapiHostMsg_ResourceSyncCall::WriteReplyParams(
+ wrapper_reply_msg, reply_params, reply_msg_);
+ test_sink_->SetSyncReplyMessage(wrapper_reply_msg);
+
+ // Stash a copy of the message for inspection later.
+ last_handled_msg_ = call_msg;
+ return true;
+}
+
+
} // namespace proxy
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698