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 "base/logging.h" |
| 8 #include "ipc/ipc_message.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/host/host_message_context.h" |
| 11 |
| 12 namespace ppapi { |
| 13 namespace host { |
| 14 |
| 15 ResourceMessageHandler::ResourceMessageHandler() { |
| 16 } |
| 17 |
| 18 ResourceMessageHandler::~ResourceMessageHandler() { |
| 19 } |
| 20 |
| 21 void ResourceMessageHandler::RunMessageHandlerAndReply( |
| 22 const IPC::Message& msg, |
| 23 HostMessageContext* context) { |
| 24 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| 25 reply_context.params.set_result(OnResourceMessageReceived(msg, context)); |
| 26 |
| 27 // Sanity check the resource handler. Note if the result was |
| 28 // "completion pending" the resource host may have already sent the reply. |
| 29 if (reply_context.params.result() == PP_OK_COMPLETIONPENDING) { |
| 30 // Message handler should have only returned a pending result if a |
| 31 // response will be sent to the plugin. |
| 32 DCHECK(context->params.has_callback()); |
| 33 |
| 34 // Message handler should not have written a message to be returned if |
| 35 // completion is pending. |
| 36 DCHECK(context->reply_msg.type() == 0); |
| 37 } else if (!context->params.has_callback()) { |
| 38 // When no response is required, the message handler should not have |
| 39 // written a message to be returned. |
| 40 DCHECK(context->reply_msg.type() == 0); |
| 41 |
| 42 // If there is no callback and the result of running the message handler |
| 43 // was not PP_OK the client won't find out. |
| 44 DLOG_IF(WARNING, reply_context.params.result() != PP_OK) |
| 45 << "'Post' message handler failed to complete successfully."; |
| 46 } |
| 47 |
| 48 if (context->params.has_callback() && |
| 49 reply_context.params.result() != PP_OK_COMPLETIONPENDING) |
| 50 SendReply(reply_context, context->reply_msg); |
| 51 } |
| 52 |
| 53 int32_t ResourceMessageHandler::OnResourceMessageReceived( |
| 54 const IPC::Message& msg, |
| 55 HostMessageContext* context) { |
| 56 return PP_ERROR_NOTSUPPORTED; |
| 57 } |
| 58 |
| 59 } // namespace host |
| 60 } // namespace ppapi |
OLD | NEW |