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 |
| 71 // Returns true if the resource is a known Graphics2D resource. |
| 72 bool IsGraphics2DResource(PP_Resource resource) const; |
| 73 |
67 private: | 74 private: |
68 friend class InstanceMessageFilter; | 75 friend class InstanceMessageFilter; |
69 | 76 |
| 77 template <typename Container, typename Element> |
| 78 static void ReleaseResource(Container container, Element element); |
| 79 |
70 // Message handlers. | 80 // Message handlers. |
71 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, | 81 void OnHostMsgResourceCall(const proxy::ResourceMessageCallParams& params, |
72 const IPC::Message& nested_msg); | 82 const IPC::Message& nested_msg); |
73 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, | 83 void OnHostMsgResourceCreated(const proxy::ResourceMessageCallParams& param, |
74 PP_Instance instance, | 84 PP_Instance instance, |
75 const IPC::Message& nested_msg); | 85 const IPC::Message& nested_msg); |
76 void OnHostMsgResourceDestroyed(PP_Resource resource); | 86 void OnHostMsgResourceDestroyed(PP_Resource resource); |
77 | 87 |
78 // Returns null if the resource doesn't exist. | |
79 host::ResourceHost* GetResourceHost(PP_Resource resource); | |
80 | |
81 // Non-owning pointer. | 88 // Non-owning pointer. |
82 IPC::Sender* sender_; | 89 IPC::Sender* sender_; |
83 | 90 |
84 PpapiPermissions permissions_; | 91 PpapiPermissions permissions_; |
85 | 92 |
86 // Filters for resource creation messages. Note that since we don't support | 93 // Filters for resource creation messages. Note that since we don't support |
87 // deleting these dynamically we don't need to worry about modifications | 94 // deleting these dynamically we don't need to worry about modifications |
88 // during iteration. If we add that capability, this should be replaced with | 95 // during iteration. If we add that capability, this should be replaced with |
89 // an ObserverList. | 96 // an ObserverList. |
90 ScopedVector<HostFactory> host_factory_filters_; | 97 ScopedVector<HostFactory> host_factory_filters_; |
91 | 98 |
92 // Filters for instance messages. Note that since we don't support deleting | 99 // Filters for instance messages. Note that since we don't support deleting |
93 // these dynamically we don't need to worry about modifications during | 100 // these dynamically we don't need to worry about modifications during |
94 // iteration. If we add that capability, this should be replaced with an | 101 // iteration. If we add that capability, this should be replaced with an |
95 // ObserverList. | 102 // ObserverList. |
96 ScopedVector<InstanceMessageFilter> instance_message_filters_; | 103 ScopedVector<InstanceMessageFilter> instance_message_filters_; |
97 | 104 |
98 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; | 105 typedef std::map<PP_Resource, linked_ptr<ResourceHost> > ResourceMap; |
99 ResourceMap resources_; | 106 ResourceMap resources_; |
100 | 107 |
| 108 // This set is used to identify Graphics2D resource. |
| 109 typedef std::set<PP_Resource> Graphics2DSet; |
| 110 Graphics2DSet graphics_2d_set_; |
| 111 |
101 DISALLOW_COPY_AND_ASSIGN(PpapiHost); | 112 DISALLOW_COPY_AND_ASSIGN(PpapiHost); |
102 }; | 113 }; |
103 | 114 |
104 } // namespace host | 115 } // namespace host |
105 } // namespace ppapi | 116 } // namespace ppapi |
106 | 117 |
107 #endif // PPAPI_HOST_PPAPIE_HOST_H_ | 118 #endif // PPAPI_HOST_PPAPIE_HOST_H_ |
OLD | NEW |