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 #ifndef PPAPI_HOST_PPAPI_HOST_H_ |
| 6 #define PPAPI_HOST_PPAPI_HOST_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/memory/linked_ptr.h" |
| 11 #include "ipc/ipc_channel.h" |
| 12 #include "ipc/ipc_message.h" |
| 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/c/pp_resource.h" |
| 15 #include "ppapi/host/ppapi_host_export.h" |
| 16 |
| 17 namespace ppapi { |
| 18 |
| 19 namespace proxy { |
| 20 class ResourceMessageCallParams; |
| 21 class ResourceMessageReplyParams; |
| 22 } |
| 23 |
| 24 namespace host { |
| 25 |
| 26 class HostFactory; |
| 27 class ResourceHost; |
| 28 |
| 29 class PPAPI_HOST_EXPORT PpapiHost |
| 30 : public IPC::Message::Sender, |
| 31 public IPC::Channel::Listener { |
| 32 public: |
| 33 PpapiHost(IPC::Message::Sender* sender, |
| 34 HostFactory* host_factory); |
| 35 ~PpapiHost(); |
| 36 |
| 37 // Sender implementation |
| 38 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 39 |
| 40 // Listener implementation |
| 41 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 42 |
| 43 void SendReply(const proxy::ResourceMessageReplyParams& params, |
| 44 const IPC::Message& msg); |
| 45 |
| 46 private: |
| 47 struct InstanceData; |
| 48 |
| 49 // Message handlers. |
| 50 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, |
| 51 const IPC::Message& nested_msg); |
| 52 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, |
| 53 PP_Instance instance, |
| 54 const IPC::Message& nested_msg); |
| 55 void OnHostMsgResourceDestroyed(PP_Resource resource); |
| 56 |
| 57 // Returns null if the resource doesn't exist. |
| 58 host::ResourceHost* GetResourceHost(PP_Resource resource); |
| 59 |
| 60 // Non-owning pointer. |
| 61 IPC::Message::Sender* sender_; |
| 62 |
| 63 // Non-owning pointer. |
| 64 HostFactory* host_factory_; |
| 65 |
| 66 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; |
| 67 ResourceMap resources_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
| 70 }; |
| 71 |
| 72 } // namespace host |
| 73 } // namespace ppapi |
| 74 |
| 75 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
OLD | NEW |