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

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: Update to match changes in v8-util.h. Created 6 years, 9 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 DOMWrapperMap<NPObject>::PersistentValueMapTraits::Impl* impl,
411 NPObject* npObject)
409 { 412 {
410 NPObject* npObject = static_cast<NPObject*>(toNative(data.GetValue()));
411
412 ASSERT(npObject); 413 ASSERT(npObject);
413 ASSERT(staticNPObjectMap().containsKeyAndValue(npObject, data.GetValue())); 414 ASSERT(staticNPObjectMap().Contains(npObject));
414 415 ASSERT(staticNPObjectMap().Get(npObject) == value);
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 416
419 if (_NPN_IsAlive(npObject)) 417 if (_NPN_IsAlive(npObject))
420 _NPN_ReleaseObject(npObject); 418 _NPN_ReleaseObject(npObject);
421 } 419 }
422 420
421
dcarney 2014/03/18 15:20:25 blink doesn't have the 2 space rule
vogelheim 2014/03/20 18:19:05 Done.
423 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate) 422 v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root , v8::Isolate* isolate)
424 { 423 {
425 static v8::Eternal<v8::FunctionTemplate> npObjectDesc; 424 static v8::Eternal<v8::FunctionTemplate> npObjectDesc;
426 425
427 ASSERT(isolate->InContext()); 426 ASSERT(isolate->InContext());
428 427
429 // If this is a v8 object, just return it. 428 // If this is a v8 object, just return it.
430 V8NPObject* v8NPObject = npObjectToV8NPObject(object); 429 V8NPObject* v8NPObject = npObjectToV8NPObject(object);
431 if (v8NPObject) 430 if (v8NPObject)
432 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object); 431 return v8::Local<v8::Object>::New(isolate, v8NPObject->v8Object);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 v8::HandleScope scope(isolate); 474 v8::HandleScope scope(isolate);
476 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e); 475 v8::Handle<v8::Object> wrapper = staticNPObjectMap().newLocal(object, isolat e);
477 if (!wrapper.IsEmpty()) { 476 if (!wrapper.IsEmpty()) {
478 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo()); 477 V8DOMWrapper::clearNativeInfo(wrapper, npObjectTypeInfo());
479 staticNPObjectMap().removeAndDispose(object); 478 staticNPObjectMap().removeAndDispose(object);
480 _NPN_ReleaseObject(object); 479 _NPN_ReleaseObject(object);
481 } 480 }
482 } 481 }
483 482
484 } // namespace WebCore 483 } // 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