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

Unified Diff: Source/bindings/dart/DartDOMWrapper.cpp

Issue 23895004: Keep a persistent handle for the bindings classes to avoid repeated lookups that involve performing… (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: get custom ids from generated table, allocate table ahead of time Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698