Index: tests/fake_browser_ppapi/fake_host.cc |
diff --git a/tests/fake_browser_ppapi/fake_host.cc b/tests/fake_browser_ppapi/fake_host.cc |
index cfdd63ef21a5f83c89271d6f933f0b12b6dcf5fd..a77f3e95de55683874c492172e8dfc2f360343db 100644 |
--- a/tests/fake_browser_ppapi/fake_host.cc |
+++ b/tests/fake_browser_ppapi/fake_host.cc |
@@ -62,10 +62,16 @@ Host::~Host() { |
int rc = dlclose(dl_handle_); |
CHECK(rc == 0); |
- ResourceMap::iterator it; |
- while ((it = resource_map_.begin()) != resource_map_.end()) { |
- delete(it->second); |
- resource_map_.erase(it); |
+ ResourceMap::iterator ri; |
+ while ((ri = resource_map_.begin()) != resource_map_.end()) { |
+ delete(ri->second); |
+ resource_map_.erase(ri); |
+ } |
+ |
+ InstanceMap::iterator ii; |
+ while ((ii = instance_map_.begin()) != instance_map_.end()) { |
+ delete(ii->second); |
+ instance_map_.erase(ii); |
} |
} |
@@ -85,6 +91,7 @@ const void* Host::GetInterface(const char* interface_name) { |
PP_Resource Host::TrackResource(Resource* resource) { |
PP_Resource resource_id = ++last_resource_id_; |
resource_map_[resource_id] = resource; |
+ resource->set_resource_id(resource_id); |
return resource_id; |
} |
@@ -95,4 +102,18 @@ Resource* Host::GetResource(PP_Resource resource_id) { |
return iter->second; |
} |
+PP_Instance Host::TrackInstance(Instance* instance) { |
+ PP_Instance instance_id = ++last_instance_id_; |
+ instance_map_[instance_id] = instance; |
+ instance->set_instance_id(instance_id); |
+ return instance_id; |
+} |
+ |
+Instance* Host::GetInstance(PP_Instance instance_id) { |
+ InstanceMap::iterator iter = instance_map_.find(instance_id); |
+ if (iter == instance_map_.end()) |
+ return Instance::Invalid(); |
+ return iter->second; |
+} |
+ |
} // namespace fake_browser_ppapi |