Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "bindings/v8/V8NPObject.h" | 33 #include "bindings/v8/V8NPObject.h" |
| 34 | 34 |
| 35 #include "V8HTMLAppletElement.h" | 35 #include "V8HTMLAppletElement.h" |
| 36 #include "V8HTMLEmbedElement.h" | 36 #include "V8HTMLEmbedElement.h" |
| 37 #include "V8HTMLObjectElement.h" | 37 #include "V8HTMLObjectElement.h" |
| 38 #include "bindings/v8/NPV8Object.h" | 38 #include "bindings/v8/NPV8Object.h" |
| 39 #include "bindings/v8/UnsafePersistent.h" | |
| 40 #include "bindings/v8/V8Binding.h" | 39 #include "bindings/v8/V8Binding.h" |
| 41 #include "bindings/v8/V8NPUtils.h" | 40 #include "bindings/v8/V8NPUtils.h" |
| 42 #include "bindings/v8/V8ObjectConstructor.h" | 41 #include "bindings/v8/V8ObjectConstructor.h" |
| 43 #include "bindings/v8/npruntime_impl.h" | 42 #include "bindings/v8/npruntime_impl.h" |
| 44 #include "bindings/v8/npruntime_priv.h" | 43 #include "bindings/v8/npruntime_priv.h" |
| 45 #include "core/html/HTMLPlugInElement.h" | 44 #include "core/html/HTMLPlugInElement.h" |
| 46 #include "wtf/OwnPtr.h" | 45 #include "wtf/OwnPtr.h" |
| 47 | 46 |
| 48 namespace WebCore { | 47 namespace WebCore { |
| 49 | 48 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 { | 396 { |
| 398 npObjectPropertyEnumerator(info, false); | 397 npObjectPropertyEnumerator(info, false); |
| 399 } | 398 } |
| 400 | 399 |
| 401 static DOMWrapperMap<NPObject>& staticNPObjectMap() | 400 static DOMWrapperMap<NPObject>& staticNPObjectMap() |
| 402 { | 401 { |
| 403 DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (v8::Isolate::GetC urrent())); | 402 DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (v8::Isolate::GetC urrent())); |
| 404 return npObjectMap; | 403 return npObjectMap; |
| 405 } | 404 } |
| 406 | 405 |
| 407 template<> | 406 template <> |
| 408 inline void DOMWrapperMap<NPObject>::setWeakCallback(const v8::WeakCallbackData< v8::Object, DOMWrapperMap<NPObject> >& data) | 407 inline void DOMWrapperMap<NPObject>::PersistentValueMapTraits::Dispose( |
| 408 v8::UniquePersistent<v8::Object> value, | |
| 409 v8::Isolate* isolate, | |
| 410 DOMWrapperMap<NPObject>::PersistentValueMapTraits::Impl* impl, | |
| 411 NPObject* key) | |
| 409 { | 412 { |
| 410 NPObject* npObject = static_cast<NPObject*>(toNative(data.GetValue())); | 413 if (_NPN_IsAlive(key)) |
| 414 _NPN_ReleaseObject(key); | |
| 415 } | |
| 411 | 416 |
| 412 ASSERT(npObject); | |
| 413 ASSERT(staticNPObjectMap().containsKeyAndValue(npObject, data.GetValue())); | |
|
dcarney
2014/03/11 15:16:28
can we keep the assert?
vogelheim
2014/03/11 18:35:31
Done.
vogelheim
2014/03/20 18:19:05
And gone again. :)
This caused test crashes, sinc
| |
| 414 | |
| 415 // Must remove from our map before calling _NPN_ReleaseObject(). _NPN_Releas eObject can | |
| 416 // call forgetV8ObjectForNPObject, which uses the table as well. | |
| 417 staticNPObjectMap().removeAndDispose(npObject); | |
| 418 | |
| 419 if (_NPN_IsAlive(npObject)) | |
| 420 _NPN_ReleaseObject(npObject); | |
| 421 } | |
| 422 | 417 |
| 423 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate) | 418 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate) |
| 424 { | 419 { |
| 425 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; | 420 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; |
| 426 | 421 |
| 427 ASSERT(isolate->InContext()); | 422 ASSERT(isolate->InContext()); |
| 428 | 423 |
| 429 // If this is a v8 object, just return it. | 424 // If this is a v8 object, just return it. |
| 430 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 425 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
| 431 if (v8NPObject) | 426 if (v8NPObject) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 v8::HandleScope scope(isolate); | 470 v8::HandleScope scope(isolate); |
| 476 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e); | 471 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e); |
| 477 if (!wrapper.IsEmpty()) { | 472 if (!wrapper.IsEmpty()) { |
| 478 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); | 473 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); |
| 479 staticNPObjectMap().removeAndDispose(object); | 474 staticNPObjectMap().removeAndDispose(object); |
| 480 _NPN_ReleaseObject(object); | 475 _NPN_ReleaseObject(object); |
| 481 } | 476 } |
| 482 } | 477 } |
| 483 | 478 |
| 484 } // namespace WebCore | 479 } // namespace WebCore |
| OLD | NEW |