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

Side by Side Diff: Source/WebCore/bindings/dart/custom/DartDOMWindowCustom.cpp

Issue 10660025: Cleanup dart to string conversions. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: . Created 8 years, 6 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 void locationSetter(Dart_NativeArguments args) 93 void locationSetter(Dart_NativeArguments args)
94 { 94 {
95 DartApiScope dartApiScope; 95 DartApiScope dartApiScope;
96 Dart_Handle exception = 0; 96 Dart_Handle exception = 0;
97 { 97 {
98 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args); 98 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args);
99 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate()); 99 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate());
100 100
101 const ParameterAdapter<String> location(Dart_GetNativeArgument(args, 1)) ; 101 DartStringAdapter location = DartUtilities::dartToString(Dart_GetNativeA rgument(args, 1), exception);
102 if (!location.conversionSuccessful()) { 102 if (exception)
103 exception = location.exception();
104 goto fail; 103 goto fail;
105 }
106 104
107 receiver->setLocation(location, receiver, receiver); 105 receiver->setLocation(location, receiver, receiver);
108 return; 106 return;
109 } 107 }
110 108
111 fail: 109 fail:
112 Dart_ThrowException(exception); 110 Dart_ThrowException(exception);
113 ASSERT_NOT_REACHED(); 111 ASSERT_NOT_REACHED();
114 } 112 }
115 113
116 void openCallback(Dart_NativeArguments args) 114 void openCallback(Dart_NativeArguments args)
117 { 115 {
118 DartApiScope dartApiScope; 116 DartApiScope dartApiScope;
119 Dart_Handle exception = 0; 117 Dart_Handle exception = 0;
120 { 118 {
121 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args); 119 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args);
122 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate()); 120 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate());
123 121
124 const ParameterAdapter<String> url(Dart_GetNativeArgument(args, 1)); 122 DartStringAdapter url = DartUtilities::dartToString(Dart_GetNativeArgume nt(args, 1), exception);
125 if (!url.conversionSuccessful()) { 123 if (exception)
126 exception = url.exception();
127 goto fail; 124 goto fail;
128 } 125 DartStringAdapter name = DartUtilities::dartToString(Dart_GetNativeArgum ent(args, 2), exception);
129 const ParameterAdapter<String> name(Dart_GetNativeArgument(args, 2)); 126 if (exception)
130 if (!name.conversionSuccessful()) {
131 exception = name.exception();
132 goto fail; 127 goto fail;
133 } 128 DartStringAdapter options = DartUtilities::dartToStringWithNullCheck(Dar t_GetNativeArgument(args, 3), exception);
134 const ParameterAdapter<String> options(Dart_GetNativeArgument(args, 3), DartUtilities::ConvertNullToDefaultValue); 129 if (exception)
135 if (!options.conversionSuccessful()) {
136 exception = options.exception();
137 goto fail; 130 goto fail;
138 }
139 131
140 RefPtr<DOMWindow> openedWindow = receiver->open(url, name, options, rece iver, receiver); 132 RefPtr<DOMWindow> openedWindow = receiver->open(url, name, options, rece iver, receiver);
141 if (openedWindow) 133 if (openedWindow)
142 DartDOMWrapper::returnValue<DartDOMWindow>(args, openedWindow.releas e()); 134 DartDOMWrapper::returnValue<DartDOMWindow>(args, openedWindow.releas e());
143 return; 135 return;
144 } 136 }
145 137
146 fail: 138 fail:
147 Dart_ThrowException(exception); 139 Dart_ThrowException(exception);
148 ASSERT_NOT_REACHED(); 140 ASSERT_NOT_REACHED();
(...skipping 25 matching lines...) Expand all
174 } 166 }
175 167
176 RefPtr<SerializedScriptValue> message = DartUtilities::toSerializedScrip tValue( 168 RefPtr<SerializedScriptValue> message = DartUtilities::toSerializedScrip tValue(
177 Dart_GetNativeArgument(args, 1), 169 Dart_GetNativeArgument(args, 1),
178 &portArray, 170 &portArray,
179 extendedTransfer ? &bufferArray : 0, 171 extendedTransfer ? &bufferArray : 0,
180 exception); 172 exception);
181 if (exception) 173 if (exception)
182 goto fail; 174 goto fail;
183 175
184 const ParameterAdapter<String> targetOrigin(Dart_GetNativeArgument(args, 2)); 176 DartStringAdapter targetOrigin = DartUtilities::dartToString(Dart_GetNat iveArgument(args, 2), exception);
185 if (!targetOrigin.conversionSuccessful()) { 177 if (exception)
186 exception = targetOrigin.exception();
187 goto fail; 178 goto fail;
188 }
189 179
190 ExceptionCode ec = 0; 180 ExceptionCode ec = 0;
191 receiver->postMessage(message.release(), &portArray, targetOrigin, sourc e, ec); 181 receiver->postMessage(message.release(), &portArray, targetOrigin, sourc e, ec);
192 if (UNLIKELY(ec)) { 182 if (UNLIKELY(ec)) {
193 exception = DartDOMWrapper::exceptionCodeToDartException(ec); 183 exception = DartDOMWrapper::exceptionCodeToDartException(ec);
194 goto fail; 184 goto fail;
195 } 185 }
196 186
197 return; 187 return;
198 } 188 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 245 }
256 246
257 void addEventListenerCallback(Dart_NativeArguments args) 247 void addEventListenerCallback(Dart_NativeArguments args)
258 { 248 {
259 DartApiScope dartApiScope; 249 DartApiScope dartApiScope;
260 Dart_Handle exception = 0; 250 Dart_Handle exception = 0;
261 { 251 {
262 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args); 252 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args);
263 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate()); 253 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate());
264 254
265 const ParameterAdapter<String> type(Dart_GetNativeArgument(args, 1)); 255 DartStringAdapter type = DartUtilities::dartToString(Dart_GetNativeArgum ent(args, 1), exception);
266 if (!type.conversionSuccessful()) { 256 if (exception)
267 exception = type.exception();
268 goto fail; 257 goto fail;
269 }
270 EventListener* listener = DartEventListener::toNative(Dart_GetNativeArgu ment(args, 2), exception); 258 EventListener* listener = DartEventListener::toNative(Dart_GetNativeArgu ment(args, 2), exception);
271 if (exception) 259 if (exception)
272 goto fail; 260 goto fail;
273 bool useCapture = DartUtilities::dartToBool(Dart_GetNativeArgument(args, 3), exception); 261 bool useCapture = DartUtilities::dartToBool(Dart_GetNativeArgument(args, 3), exception);
274 if (exception) 262 if (exception)
275 goto fail; 263 goto fail;
276 264
277 receiver->addEventListener(type, listener, useCapture); 265 receiver->addEventListener(type, listener, useCapture);
278 return; 266 return;
279 } 267 }
280 268
281 fail: 269 fail:
282 Dart_ThrowException(exception); 270 Dart_ThrowException(exception);
283 ASSERT_NOT_REACHED(); 271 ASSERT_NOT_REACHED();
284 } 272 }
285 273
286 void removeEventListenerCallback(Dart_NativeArguments args) 274 void removeEventListenerCallback(Dart_NativeArguments args)
287 { 275 {
288 DartApiScope dartApiScope; 276 DartApiScope dartApiScope;
289 Dart_Handle exception = 0; 277 Dart_Handle exception = 0;
290 { 278 {
291 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args); 279 DOMWindow* receiver = DartDOMWrapper::receiver<DOMWindow>(args);
292 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate()); 280 ASSERT(receiver == DartUtilities::domWindowForCurrentIsolate());
293 281
294 const ParameterAdapter<String> type(Dart_GetNativeArgument(args, 1)); 282 DartStringAdapter type = DartUtilities::dartToString(Dart_GetNativeArgum ent(args, 1), exception);
295 if (!type.conversionSuccessful()) { 283 if (exception)
296 exception = type.exception();
297 goto fail; 284 goto fail;
298 }
299 EventListener* listener = DartEventListener::toNative(Dart_GetNativeArgu ment(args, 2), exception); 285 EventListener* listener = DartEventListener::toNative(Dart_GetNativeArgu ment(args, 2), exception);
300 if (exception) 286 if (exception)
301 goto fail; 287 goto fail;
302 bool useCapture = DartUtilities::dartToBool(Dart_GetNativeArgument(args, 3), exception); 288 bool useCapture = DartUtilities::dartToBool(Dart_GetNativeArgument(args, 3), exception);
303 if (exception) 289 if (exception)
304 goto fail; 290 goto fail;
305 291
306 receiver->removeEventListener(type, listener, useCapture); 292 receiver->removeEventListener(type, listener, useCapture);
307 return; 293 return;
308 } 294 }
(...skipping 10 matching lines...) Expand all
319 } 305 }
320 306
321 } 307 }
322 308
323 Dart_Handle DartDOMWindow::toDart(DOMWindow* window) 309 Dart_Handle DartDOMWindow::toDart(DOMWindow* window)
324 { 310 {
325 return DartDOMWrapper::toDartWithClassName<DartDOMWindow>(window, "_DOMWindo wCrossFrameImpl"); 311 return DartDOMWrapper::toDartWithClassName<DartDOMWindow>(window, "_DOMWindo wCrossFrameImpl");
326 } 312 }
327 313
328 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698