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