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 #ifndef PPAPI_HOST_HOST_MESSAGE_CONTEXT_H_ 6 #define PPAPI_HOST_HOST_MESSAGE_CONTEXT_H_ 7 8 #include "ipc/ipc_message.h" 9 #include "ppapi/host/ppapi_host_export.h" 10 #include "ppapi/proxy/resource_message_params.h" 11 12 namespace ppapi { 13 namespace host { 14 15 // This context structure provides information about outgoing resource message 16 // replies. 17 struct PPAPI_HOST_EXPORT ReplyMessageContext { 18 ReplyMessageContext(); 19 ReplyMessageContext( 20 const ppapi::proxy::ResourceMessageReplyParams& cp, 21 IPC::Message* sync_reply_msg, 22 int routing_id); 23 ~ReplyMessageContext(); 24 25 // The "reply params" struct with the same resource and sequence number 26 // as the original resource message call. 27 ppapi::proxy::ResourceMessageReplyParams params; 28 29 // If this context is generated from a sync message, this will be set to the 30 // incoming sync message. Otherwise, it will be NULL. The plugin controls 31 // whether or not the resource call is synchronous or asynchronous so a 32 // ResoureHost cannot make any assumptions about whether or not this is NULL. 33 IPC::Message* sync_reply_msg; 34 35 // Routing ID to be used when sending a reply message. This is only useful 36 // when the plugin is in-process. Otherwise, the value will be 37 // MSG_ROUTING_NONE. 38 int routing_id; 39 }; 40 41 // This context structure provides information about incoming resource message 42 // call requests when passed to resources. 43 struct PPAPI_HOST_EXPORT HostMessageContext { 44 explicit HostMessageContext( 45 const ppapi::proxy::ResourceMessageCallParams& cp); 46 HostMessageContext( 47 int routing_id, 48 const ppapi::proxy::ResourceMessageCallParams& cp); 49 HostMessageContext( 50 const ppapi::proxy::ResourceMessageCallParams& cp, 51 IPC::Message* sync_reply_msg); 52 ~HostMessageContext(); 53 54 // Returns a reply message context struct which includes the reply params. 55 ReplyMessageContext MakeReplyMessageContext() const; 56 57 // The original call parameters passed to the resource message call. This 58 // cannot be a reference because this object may be passed to another thread. 59 ppapi::proxy::ResourceMessageCallParams params; 60 61 // The reply message. If the params has the callback flag set, this message 62 // will be sent in reply. It is initialized to the empty message. If the 63 // handler wants to send something else, it should just assign the message 64 // it wants to this value. 65 IPC::Message reply_msg; 66 67 // If this context is generated from a sync message, this will be set to the 68 // incoming sync message. Otherwise, it will be NULL. 69 IPC::Message* sync_reply_msg; 70 71 // Routing ID to be used when sending a reply message. This is only useful 72 // when the plugin is in-process. Otherwise, the value will be 73 // MSG_ROUTING_NONE. 74 int routing_id; 75 }; 76 77 } // namespace host 78 } // namespace ppapi 79 80 #endif // PPAPI_HOST_HOST_MESSAGE_CONTEXT_H_ 81