| 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 #include <memory> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
| 16 #include "ipc/ipc_sender.h" | 16 #include "ipc/ipc_sender.h" |
| 17 #include "ppapi/c/pp_instance.h" | 17 #include "ppapi/c/pp_instance.h" |
| 18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
| 19 #include "ppapi/host/ppapi_host_export.h" | 19 #include "ppapi/host/ppapi_host_export.h" |
| 20 #include "ppapi/shared_impl/ppapi_permissions.h" | 20 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 21 | 21 |
| 22 namespace ppapi { | 22 namespace ppapi { |
| 23 | 23 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Sends the given unsolicited reply message to the plugin. | 62 // Sends the given unsolicited reply message to the plugin. |
| 63 void SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg); | 63 void SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg); |
| 64 | 64 |
| 65 // Similar to |SendUnsolicitedReply()|, but also sends handles. | 65 // Similar to |SendUnsolicitedReply()|, but also sends handles. |
| 66 void SendUnsolicitedReplyWithHandles( | 66 void SendUnsolicitedReplyWithHandles( |
| 67 PP_Resource resource, | 67 PP_Resource resource, |
| 68 const IPC::Message& msg, | 68 const IPC::Message& msg, |
| 69 const std::vector<proxy::SerializedHandle>& handles); | 69 const std::vector<proxy::SerializedHandle>& handles); |
| 70 | 70 |
| 71 // Create a ResourceHost with the given |nested_msg|. | 71 // Create a ResourceHost with the given |nested_msg|. |
| 72 scoped_ptr<ResourceHost> CreateResourceHost(PP_Resource resource, | 72 std::unique_ptr<ResourceHost> CreateResourceHost( |
| 73 PP_Instance instance, | 73 PP_Resource resource, |
| 74 const IPC::Message& nested_msg); | 74 PP_Instance instance, |
| 75 const IPC::Message& nested_msg); |
| 75 | 76 |
| 76 // Adds the given host resource as a pending one (with no corresponding | 77 // Adds the given host resource as a pending one (with no corresponding |
| 77 // PluginResource object and no PP_Resource ID yet). The pending resource ID | 78 // PluginResource object and no PP_Resource ID yet). The pending resource ID |
| 78 // is returned. See PpapiHostMsg_AttachToPendingHost. | 79 // is returned. See PpapiHostMsg_AttachToPendingHost. |
| 79 int AddPendingResourceHost(scoped_ptr<ResourceHost> resource_host); | 80 int AddPendingResourceHost(std::unique_ptr<ResourceHost> resource_host); |
| 80 | 81 |
| 81 // Adds the given host factory filter to the host. The PpapiHost will take | 82 // Adds the given host factory filter to the host. The PpapiHost will take |
| 82 // ownership of the pointer. | 83 // ownership of the pointer. |
| 83 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter); | 84 void AddHostFactoryFilter(std::unique_ptr<HostFactory> filter); |
| 84 | 85 |
| 85 // Adds the given message filter to the host. The PpapiHost will take | 86 // Adds the given message filter to the host. The PpapiHost will take |
| 86 // ownership of the pointer. | 87 // ownership of the pointer. |
| 87 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); | 88 void AddInstanceMessageFilter(std::unique_ptr<InstanceMessageFilter> filter); |
| 88 | 89 |
| 89 // Returns null if the resource doesn't exist. | 90 // Returns null if the resource doesn't exist. |
| 90 host::ResourceHost* GetResourceHost(PP_Resource resource) const; | 91 host::ResourceHost* GetResourceHost(PP_Resource resource) const; |
| 91 | 92 |
| 92 private: | 93 private: |
| 93 friend class InstanceMessageFilter; | 94 friend class InstanceMessageFilter; |
| 94 | 95 |
| 95 void HandleResourceCall( | 96 void HandleResourceCall( |
| 96 const proxy::ResourceMessageCallParams& params, | 97 const proxy::ResourceMessageCallParams& params, |
| 97 const IPC::Message& nested_msg, | 98 const IPC::Message& nested_msg, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 116 | 117 |
| 117 // Non-owning pointer. | 118 // Non-owning pointer. |
| 118 IPC::Sender* sender_; | 119 IPC::Sender* sender_; |
| 119 | 120 |
| 120 PpapiPermissions permissions_; | 121 PpapiPermissions permissions_; |
| 121 | 122 |
| 122 // Filters for resource creation messages. Note that since we don't support | 123 // Filters for resource creation messages. Note that since we don't support |
| 123 // deleting these dynamically we don't need to worry about modifications | 124 // deleting these dynamically we don't need to worry about modifications |
| 124 // during iteration. If we add that capability, this should be replaced with | 125 // during iteration. If we add that capability, this should be replaced with |
| 125 // an base::ObserverList. | 126 // an base::ObserverList. |
| 126 std::vector<scoped_ptr<HostFactory>> host_factory_filters_; | 127 std::vector<std::unique_ptr<HostFactory>> host_factory_filters_; |
| 127 | 128 |
| 128 // Filters for instance messages. Note that since we don't support deleting | 129 // Filters for instance messages. Note that since we don't support deleting |
| 129 // these dynamically we don't need to worry about modifications during | 130 // these dynamically we don't need to worry about modifications during |
| 130 // iteration. If we add that capability, this should be replaced with an | 131 // iteration. If we add that capability, this should be replaced with an |
| 131 // base::ObserverList. | 132 // base::ObserverList. |
| 132 std::vector<scoped_ptr<InstanceMessageFilter>> instance_message_filters_; | 133 std::vector<std::unique_ptr<InstanceMessageFilter>> instance_message_filters_; |
| 133 | 134 |
| 134 typedef std::map<PP_Resource, scoped_ptr<ResourceHost>> ResourceMap; | 135 typedef std::map<PP_Resource, std::unique_ptr<ResourceHost>> ResourceMap; |
| 135 ResourceMap resources_; | 136 ResourceMap resources_; |
| 136 | 137 |
| 137 // Resources that have been created in the host and have not yet had the | 138 // Resources that have been created in the host and have not yet had the |
| 138 // corresponding PluginResource associated with them. | 139 // corresponding PluginResource associated with them. |
| 139 // See PpapiHostMsg_AttachToPendingHost. | 140 // See PpapiHostMsg_AttachToPendingHost. |
| 140 typedef std::map<int, scoped_ptr<ResourceHost>> PendingHostResourceMap; | 141 typedef std::map<int, std::unique_ptr<ResourceHost>> PendingHostResourceMap; |
| 141 PendingHostResourceMap pending_resource_hosts_; | 142 PendingHostResourceMap pending_resource_hosts_; |
| 142 int next_pending_resource_host_id_; | 143 int next_pending_resource_host_id_; |
| 143 | 144 |
| 144 DISALLOW_COPY_AND_ASSIGN(PpapiHost); | 145 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 } // namespace host | 148 } // namespace host |
| 148 } // namespace ppapi | 149 } // namespace ppapi |
| 149 | 150 |
| 150 #endif // PPAPI_HOST_PPAPIE_HOST_H_ | 151 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
| OLD | NEW |