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