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

Side by Side Diff: Source/bindings/dart/DartUtilities.cpp

Issue 23513085: Incorporating review feedback from https://codereview.chromium.org/24294002/ (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 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 12 matching lines...) Expand all
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "bindings/dart/DartUtilities.h" 31 #include "bindings/dart/DartUtilities.h"
32 32
33 #include "DartBlob.h"
34 #include "DartIDBKeyRange.h"
35 #include "DartImageData.h"
33 #include "DartMessagePort.h" 36 #include "DartMessagePort.h"
34 #include "bindings/dart/DartDOMData.h" 37 #include "bindings/dart/DartDOMData.h"
35 #include "bindings/dart/DartHandleProxy.h" 38 #include "bindings/dart/DartHandleProxy.h"
36 #include "bindings/dart/V8Converter.h" 39 #include "bindings/dart/V8Converter.h"
37 #include "bindings/v8/ScriptController.h" 40 #include "bindings/v8/ScriptController.h"
38 #include "bindings/v8/SerializedScriptValue.h" 41 #include "bindings/v8/SerializedScriptValue.h"
39 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
40 #include "core/html/canvas/DataView.h" 43 #include "core/html/canvas/DataView.h"
41 #include "core/inspector/ScriptArguments.h" 44 #include "core/inspector/ScriptArguments.h"
42 #include "core/inspector/ScriptCallStack.h" 45 #include "core/inspector/ScriptCallStack.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return dartToDate(object, exception); 342 return dartToDate(object, exception);
340 } 343 }
341 344
342 bool DartUtilities::isDateTime(Dart_Handle handle) 345 bool DartUtilities::isDateTime(Dart_Handle handle)
343 { 346 {
344 return objectIsType(handle, "dart:core", "DateTime"); 347 return objectIsType(handle, "dart:core", "DateTime");
345 } 348 }
346 349
347 bool DartUtilities::isBlob(Dart_Handle handle) 350 bool DartUtilities::isBlob(Dart_Handle handle)
348 { 351 {
349 return objectIsType(handle, htmlLibraryName, "Blob"); 352 return objectIsClass(handle, DartDOMWrapper::dartClass<DartBlob>());
350 } 353 }
351 354
352 bool DartUtilities::isImageData(Dart_Handle handle) 355 bool DartUtilities::isImageData(Dart_Handle handle)
353 { 356 {
354 return objectIsType(handle, htmlLibraryName, "ImageData"); 357 return objectIsClass(handle, DartDOMWrapper::dartClass<DartImageData>());
355 } 358 }
356 359
357 bool DartUtilities::isIDBKeyRange(Dart_Handle handle) 360 bool DartUtilities::isIDBKeyRange(Dart_Handle handle)
358 { 361 {
359 return objectIsType(handle, indexedDBLibraryName, "KeyRange"); 362 return objectIsClass(handle, DartDOMWrapper::dartClass<DartIDBKeyRange>());
363 }
364
365 bool DartUtilities::objectIsClass(Dart_Handle handle, Dart_Handle cls)
366 {
367 bool isType = false;
368 Dart_Handle result = Dart_ObjectIsType(handle, cls, &isType);
369 ASSERT(!Dart_IsError(result));
370 if (Dart_IsError(result))
371 return false;
372
373 return isType;
360 } 374 }
361 375
362 bool DartUtilities::objectIsType(Dart_Handle handle, const char* libraryName, co nst char* typeName) 376 bool DartUtilities::objectIsType(Dart_Handle handle, const char* libraryName, co nst char* typeName)
363 { 377 {
364 // FIXME: cache the lookup for library & type name. 378 // FIXME: cache the lookup for library & type name.
365 Dart_Handle library = libraryForCurrentIsolate(libraryName); 379 Dart_Handle library = libraryForCurrentIsolate(libraryName);
366 ASSERT(!Dart_IsError(library)); 380 ASSERT(!Dart_IsError(library));
367 381
368 Dart_Handle cls = Dart_GetClass(library, Dart_NewStringFromCString(typeName) ); 382 Dart_Handle cls = Dart_GetClass(library, Dart_NewStringFromCString(typeName) );
369 ASSERT(!Dart_IsError(cls)); 383 ASSERT(!Dart_IsError(cls));
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 Dart_Handle library = htmlLibraryForCurrentIsolate(); 1062 Dart_Handle library = htmlLibraryForCurrentIsolate();
1049 ASSERT(!Dart_IsError(library)); 1063 ASSERT(!Dart_IsError(library));
1050 1064
1051 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0); 1065 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0);
1052 ASSERT(!Dart_IsError(utilsClass)); 1066 ASSERT(!Dart_IsError(utilsClass));
1053 1067
1054 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args); 1068 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args);
1055 } 1069 }
1056 1070
1057 } 1071 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698