| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_HOST_PPAPI_HOST_H_ | 5 #ifndef PPAPI_HOST_PPAPI_HOST_H_ |
| 6 #define PPAPI_HOST_PPAPI_HOST_H_ | 6 #define PPAPI_HOST_PPAPI_HOST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
| 13 #include "ipc/ipc_sender.h" | 13 #include "ipc/ipc_sender.h" |
| 14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
| 15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
| 16 #include "ppapi/host/ppapi_host_export.h" | 16 #include "ppapi/host/ppapi_host_export.h" |
| 17 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 17 | 18 |
| 18 namespace ppapi { | 19 namespace ppapi { |
| 19 | 20 |
| 20 namespace proxy { | 21 namespace proxy { |
| 21 class ResourceMessageCallParams; | 22 class ResourceMessageCallParams; |
| 22 class ResourceMessageReplyParams; | 23 class ResourceMessageReplyParams; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace host { | 26 namespace host { |
| 26 | 27 |
| 27 class HostFactory; | 28 class HostFactory; |
| 28 class ResourceHost; | 29 class ResourceHost; |
| 29 | 30 |
| 30 // The host provides routing and tracking for resource message calls that | 31 // The host provides routing and tracking for resource message calls that |
| 31 // come from the plugin to the host (browser or renderer), and the | 32 // come from the plugin to the host (browser or renderer), and the |
| 32 // corresponding replies. | 33 // corresponding replies. |
| 33 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { | 34 class PPAPI_HOST_EXPORT PpapiHost : public IPC::Sender, public IPC::Listener { |
| 34 public: | 35 public: |
| 35 // The sender is the channel to the plugin for outgoing messages. The factory | 36 // The sender is the channel to the plugin for outgoing messages. The factory |
| 36 // will be used to receive resource creation messages from the plugin. Both | 37 // will be used to receive resource creation messages from the plugin. Both |
| 37 // pointers are owned by the caller and must outlive this class. | 38 // pointers are owned by the caller and must outlive this class. |
| 38 PpapiHost(IPC::Sender* sender, HostFactory* host_factory); | 39 PpapiHost(IPC::Sender* sender, |
| 40 HostFactory* host_factory, |
| 41 const PpapiPermissions& perms); |
| 39 virtual ~PpapiHost(); | 42 virtual ~PpapiHost(); |
| 40 | 43 |
| 44 const PpapiPermissions& permissions() const { return permissions_; } |
| 45 |
| 41 // Sender implementation. Forwards to the sender_. | 46 // Sender implementation. Forwards to the sender_. |
| 42 virtual bool Send(IPC::Message* msg) OVERRIDE; | 47 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 43 | 48 |
| 44 // Listener implementation. | 49 // Listener implementation. |
| 45 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 50 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 46 | 51 |
| 47 // Sends the given reply message to the plugin. | 52 // Sends the given reply message to the plugin. |
| 48 void SendReply(const proxy::ResourceMessageReplyParams& params, | 53 void SendReply(const proxy::ResourceMessageReplyParams& params, |
| 49 const IPC::Message& msg); | 54 const IPC::Message& msg); |
| 50 | 55 |
| 51 private: | 56 private: |
| 52 // Message handlers. | 57 // Message handlers. |
| 53 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, | 58 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, |
| 54 const IPC::Message& nested_msg); | 59 const IPC::Message& nested_msg); |
| 55 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, | 60 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, |
| 56 PP_Instance instance, | 61 PP_Instance instance, |
| 57 const IPC::Message& nested_msg); | 62 const IPC::Message& nested_msg); |
| 58 void OnHostMsgResourceDestroyed(PP_Resource resource); | 63 void OnHostMsgResourceDestroyed(PP_Resource resource); |
| 59 | 64 |
| 60 // Returns null if the resource doesn't exist. | 65 // Returns null if the resource doesn't exist. |
| 61 host::ResourceHost* GetResourceHost(PP_Resource resource); | 66 host::ResourceHost* GetResourceHost(PP_Resource resource); |
| 62 | 67 |
| 63 // Non-owning pointer. | 68 // Non-owning pointer. |
| 64 IPC::Sender* sender_; | 69 IPC::Sender* sender_; |
| 65 | 70 |
| 66 // Non-owning pointer. | 71 // Non-owning pointer. |
| 67 HostFactory* host_factory_; | 72 HostFactory* host_factory_; |
| 68 | 73 |
| 74 PpapiPermissions permissions_; |
| 75 |
| 69 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; | 76 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; |
| 70 ResourceMap resources_; | 77 ResourceMap resources_; |
| 71 | 78 |
| 72 DISALLOW_COPY_AND_ASSIGN(PpapiHost); | 79 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
| 73 }; | 80 }; |
| 74 | 81 |
| 75 } // namespace host | 82 } // namespace host |
| 76 } // namespace ppapi | 83 } // namespace ppapi |
| 77 | 84 |
| 78 #endif // PPAPI_HOST_PPAPIE_HOST_H_ | 85 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
| OLD | NEW |