Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/host/resource_message_handler.h" | |
| 6 | |
| 7 #include "ipc/ipc_message.h" | |
| 8 #include "ppapi/c/pp_errors.h" | |
| 9 #include "ppapi/host/host_message_context.h" | |
| 10 | |
| 11 namespace ppapi { | |
| 12 namespace host { | |
| 13 | |
| 14 ResourceMessageHandler::ResourceMessageHandler() { | |
| 15 } | |
| 16 | |
| 17 ResourceMessageHandler::~ResourceMessageHandler() { | |
| 18 } | |
| 19 | |
| 20 void ResourceMessageHandler::RunMessageHandlerAndReply( | |
| 21 const IPC::Message& msg, | |
| 22 HostMessageContext* context) { | |
| 23 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | |
| 24 reply_context.params.set_result(OnResourceMessageReceived(msg, context)); | |
| 25 | |
| 26 // Sanity check the resource handler. Note if the result was | |
| 27 // "completion pending" the resource host may have already sent the reply. | |
| 28 if (reply_context.params.result() == PP_OK_COMPLETIONPENDING) { | |
| 29 // Message handler should have only returned a pending result if a | |
| 30 // response will be sent to the plugin. | |
| 31 DCHECK(context->params.has_callback()); | |
| 32 | |
| 33 // Message handler should not have written a message to be returned if | |
| 34 // completion is pending. | |
| 35 DCHECK(context->reply_msg.type() == 0); | |
| 36 } else if (!context->params.has_callback()) { | |
| 37 // When no response is required, the message handler should not have | |
| 38 // written a message to be returned. | |
| 39 DCHECK(context->reply_msg.type() == 0); | |
|
yzshen1
2012/11/19 18:59:25
I notice that you removed a DLOG_IF here, any reas
raymes
2012/11/19 22:35:04
I think I may have started this CL prior to adding
| |
| 40 } | |
| 41 | |
| 42 if (context->params.has_callback() && | |
| 43 reply_context.params.result() != PP_OK_COMPLETIONPENDING) | |
| 44 SendReply(reply_context, context->reply_msg); | |
| 45 } | |
| 46 | |
| 47 int32_t ResourceMessageHandler::OnResourceMessageReceived( | |
| 48 const IPC::Message& msg, | |
| 49 HostMessageContext* context) { | |
| 50 return PP_ERROR_NOTSUPPORTED; | |
| 51 } | |
| 52 | |
| 53 } // namespace host | |
| 54 } // namespace ppapi | |
| OLD | NEW |