Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: content/child/np_channel_base.cc

Issue 17208003: Track NPObject ownership by the originating plugins' NPP identifier. [4/6] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECKs on proxy and stub maps. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/np_channel_base.h ('k') | content/child/npobject_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/np_channel_base.cc
diff --git a/content/child/np_channel_base.cc b/content/child/np_channel_base.cc
index 81b848b0866a638681a66d657898b8422b653991..23805e756df37b87481b0acc3570c39818ad1651 100644
--- a/content/child/np_channel_base.cc
+++ b/content/child/np_channel_base.cc
@@ -72,12 +72,19 @@ NPChannelBase::NPChannelBase()
non_npobject_count_(0),
peer_pid_(0),
in_remove_route_(false),
+ default_owner_(NULL),
channel_valid_(false),
in_unblock_dispatch_(0),
send_unblocking_only_during_unblock_dispatch_(false) {
}
NPChannelBase::~NPChannelBase() {
+ // TODO(wez): Establish why these would ever be non-empty at teardown.
+ //DCHECK(npobject_listeners_.empty());
+ //DCHECK(proxy_map_.empty());
+ //DCHECK(stub_map_.empty());
+ DCHECK(owner_to_route_.empty());
+ DCHECK(route_to_owner_.empty());
}
NPChannelBase* NPChannelBase::GetCurrentChannel() {
@@ -271,21 +278,15 @@ void NPChannelBase::OnChannelError() {
}
}
-NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) {
- ProxyMap::iterator iter = proxy_map_.find(route_id);
- return iter != proxy_map_.end() ? iter->second : NULL;
-}
-
-int NPChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) {
- StubMap::iterator iter = stub_map_.find(npobject);
- return iter != stub_map_.end() ? iter->second : MSG_ROUTING_NONE;
-}
-
void NPChannelBase::AddMappingForNPObjectProxy(int route_id,
NPObject* object) {
proxy_map_[route_id] = object;
}
+void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) {
+ proxy_map_.erase(route_id);
+}
+
void NPChannelBase::AddMappingForNPObjectStub(int route_id,
NPObject* object) {
DCHECK(object != NULL);
@@ -298,8 +299,42 @@ void NPChannelBase::RemoveMappingForNPObjectStub(int route_id,
stub_map_.erase(object);
}
-void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) {
- proxy_map_.erase(route_id);
+void NPChannelBase::AddMappingForNPObjectOwner(int route_id,
+ struct _NPP* owner) {
+ DCHECK(owner != NULL);
+ route_to_owner_[route_id] = owner;
+ owner_to_route_[owner] = route_id;
+}
+
+void NPChannelBase::SetDefaultNPObjectOwner(struct _NPP* owner) {
+ DCHECK(owner != NULL);
+ default_owner_ = owner;
+}
+
+void NPChannelBase::RemoveMappingForNPObjectOwner(int route_id) {
+ DCHECK(route_to_owner_.find(route_id) != route_to_owner_.end());
+ owner_to_route_.erase(route_to_owner_[route_id]);
+ route_to_owner_.erase(route_id);
+}
+
+NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) {
+ ProxyMap::iterator iter = proxy_map_.find(route_id);
+ return iter != proxy_map_.end() ? iter->second : NULL;
+}
+
+int NPChannelBase::GetExistingRouteForNPObjectStub(NPObject* npobject) {
+ StubMap::iterator iter = stub_map_.find(npobject);
+ return iter != stub_map_.end() ? iter->second : MSG_ROUTING_NONE;
+}
+
+NPP NPChannelBase::GetExistingNPObjectOwner(int route_id) {
+ RouteToOwnerMap::iterator iter = route_to_owner_.find(route_id);
+ return iter != route_to_owner_.end() ? iter->second : default_owner_;
+}
+
+int NPChannelBase::GetExistingRouteForNPObjectOwner(NPP owner) {
+ OwnerToRouteMap::iterator iter = owner_to_route_.find(owner);
+ return iter != owner_to_route_.end() ? iter->second : MSG_ROUTING_NONE;
}
} // namespace content
« no previous file with comments | « content/child/np_channel_base.h ('k') | content/child/npobject_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698