Chromium Code Reviews| Index: Source/bindings/dart/DartDOMWrapper.cpp |
| diff --git a/Source/bindings/dart/DartDOMWrapper.cpp b/Source/bindings/dart/DartDOMWrapper.cpp |
| index e26835cefbe34bf556f794747cc6993e17885756..dcaa874fa9f4fab1672441f8cee777647e1ff4d4 100644 |
| --- a/Source/bindings/dart/DartDOMWrapper.cpp |
| +++ b/Source/bindings/dart/DartDOMWrapper.cpp |
| @@ -57,23 +57,32 @@ Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className, const char |
| return instance; |
| } |
| -bool DartDOMWrapper::instanceOf(const char* className, const char* libraryName, Dart_Handle wrapper) |
| +Dart_Handle DartDOMWrapper::dartClass(const char* className, const char* libraryName, intptr_t index) |
| { |
| - // FIXME(rmacnak): Cache classes in the corresponding bindings class. Requires persistent handles. |
| - Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); |
| - ASSERT(!Dart_IsError(library)); |
| + Vector<Dart_PersistentHandle> *map = DartDOMData::current()->classHandleCache(); |
| - Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0); |
| - ASSERT(!Dart_IsError(type)); |
| - if (Dart_IsError(type)) |
| - return false; |
| - |
| - bool isInstanceOf = false; |
| - Dart_Handle result = Dart_ObjectIsType(wrapper, type, &isInstanceOf); |
| - ASSERT(!Dart_IsError(result)); |
| - if (Dart_IsError(result)) |
| - return false; |
| - return isInstanceOf; |
| + Dart_Handle type; |
| + Dart_PersistentHandle persistentType; |
| + |
| + while (map->size() <= index) { |
| + map->append(reinterpret_cast<Dart_PersistentHandle>(0)); |
|
siva
2013/09/10 00:18:50
Might be more efficient to do:
if (map->size() <=
rmacnak
2013/09/10 20:09:51
expandCapacity is private, but grow works
|
| + } |
| + |
| + if (map->at(index)) { |
| + persistentType = map->at(index); |
| + type = Dart_HandleFromPersistent(persistentType); |
| + } else { |
| + Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); |
| + ASSERT(!Dart_IsError(library)); |
| + |
| + type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0); |
| + ASSERT(!Dart_IsError(type)); |
| + |
| + persistentType = Dart_NewPersistentHandle(type); |
| + map->insert(index, persistentType); |
|
siva
2013/09/10 00:18:50
insert here in the implementation of Vector seems
rmacnak
2013/09/10 20:09:51
map->data()[index] = persistentType seems to do th
|
| + } |
| + |
| + return type; |
| } |
| Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exceptionCode) |