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

Side by Side Diff: Source/bindings/v8/V8NPObject.cpp

Issue 180363004: Convert DOMWrapperMap to use PersistentValueMap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adapt to changes in v8-util.h Created 6 years, 8 months 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 | « Source/bindings/v8/DOMWrapperMap.h ('k') | Source/bindings/v8/WrapperTypeInfo.h » ('j') | 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) 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
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
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::Isolate* isolate,
409 v8::UniquePersistent<v8::Object> value,
410 NPObject* npObject)
409 { 411 {
410 NPObject* npObject = static_cast<NPObject*>(toNative(data.GetValue()));
411
412 ASSERT(npObject); 412 ASSERT(npObject);
413 ASSERT(staticNPObjectMap().containsKeyAndValue(npObject, data.GetValue()));
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)) 413 if (_NPN_IsAlive(npObject))
420 _NPN_ReleaseObject(npObject); 414 _NPN_ReleaseObject(npObject);
421 } 415 }
422 416
423 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate) 417 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate)
424 { 418 {
425 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; 419 static v8::Eternal<v8::FunctionTemplate> npObjectDesc;
426 420
427 ASSERT(isolate->InContext()); 421 ASSERT(isolate->InContext());
428 422
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 v8::HandleScope scope(isolate); 469 v8::HandleScope scope(isolate);
476 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e); 470 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e);
477 if (!wrapper.IsEmpty()) { 471 if (!wrapper.IsEmpty()) {
478 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); 472 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo());
479 staticNPObjectMap().removeAndDispose(object); 473 staticNPObjectMap().removeAndDispose(object);
480 _NPN_ReleaseObject(object); 474 _NPN_ReleaseObject(object);
481 } 475 }
482 } 476 }
483 477
484 } // namespace WebCore 478 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMWrapperMap.h ('k') | Source/bindings/v8/WrapperTypeInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698