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

Unified Diff: Source/WebCore/bindings/v8/NPV8Object.cpp

Issue 11411245: Merge 135804 - Check for empty perContextData while creating NP V8 Object. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years, 1 month 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 | « LayoutTests/platform/chromium/plugins/resources/script-container.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/bindings/v8/NPV8Object.cpp
===================================================================
--- Source/WebCore/bindings/v8/NPV8Object.cpp (revision 136063)
+++ Source/WebCore/bindings/v8/NPV8Object.cpp (working copy)
@@ -143,29 +143,33 @@
}
}
- int v8ObjectHash = object->GetIdentityHash();
- ASSERT(v8ObjectHash);
- V8NPObjectMap* v8NPObjectMap = V8PerContextData::from(object->CreationContext())->v8NPObjectMap();
- V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash);
- if (iter != v8NPObjectMap->end()) {
- V8NPObjectVector& objects = iter->value;
- for (size_t index = 0; index < objects.size(); ++index) {
- V8NPObject* v8npObject = objects.at(index);
- if (v8npObject->rootObject == root) {
- ASSERT(v8npObject->v8Object == object);
- _NPN_RetainObject(&v8npObject->object);
- return reinterpret_cast<NPObject*>(v8npObject);
+ V8NPObjectVector* objectVector = 0;
+ if (V8PerContextData* perContextData = V8PerContextData::from(object->CreationContext())) {
+ int v8ObjectHash = object->GetIdentityHash();
+ ASSERT(v8ObjectHash);
+ V8NPObjectMap* v8NPObjectMap = perContextData->v8NPObjectMap();
+ V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash);
+ if (iter != v8NPObjectMap->end()) {
+ V8NPObjectVector& objects = iter->value;
+ for (size_t index = 0; index < objects.size(); ++index) {
+ V8NPObject* v8npObject = objects.at(index);
+ if (v8npObject->rootObject == root) {
+ ASSERT(v8npObject->v8Object == object);
+ _NPN_RetainObject(&v8npObject->object);
+ return reinterpret_cast<NPObject*>(v8npObject);
+ }
}
+ } else {
+ iter = v8NPObjectMap->set(v8ObjectHash, V8NPObjectVector()).iterator;
+ objectVector = &iter->value;
}
- } else {
- iter = v8NPObjectMap->set(v8ObjectHash, V8NPObjectVector()).iterator;
}
-
V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass));
v8npObject->v8Object = v8::Persistent<v8::Object>::New(object);
v8npObject->rootObject = root;
- iter->value.append(v8npObject);
+ if (objectVector)
+ objectVector->append(v8npObject);
return reinterpret_cast<NPObject*>(v8npObject);
}
« no previous file with comments | « LayoutTests/platform/chromium/plugins/resources/script-container.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698