 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| 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 #include "ppapi/proxy/resource_message_test_sink.h" | 5 #include "ppapi/proxy/resource_message_test_sink.h" | 
| 6 | 6 | 
| 7 #include "ppapi/proxy/ppapi_messages.h" | 7 #include "ppapi/proxy/ppapi_messages.h" | 
| 8 #include "ppapi/proxy/resource_message_params.h" | 8 #include "ppapi/proxy/resource_message_params.h" | 
| 9 | 9 | 
| 10 namespace ppapi { | 10 namespace ppapi { | 
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 *nested_msg = cur_msg; | 29 *nested_msg = cur_msg; | 
| 30 return true; | 30 return true; | 
| 31 } | 31 } | 
| 32 } | 32 } | 
| 33 } | 33 } | 
| 34 return false; | 34 return false; | 
| 35 } | 35 } | 
| 36 | 36 | 
| 37 } // namespace | 37 } // namespace | 
| 38 | 38 | 
| 39 ResourceMessageTestSink::ResourceMessageTestSink() { | 39 ResourceMessageTestSink::ResourceMessageTestSink() | 
| 40 : sync_reply_msg_(NULL) { | |
| 40 } | 41 } | 
| 41 | 42 | 
| 42 ResourceMessageTestSink::~ResourceMessageTestSink() { | 43 ResourceMessageTestSink::~ResourceMessageTestSink() { | 
| 43 } | 44 } | 
| 44 | 45 | 
| 46 bool ResourceMessageTestSink::Send(IPC::Message* msg) { | |
| 47 IPC::MessageReplyDeserializer* reply_deserializer; | |
| 
yzshen1
2012/10/05 18:16:46
You should init it.
 
raymes
2012/10/08 17:08:50
Done.
 | |
| 48 if (msg->is_sync()) { | |
| 49 reply_deserializer = | |
| 
yzshen1
2012/10/05 18:16:46
Are we leaking reply_deserializer?
 
raymes
2012/10/08 17:08:50
Done.
 | |
| 50 static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer(); | |
| 51 } | |
| 52 bool result = IPC::TestSink::Send(msg); | |
| 53 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
 | |
| 54 reply_deserializer->SerializeOutputParameters(*sync_reply_msg_); | |
| 55 delete sync_reply_msg_; | |
| 56 sync_reply_msg_ = NULL; | |
| 57 } | |
| 58 return result; | |
| 59 } | |
| 60 | |
| 61 void ResourceMessageTestSink::SetSyncReplyMessage(IPC::Message* reply_msg) { | |
| 62 DCHECK(!sync_reply_msg_); | |
| 63 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
 | |
| 64 } | |
| 65 | |
| 45 bool ResourceMessageTestSink::GetFirstResourceCallMatching( | 66 bool ResourceMessageTestSink::GetFirstResourceCallMatching( | 
| 46 uint32 id, | 67 uint32 id, | 
| 47 ResourceMessageCallParams* params, | 68 ResourceMessageCallParams* params, | 
| 48 IPC::Message* nested_msg) const { | 69 IPC::Message* nested_msg) const { | 
| 49 return GetFirstResourceMessageMatching<PpapiHostMsg_ResourceCall, | 70 return GetFirstResourceMessageMatching<PpapiHostMsg_ResourceCall, | 
| 50 ResourceMessageCallParams>( | 71 ResourceMessageCallParams>( | 
| 51 *this, id, params, nested_msg); | 72 *this, id, params, nested_msg); | 
| 52 } | 73 } | 
| 53 | 74 | 
| 54 bool ResourceMessageTestSink::GetFirstResourceReplyMatching( | 75 bool ResourceMessageTestSink::GetFirstResourceReplyMatching( | 
| 55 uint32 id, | 76 uint32 id, | 
| 56 ResourceMessageReplyParams* params, | 77 ResourceMessageReplyParams* params, | 
| 57 IPC::Message* nested_msg) { | 78 IPC::Message* nested_msg) { | 
| 58 return GetFirstResourceMessageMatching<PpapiPluginMsg_ResourceReply, | 79 return GetFirstResourceMessageMatching<PpapiPluginMsg_ResourceReply, | 
| 59 ResourceMessageReplyParams>( | 80 ResourceMessageReplyParams>( | 
| 60 *this, id, params, nested_msg); | 81 *this, id, params, nested_msg); | 
| 61 } | 82 } | 
| 62 | 83 | 
| 84 ResourceSyncCallHandler::ResourceSyncCallHandler( | |
| 85 ResourceMessageTestSink* test_sink, | |
| 86 uint32 incoming_type, | |
| 87 int32_t result, | |
| 88 const IPC::Message& reply_msg) | |
| 89 : test_sink_(test_sink), | |
| 90 incoming_type_(incoming_type), | |
| 91 result_(result), | |
| 92 reply_msg_(reply_msg) { | |
| 93 } | |
| 94 | |
| 95 ResourceSyncCallHandler::~ResourceSyncCallHandler() { | |
| 96 } | |
| 97 | |
| 98 bool ResourceSyncCallHandler::OnMessageReceived(const IPC::Message& msg) { | |
| 99 if (msg.type() != ::PpapiHostMsg_ResourceSyncCall::ID) | |
| 100 return false; | |
| 101 ::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.
 | |
| 102 DCHECK(::PpapiHostMsg_ResourceSyncCall::ReadSendParam( | |
| 103 &msg, &send_params)); | |
| 104 ResourceMessageCallParams call_params = send_params.a; | |
| 105 IPC::Message call_msg = send_params.b; | |
| 106 if (call_msg.type() != incoming_type_) | |
| 107 return false; | |
| 108 IPC::Message* wrapper_reply_msg = IPC::SyncMessage::GenerateReply(&msg); | |
| 109 ResourceMessageReplyParams reply_params(call_params.pp_resource(), | |
| 110 call_params.sequence()); | |
| 111 reply_params.set_result(result_); | |
| 112 ::PpapiHostMsg_ResourceSyncCall::WriteReplyParams( | |
| 113 wrapper_reply_msg, reply_params, reply_msg_); | |
| 114 test_sink_->SetSyncReplyMessage(wrapper_reply_msg); | |
| 115 | |
| 116 // Stash a copy of the message for inspection later. | |
| 117 last_handled_msg_ = call_msg; | |
| 118 return true; | |
| 119 } | |
| 120 | |
| 121 | |
| 63 } // namespace proxy | 122 } // namespace proxy | 
| 64 } // namespace ppapi | 123 } // namespace ppapi | 
| OLD | NEW |