Chromium Code Reviews| 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" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 // Listener implementation. | 54 // Listener implementation. |
| 55 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 55 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 56 | 56 |
| 57 // Sends the given reply message to the plugin. | 57 // Sends the given reply message to the plugin. |
| 58 void SendReply(const ReplyMessageContext& context, | 58 void SendReply(const ReplyMessageContext& context, |
| 59 const IPC::Message& msg); | 59 const IPC::Message& msg); |
| 60 | 60 |
| 61 // Sends the given unsolicited reply message to the plugin. | 61 // Sends the given unsolicited reply message to the plugin. |
| 62 void SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg); | 62 void SendUnsolicitedReply(PP_Resource resource, const IPC::Message& msg); |
| 63 | 63 |
| 64 // Adds the given host resource as a pending one (with no corresponding | |
| 65 // PluginResource object and no PP_Resource ID yet). The pending resource ID | |
| 66 // is returned. See PpapiHostMsg_AttachToPendingHost. | |
| 67 int AddPendingResourceHost(scoped_ptr<ResourceHost> resource_host); | |
| 68 | |
| 64 // Adds the given host factory filter to the host. The PpapiHost will take | 69 // Adds the given host factory filter to the host. The PpapiHost will take |
| 65 // ownership of the pointer. | 70 // ownership of the pointer. |
| 66 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter); | 71 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter); |
| 67 | 72 |
| 68 // Adds the given message filter to the host. The PpapiHost will take | 73 // Adds the given message filter to the host. The PpapiHost will take |
| 69 // ownership of the pointer. | 74 // ownership of the pointer. |
| 70 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); | 75 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); |
| 71 | 76 |
| 72 // Returns null if the resource doesn't exist. | 77 // Returns null if the resource doesn't exist. |
| 73 host::ResourceHost* GetResourceHost(PP_Resource resource) const; | 78 host::ResourceHost* GetResourceHost(PP_Resource resource) const; |
| 74 | 79 |
| 75 private: | 80 private: |
| 76 friend class InstanceMessageFilter; | 81 friend class InstanceMessageFilter; |
| 77 | 82 |
| 78 void HandleResourceCall( | 83 void HandleResourceCall( |
| 79 const proxy::ResourceMessageCallParams& params, | 84 const proxy::ResourceMessageCallParams& params, |
| 80 const IPC::Message& nested_msg, | 85 const IPC::Message& nested_msg, |
| 81 HostMessageContext* context); | 86 HostMessageContext* context); |
| 82 | 87 |
| 83 // Message handlers. | 88 // Message handlers. |
| 84 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, | 89 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, |
| 85 const IPC::Message& nested_msg); | 90 const IPC::Message& nested_msg); |
| 86 void OnHostMsgResourceSyncCall( | 91 void OnHostMsgResourceSyncCall( |
| 87 const proxy::ResourceMessageCallParams& params, | 92 const proxy::ResourceMessageCallParams& params, |
| 88 const IPC::Message& nested_msg, | 93 const IPC::Message& nested_msg, |
| 89 IPC::Message* reply_msg); | 94 IPC::Message* reply_msg); |
| 90 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, | 95 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, |
| 91 PP_Instance instance, | 96 PP_Instance instance, |
| 92 const IPC::Message& nested_msg); | 97 const IPC::Message& nested_msg); |
| 98 void OnHostMsgAttachToPendingHost(PP_Resource rseource, int pending_host_id); | |
|
raymes
2012/12/03 15:55:18
rseource->resource
| |
| 93 void OnHostMsgResourceDestroyed(PP_Resource resource); | 99 void OnHostMsgResourceDestroyed(PP_Resource resource); |
| 94 | 100 |
| 95 // Non-owning pointer. | 101 // Non-owning pointer. |
| 96 IPC::Sender* sender_; | 102 IPC::Sender* sender_; |
| 97 | 103 |
| 98 PpapiPermissions permissions_; | 104 PpapiPermissions permissions_; |
| 99 | 105 |
| 100 // Filters for resource creation messages. Note that since we don't support | 106 // Filters for resource creation messages. Note that since we don't support |
| 101 // deleting these dynamically we don't need to worry about modifications | 107 // deleting these dynamically we don't need to worry about modifications |
| 102 // during iteration. If we add that capability, this should be replaced with | 108 // during iteration. If we add that capability, this should be replaced with |
| 103 // an ObserverList. | 109 // an ObserverList. |
| 104 ScopedVector<HostFactory> host_factory_filters_; | 110 ScopedVector<HostFactory> host_factory_filters_; |
| 105 | 111 |
| 106 // Filters for instance messages. Note that since we don't support deleting | 112 // Filters for instance messages. Note that since we don't support deleting |
| 107 // these dynamically we don't need to worry about modifications during | 113 // these dynamically we don't need to worry about modifications during |
| 108 // iteration. If we add that capability, this should be replaced with an | 114 // iteration. If we add that capability, this should be replaced with an |
| 109 // ObserverList. | 115 // ObserverList. |
| 110 ScopedVector<InstanceMessageFilter> instance_message_filters_; | 116 ScopedVector<InstanceMessageFilter> instance_message_filters_; |
| 111 | 117 |
| 112 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; | 118 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; |
| 113 ResourceMap resources_; | 119 ResourceMap resources_; |
| 114 | 120 |
| 121 // Resources that have been created in the host and have not yet had the | |
| 122 // corresponding PluginResource associated with them. | |
| 123 // See PpapiHostMsg_AttachToPendingHost. | |
| 124 typedef std::map<int, linked_ptr<ResourceHost> > PendingHostResourceMap; | |
| 125 PendingHostResourceMap pending_resource_hosts_; | |
| 126 int next_pending_resource_host_id_; | |
| 127 | |
| 115 DISALLOW_COPY_AND_ASSIGN(PpapiHost); | 128 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
| 116 }; | 129 }; |
| 117 | 130 |
| 118 } // namespace host | 131 } // namespace host |
| 119 } // namespace ppapi | 132 } // namespace ppapi |
| 120 | 133 |
| 121 #endif // PPAPI_HOST_PPAPIE_HOST_H_ | 134 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
| OLD | NEW |