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..966af75e91dbc570cbca0f353d995789c149b273 100644 |
| --- a/Source/bindings/dart/DartDOMWrapper.cpp |
| +++ b/Source/bindings/dart/DartDOMWrapper.cpp |
| @@ -43,37 +43,28 @@ |
| namespace WebCore { |
| -Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className, const char* libraryName) |
| +Dart_Handle DartDOMWrapper::dartClass(const char* className, const char* libraryName, intptr_t index) |
| { |
| - Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); |
| - ASSERT(!Dart_IsError(library)); |
| + ClassTable* table = DartDOMData::current()->classHandleCache(); |
| - Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0); |
| - ASSERT(!Dart_IsError(type)); |
| + Dart_Handle type; |
| + Dart_PersistentHandle persistentType; |
|
siva
2013/09/12 18:33:34
ASSERT(index < kNumWebKitClassIds);
|
| - Dart_Handle instance = Dart_Allocate(type); |
| - ASSERT(!Dart_IsError(instance)); |
| + if ((*table)[index]) { |
| + persistentType = (*table)[index]; |
| + type = Dart_HandleFromPersistent(persistentType); |
| + } else { |
| + Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); |
| + ASSERT(!Dart_IsError(library)); |
| - return instance; |
| -} |
| - |
| -bool DartDOMWrapper::instanceOf(const char* className, const char* libraryName, Dart_Handle wrapper) |
| -{ |
| - // FIXME(rmacnak): Cache classes in the corresponding bindings class. Requires persistent handles. |
| - Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); |
| - ASSERT(!Dart_IsError(library)); |
| + type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0); |
| + ASSERT(!Dart_IsError(type)); |
| - Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0); |
| - ASSERT(!Dart_IsError(type)); |
| - if (Dart_IsError(type)) |
| - return false; |
| + persistentType = Dart_NewPersistentHandle(type); |
| + (*table)[index] = persistentType; |
| + } |
|
siva
2013/09/12 18:33:34
Maybe structure this code as:
persistentType = (*
|
| - bool isInstanceOf = false; |
| - Dart_Handle result = Dart_ObjectIsType(wrapper, type, &isInstanceOf); |
| - ASSERT(!Dart_IsError(result)); |
| - if (Dart_IsError(result)) |
| - return false; |
| - return isInstanceOf; |
| + return type; |
| } |
| Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exceptionCode) |