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

Side by Side 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 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/platform/chromium/plugins/resources/script-container.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2009 Google, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 if (object->InternalFieldCount() == npObjectInternalFieldCount) { 136 if (object->InternalFieldCount() == npObjectInternalFieldCount) {
137 WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetPoi nterFromInternalField(v8DOMWrapperTypeIndex)); 137 WrapperTypeInfo* typeInfo = static_cast<WrapperTypeInfo*>(object->GetPoi nterFromInternalField(v8DOMWrapperTypeIndex));
138 if (typeInfo == npObjectTypeInfo()) { 138 if (typeInfo == npObjectTypeInfo()) {
139 139
140 NPObject* returnValue = v8ObjectToNPObject(object); 140 NPObject* returnValue = v8ObjectToNPObject(object);
141 _NPN_RetainObject(returnValue); 141 _NPN_RetainObject(returnValue);
142 return returnValue; 142 return returnValue;
143 } 143 }
144 } 144 }
145 145
146 int v8ObjectHash = object->GetIdentityHash(); 146 V8NPObjectVector* objectVector = 0;
147 ASSERT(v8ObjectHash); 147 if (V8PerContextData* perContextData = V8PerContextData::from(object->Creati onContext())) {
148 V8NPObjectMap* v8NPObjectMap = V8PerContextData::from(object->CreationContex t())->v8NPObjectMap(); 148 int v8ObjectHash = object->GetIdentityHash();
149 V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash); 149 ASSERT(v8ObjectHash);
150 if (iter != v8NPObjectMap->end()) { 150 V8NPObjectMap* v8NPObjectMap = perContextData->v8NPObjectMap();
151 V8NPObjectVector& objects = iter->value; 151 V8NPObjectMap::iterator iter = v8NPObjectMap->find(v8ObjectHash);
152 for (size_t index = 0; index < objects.size(); ++index) { 152 if (iter != v8NPObjectMap->end()) {
153 V8NPObject* v8npObject = objects.at(index); 153 V8NPObjectVector& objects = iter->value;
154 if (v8npObject->rootObject == root) { 154 for (size_t index = 0; index < objects.size(); ++index) {
155 ASSERT(v8npObject->v8Object == object); 155 V8NPObject* v8npObject = objects.at(index);
156 _NPN_RetainObject(&v8npObject->object); 156 if (v8npObject->rootObject == root) {
157 return reinterpret_cast<NPObject*>(v8npObject); 157 ASSERT(v8npObject->v8Object == object);
158 _NPN_RetainObject(&v8npObject->object);
159 return reinterpret_cast<NPObject*>(v8npObject);
160 }
158 } 161 }
162 } else {
163 iter = v8NPObjectMap->set(v8ObjectHash, V8NPObjectVector()).iterator ;
164 objectVector = &iter->value;
159 } 165 }
160 } else {
161 iter = v8NPObjectMap->set(v8ObjectHash, V8NPObjectVector()).iterator;
162 } 166 }
163
164 V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp , &V8NPObjectClass)); 167 V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp , &V8NPObjectClass));
165 v8npObject->v8Object = v8::Persistent<v8::Object>::New(object); 168 v8npObject->v8Object = v8::Persistent<v8::Object>::New(object);
166 v8npObject->rootObject = root; 169 v8npObject->rootObject = root;
167 170
168 iter->value.append(v8npObject); 171 if (objectVector)
172 objectVector->append(v8npObject);
169 173
170 return reinterpret_cast<NPObject*>(v8npObject); 174 return reinterpret_cast<NPObject*>(v8npObject);
171 } 175 }
172 176
173 } // namespace WebCore 177 } // namespace WebCore
174 178
175 bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPV ariant* arguments, uint32_t argumentCount, NPVariant* result) 179 bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPV ariant* arguments, uint32_t argumentCount, NPVariant* result)
176 { 180 {
177 if (!npObject) 181 if (!npObject)
178 return false; 182 return false;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 582
579 convertV8ObjectToNPVariant(resultObject, npObject, result); 583 convertV8ObjectToNPVariant(resultObject, npObject, result);
580 return true; 584 return true;
581 } 585 }
582 586
583 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class-> construct) 587 if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class-> construct)
584 return npObject->_class->construct(npObject, arguments, argumentCount, r esult); 588 return npObject->_class->construct(npObject, arguments, argumentCount, r esult);
585 589
586 return false; 590 return false;
587 } 591 }
OLDNEW
« 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