Remove unused cruft, change tracking JS object identity to use an expando
property on JS objects. With this, the Chrome plugin is usable but the
access control still needs to be implemented before we can ship it.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6106 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/npapi/LocalObjectTable.h b/plugins/npapi/LocalObjectTable.h
index 4943ff3..9ff809d 100644
--- a/plugins/npapi/LocalObjectTable.h
+++ b/plugins/npapi/LocalObjectTable.h
@@ -18,7 +18,6 @@
#include <vector>
#include <algorithm>
-#include <map>
#include "Debug.h"
@@ -30,9 +29,7 @@
int nextFree;
std::vector<NPObject*> objects;
- std::map<void*, int> objectIndex;
bool dontFree;
- static NPClass* wrappedObjectClass;
bool isFree(int id) {
// low bit is set for free pointers, object pointers can't be odd
@@ -45,15 +42,6 @@
nextFree = id;
}
- int findIndex(void* ptr) {
- std::map<void*, int>::iterator it = objectIndex.find(ptr);
- if (it == objectIndex.end()) {
- return -1;
- }
- return it->second;
- }
-
- static void* getIdentityFrom(NPObject* obj);
public:
LocalObjectTable() {
nextFree = -1;
@@ -63,18 +51,11 @@
virtual ~LocalObjectTable();
- static void setWrappedObjectClass(NPClass* clazz) {
- wrappedObjectClass = clazz;
- }
-
+ /**
+ * Add a new object, which must not be in the table, and return a new id for it.
+ */
int add(NPObject* obj) {
- void* objId = getIdentityFrom(obj);
- int id = findIndex(objId);
- if (id >= 0) {
- Debug::log(Debug::Spam) << "LocalObjectTable::add(obj=" << obj
- << "): returning old id=" << id << Debug::flush;
- return id;
- }
+ int id;
if (nextFree >= 0) {
id = nextFree;
nextFree = int(reinterpret_cast<long long>(objects[nextFree])) >> 1;
@@ -83,7 +64,6 @@
id = static_cast<int>(objects.size());
objects.push_back(obj);
}
- objectIndex[objId] = id;
Debug::log(Debug::Spam) << "LocalObjectTable::add(obj=" << obj << "): id=" << id
<< Debug::flush;
// keep track that we hold a reference in the table
@@ -91,11 +71,6 @@
return id;
}
- int find(NPObject* obj) {
- void* objId = getIdentityFrom(obj);
- return findIndex(objId);
- }
-
void free(int id) {
Debug::log(Debug::Spam) << "LocalObjectTable::free(id=" << id << ")" << Debug::flush;
if (unsigned(id) >= objects.size()) {