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

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: . 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
« no previous file with comments | « Source/bindings/dart/DartDOMWrapper.h ('k') | Source/bindings/dart/DartNativeUtilities.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartDOMWrapper.cpp
diff --git a/Source/bindings/dart/DartDOMWrapper.cpp b/Source/bindings/dart/DartDOMWrapper.cpp
index e26835cefbe34bf556f794747cc6993e17885756..3f51bc5a3e351fbc1f613783666331508f4a63d3 100644
--- a/Source/bindings/dart/DartDOMWrapper.cpp
+++ b/Source/bindings/dart/DartDOMWrapper.cpp
@@ -43,37 +43,29 @@
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));
+ ASSERT(index < NumWebkitClassIds);
- Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0);
- ASSERT(!Dart_IsError(type));
+ ClassTable* table = DartDOMData::current()->classHandleCache();
- Dart_Handle instance = Dart_Allocate(type);
- ASSERT(!Dart_IsError(instance));
+ Dart_Handle type;
+ Dart_PersistentHandle persistentType = (*table)[index];
- return instance;
-}
+ if (persistentType) {
+ type = Dart_HandleFromPersistent(persistentType);
+ } else {
+ Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName);
+ ASSERT(!Dart_IsError(library));
-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));
-
- 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;
+ type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0);
+ ASSERT(!Dart_IsError(type));
+
+ persistentType = Dart_NewPersistentHandle(type);
+ (*table)[index] = persistentType;
+ }
+
+ return type;
}
Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exceptionCode)
« no previous file with comments | « Source/bindings/dart/DartDOMWrapper.h ('k') | Source/bindings/dart/DartNativeUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698