| 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 <set> |
| 9 | 10 |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 14 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 15 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
| 16 #include "ipc/ipc_sender.h" | 17 #include "ipc/ipc_sender.h" |
| 17 #include "ppapi/c/pp_instance.h" | 18 #include "ppapi/c/pp_instance.h" |
| 18 #include "ppapi/c/pp_resource.h" | 19 #include "ppapi/c/pp_resource.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 const IPC::Message& msg); | 58 const IPC::Message& msg); |
| 58 | 59 |
| 59 // Adds the given host factory filter to the host. The PpapiHost will take | 60 // Adds the given host factory filter to the host. The PpapiHost will take |
| 60 // ownership of the pointer. | 61 // ownership of the pointer. |
| 61 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter); | 62 void AddHostFactoryFilter(scoped_ptr<HostFactory> filter); |
| 62 | 63 |
| 63 // Adds the given message filter to the host. The PpapiHost will take | 64 // Adds the given message filter to the host. The PpapiHost will take |
| 64 // ownership of the pointer. | 65 // ownership of the pointer. |
| 65 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); | 66 void AddInstanceMessageFilter(scoped_ptr<InstanceMessageFilter> filter); |
| 66 | 67 |
| 68 // Returns null if the resource doesn't exist. |
| 69 host::ResourceHost* GetResourceHost(PP_Resource resource) const; |
| 70 |
| 67 private: | 71 private: |
| 68 friend class InstanceMessageFilter; | 72 friend class InstanceMessageFilter; |
| 69 | 73 |
| 74 void HandleResourceCall( |
| 75 const proxy::ResourceMessageCallParams& params, |
| 76 const IPC::Message& nested_msg, |
| 77 HostMessageContext* context); |
| 78 |
| 70 // Message handlers. | 79 // Message handlers. |
| 71 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, | 80 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, |
| 72 const IPC::Message& nested_msg); | 81 const IPC::Message& nested_msg); |
| 73 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, | 82 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, |
| 74 PP_Instance instance, | 83 PP_Instance instance, |
| 75 const IPC::Message& nested_msg); | 84 const IPC::Message& nested_msg); |
| 76 void OnHostMsgResourceDestroyed(PP_Resource resource); | 85 void OnHostMsgResourceDestroyed(PP_Resource resource); |
| 77 | 86 |
| 78 // Returns null if the resource doesn't exist. | |
| 79 host::ResourceHost* GetResourceHost(PP_Resource resource); | |
| 80 | |
| 81 // Non-owning pointer. | 87 // Non-owning pointer. |
| 82 IPC::Sender* sender_; | 88 IPC::Sender* sender_; |
| 83 | 89 |
| 84 PpapiPermissions permissions_; | 90 PpapiPermissions permissions_; |
| 85 | 91 |
| 86 // Filters for resource creation messages. Note that since we don't support | 92 // Filters for resource creation messages. Note that since we don't support |
| 87 // deleting these dynamically we don't need to worry about modifications | 93 // deleting these dynamically we don't need to worry about modifications |
| 88 // during iteration. If we add that capability, this should be replaced with | 94 // during iteration. If we add that capability, this should be replaced with |
| 89 // an ObserverList. | 95 // an ObserverList. |
| 90 ScopedVector<HostFactory> host_factory_filters_; | 96 ScopedVector<HostFactory> host_factory_filters_; |
| 91 | 97 |
| 92 // Filters for instance messages. Note that since we don't support deleting | 98 // Filters for instance messages. Note that since we don't support deleting |
| 93 // these dynamically we don't need to worry about modifications during | 99 // these dynamically we don't need to worry about modifications during |
| 94 // iteration. If we add that capability, this should be replaced with an | 100 // iteration. If we add that capability, this should be replaced with an |
| 95 // ObserverList. | 101 // ObserverList. |
| 96 ScopedVector<InstanceMessageFilter> instance_message_filters_; | 102 ScopedVector<InstanceMessageFilter> instance_message_filters_; |
| 97 | 103 |
| 98 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; | 104 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; |
| 99 ResourceMap resources_; | 105 ResourceMap resources_; |
| 100 | 106 |
| 101 DISALLOW_COPY_AND_ASSIGN(PpapiHost); | 107 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
| 102 }; | 108 }; |
| 103 | 109 |
| 104 } // namespace host | 110 } // namespace host |
| 105 } // namespace ppapi | 111 } // namespace ppapi |
| 106 | 112 |
| 107 #endif // PPAPI_HOST_PPAPIE_HOST_H_ | 113 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
| OLD | NEW |