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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011, Google Inc. 1 // Copyright 2011, Google Inc.
2 // All rights reserved. 2 // 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 25 matching lines...) Expand all
36 #include "DartNode.h" 36 #include "DartNode.h"
37 #include "bindings/dart/DartUtilities.h" 37 #include "bindings/dart/DartUtilities.h"
38 #include "core/html/HTMLFormControlElement.h" 38 #include "core/html/HTMLFormControlElement.h"
39 #include "core/html/LabelableElement.h" 39 #include "core/html/LabelableElement.h"
40 40
41 #include <stdio.h> 41 #include <stdio.h>
42 #include <wtf/text/WTFString.h> 42 #include <wtf/text/WTFString.h>
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 Dart_Handle DartDOMWrapper::instantiateWrapper(const char* className, const char * libraryName) 46 Dart_Handle DartDOMWrapper::dartClass(const char* className, const char* library Name, intptr_t index)
47 { 47 {
48 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); 48 ClassTable* table = DartDOMData::current()->classHandleCache();
49 ASSERT(!Dart_IsError(library));
50 49
51 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className ), 0, 0); 50 Dart_Handle type;
52 ASSERT(!Dart_IsError(type)); 51 Dart_PersistentHandle persistentType;
siva 2013/09/12 18:33:34 ASSERT(index < kNumWebKitClassIds);
53 52
54 Dart_Handle instance = Dart_Allocate(type); 53 if ((*table)[index]) {
55 ASSERT(!Dart_IsError(instance)); 54 persistentType = (*table)[index];
55 type = Dart_HandleFromPersistent(persistentType);
56 } else {
57 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryNam e);
58 ASSERT(!Dart_IsError(library));
56 59
57 return instance; 60 type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0) ;
58 } 61 ASSERT(!Dart_IsError(type));
59 62
60 bool DartDOMWrapper::instanceOf(const char* className, const char* libraryName, Dart_Handle wrapper) 63 persistentType = Dart_NewPersistentHandle(type);
61 { 64 (*table)[index] = persistentType;
62 // FIXME(rmacnak): Cache classes in the corresponding bindings class. Requir es persistent handles. 65 }
siva 2013/09/12 18:33:34 Maybe structure this code as: persistentType = (*
63 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName);
64 ASSERT(!Dart_IsError(library));
65 66
66 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className ), 0, 0); 67 return type;
67 ASSERT(!Dart_IsError(type));
68 if (Dart_IsError(type))
69 return false;
70
71 bool isInstanceOf = false;
72 Dart_Handle result = Dart_ObjectIsType(wrapper, type, &isInstanceOf);
73 ASSERT(!Dart_IsError(result));
74 if (Dart_IsError(result))
75 return false;
76 return isInstanceOf;
77 } 68 }
78 69
79 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception Code) 70 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception Code)
80 { 71 {
81 ASSERT(exceptionCode > 0); 72 ASSERT(exceptionCode > 0);
82 73
83 // FIXME: Get a better exception message here. 74 // FIXME: Get a better exception message here.
84 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int ernal Dartium Exception"); 75 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int ernal Dartium Exception");
85 76
86 return DartDOMException::toDart(domException); 77 return DartDOMException::toDart(domException);
87 } 78 }
88 79
89 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc eptionState) 80 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc eptionState)
90 { 81 {
91 return exceptionCodeToDartException(exceptionState.code()); 82 return exceptionCodeToDartException(exceptionState.code());
92 } 83 }
93 84
94 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698