| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_CHILD_NP_CHANNEL_BASE_H_ | 5 #ifndef CONTENT_CHILD_NP_CHANNEL_BASE_H_ |
| 6 #define CONTENT_CHILD_NP_CHANNEL_BASE_H_ | 6 #define CONTENT_CHILD_NP_CHANNEL_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if defined(COMPILER_GCC) | 24 #if defined(COMPILER_GCC) |
| 25 namespace BASE_HASH_NAMESPACE { | 25 namespace BASE_HASH_NAMESPACE { |
| 26 | 26 |
| 27 template<> | 27 template<> |
| 28 struct hash<NPObject*> { | 28 struct hash<NPObject*> { |
| 29 std::size_t operator()(NPObject* const& ptr) const { | 29 std::size_t operator()(NPObject* const& ptr) const { |
| 30 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 30 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
| 31 } | 31 } |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 template<> |
| 35 struct hash<struct _NPP*> { |
| 36 std::size_t operator()(struct _NPP* const& ptr) const { |
| 37 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
| 38 } |
| 39 }; |
| 40 |
| 34 } // namespace __gnu_cxx | 41 } // namespace __gnu_cxx |
| 35 #elif defined(COMPILER_MSVC) | 42 #elif defined(COMPILER_MSVC) |
| 36 namespace stdext { | 43 namespace stdext { |
| 37 | 44 |
| 38 template<> | 45 template<> |
| 39 inline size_t hash_value(NPObject* const& ptr) { | 46 inline size_t hash_value(NPObject* const& ptr) { |
| 40 return hash_value(reinterpret_cast<size_t>(ptr)); | 47 return hash_value(reinterpret_cast<size_t>(ptr)); |
| 41 } | 48 } |
| 42 | 49 |
| 43 } // namespace stdext | 50 } // namespace stdext |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 | 61 |
| 55 // WebPlugin[Delegate] call these on construction and destruction to setup | 62 // WebPlugin[Delegate] call these on construction and destruction to setup |
| 56 // the routing and manage lifetime of this object (they pass NULL for | 63 // the routing and manage lifetime of this object (they pass NULL for |
| 57 // npobject). These are also called by NPObjectProxy and NPObjectStub (which | 64 // npobject). These are also called by NPObjectProxy and NPObjectStub (which |
| 58 // pass themselves for npobject). However the latter don't control the | 65 // pass themselves for npobject). However the latter don't control the |
| 59 // lifetime of this object because we don't want a leak of an NPObject to | 66 // lifetime of this object because we don't want a leak of an NPObject to |
| 60 // keep the channel around longer than necessary. | 67 // keep the channel around longer than necessary. |
| 61 void AddRoute(int route_id, IPC::Listener* listener, NPObjectBase* npobject); | 68 void AddRoute(int route_id, IPC::Listener* listener, NPObjectBase* npobject); |
| 62 void RemoveRoute(int route_id); | 69 void RemoveRoute(int route_id); |
| 63 | 70 |
| 64 | |
| 65 void AddMappingForNPObjectProxy(int route_id, NPObject* object); | 71 void AddMappingForNPObjectProxy(int route_id, NPObject* object); |
| 66 void RemoveMappingForNPObjectProxy(int route_id); | 72 void RemoveMappingForNPObjectProxy(int route_id); |
| 67 | 73 |
| 68 void AddMappingForNPObjectStub(int route_id, NPObject* object); | 74 void AddMappingForNPObjectStub(int route_id, NPObject* object); |
| 69 void RemoveMappingForNPObjectStub(int route_id, NPObject* object); | 75 void RemoveMappingForNPObjectStub(int route_id, NPObject* object); |
| 70 | 76 |
| 77 void AddMappingForNPObjectOwner(int route_id, struct _NPP* owner); |
| 78 void SetDefaultNPObjectOwner(struct _NPP* owner); |
| 79 void RemoveMappingForNPObjectOwner(int route_id); |
| 80 |
| 71 NPObject* GetExistingNPObjectProxy(int route_id); | 81 NPObject* GetExistingNPObjectProxy(int route_id); |
| 72 int GetExistingRouteForNPObjectStub(NPObject* npobject); | 82 int GetExistingRouteForNPObjectStub(NPObject* npobject); |
| 73 | 83 struct _NPP* GetExistingNPObjectOwner(int route_id); |
| 84 int GetExistingRouteForNPObjectOwner(struct _NPP* owner); |
| 74 | 85 |
| 75 // IPC::Sender implementation: | 86 // IPC::Sender implementation: |
| 76 virtual bool Send(IPC::Message* msg) OVERRIDE; | 87 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 77 | 88 |
| 78 base::ProcessId peer_pid() { return channel_->peer_pid(); } | 89 base::ProcessId peer_pid() { return channel_->peer_pid(); } |
| 79 IPC::ChannelHandle channel_handle() const { return channel_handle_; } | 90 IPC::ChannelHandle channel_handle() const { return channel_handle_; } |
| 80 | 91 |
| 81 // Returns the number of open NPObject channels in this process. | 92 // Returns the number of open NPObject channels in this process. |
| 82 static int Count(); | 93 static int Count(); |
| 83 | 94 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // channel is closed we can inform them. | 175 // channel is closed we can inform them. |
| 165 typedef base::hash_map<int, NPObjectBase*> ListenerMap; | 176 typedef base::hash_map<int, NPObjectBase*> ListenerMap; |
| 166 ListenerMap npobject_listeners_; | 177 ListenerMap npobject_listeners_; |
| 167 | 178 |
| 168 typedef base::hash_map<int, NPObject*> ProxyMap; | 179 typedef base::hash_map<int, NPObject*> ProxyMap; |
| 169 ProxyMap proxy_map_; | 180 ProxyMap proxy_map_; |
| 170 | 181 |
| 171 typedef base::hash_map<NPObject*, int> StubMap; | 182 typedef base::hash_map<NPObject*, int> StubMap; |
| 172 StubMap stub_map_; | 183 StubMap stub_map_; |
| 173 | 184 |
| 185 typedef base::hash_map<struct _NPP*, int> OwnerToRouteMap; |
| 186 OwnerToRouteMap owner_to_route_; |
| 187 |
| 188 typedef base::hash_map<int, struct _NPP*> RouteToOwnerMap; |
| 189 RouteToOwnerMap route_to_owner_; |
| 190 |
| 191 // Used on the plugin side to represent any object received that does |
| 192 // not belong to a plugin instance. |
| 193 struct _NPP* default_owner_; |
| 194 |
| 174 // Used to implement message routing functionality to WebPlugin[Delegate] | 195 // Used to implement message routing functionality to WebPlugin[Delegate] |
| 175 // objects | 196 // objects |
| 176 MessageRouter router_; | 197 MessageRouter router_; |
| 177 | 198 |
| 178 // A channel is invalid if it is disconnected as a result of a channel | 199 // A channel is invalid if it is disconnected as a result of a channel |
| 179 // error. This flag is used to indicate the same. | 200 // error. This flag is used to indicate the same. |
| 180 bool channel_valid_; | 201 bool channel_valid_; |
| 181 | 202 |
| 182 // Track whether we're dispatching a message with the unblock flag; works like | 203 // Track whether we're dispatching a message with the unblock flag; works like |
| 183 // a refcount, 0 when we're not. | 204 // a refcount, 0 when we're not. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 194 // have the unblock flag set, since they could be followed by a sync message | 215 // have the unblock flag set, since they could be followed by a sync message |
| 195 // that won't get dispatched until the call to the renderer is complete. | 216 // that won't get dispatched until the call to the renderer is complete. |
| 196 bool send_unblocking_only_during_unblock_dispatch_; | 217 bool send_unblocking_only_during_unblock_dispatch_; |
| 197 | 218 |
| 198 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); | 219 DISALLOW_COPY_AND_ASSIGN(NPChannelBase); |
| 199 }; | 220 }; |
| 200 | 221 |
| 201 } // namespace content | 222 } // namespace content |
| 202 | 223 |
| 203 #endif // CONTENT_CHILD_NP_CHANNEL_BASE_H_ | 224 #endif // CONTENT_CHILD_NP_CHANNEL_BASE_H_ |
| OLD | NEW |