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

Side by Side Diff: Source/core/fileapi/FileReader.cpp

Issue 474353004: FileReader: switch to using TypeChecking=Interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 terminate(); 248 terminate();
249 } 249 }
250 250
251 bool FileReader::hasPendingActivity() const 251 bool FileReader::hasPendingActivity() const
252 { 252 {
253 return m_state == LOADING; 253 return m_state == LOADING;
254 } 254 }
255 255
256 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionState& exceptionState) 256 void FileReader::readAsArrayBuffer(Blob* blob, ExceptionState& exceptionState)
257 { 257 {
258 if (!blob) { 258 ASSERT(blob);
259 exceptionState.throwTypeError("The argument is not a Blob.");
260 return;
261 }
262
263 WTF_LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", utf8BlobUUI D(blob).data(), utf8FilePath(blob).data()); 259 WTF_LOG(FileAPI, "FileReader: reading as array buffer: %s %s\n", utf8BlobUUI D(blob).data(), utf8FilePath(blob).data());
264 260
265 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, exceptionState); 261 readInternal(blob, FileReaderLoader::ReadAsArrayBuffer, exceptionState);
266 } 262 }
267 263
268 void FileReader::readAsBinaryString(Blob* blob, ExceptionState& exceptionState) 264 void FileReader::readAsBinaryString(Blob* blob, ExceptionState& exceptionState)
269 { 265 {
270 if (!blob) { 266 ASSERT(blob);
271 exceptionState.throwTypeError("The argument is not a Blob.");
272 return;
273 }
274
275 WTF_LOG(FileAPI, "FileReader: reading as binary: %s %s\n", utf8BlobUUID(blob ).data(), utf8FilePath(blob).data()); 267 WTF_LOG(FileAPI, "FileReader: reading as binary: %s %s\n", utf8BlobUUID(blob ).data(), utf8FilePath(blob).data());
276 268
277 readInternal(blob, FileReaderLoader::ReadAsBinaryString, exceptionState); 269 readInternal(blob, FileReaderLoader::ReadAsBinaryString, exceptionState);
278 } 270 }
279 271
280 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionState& exceptionState) 272 void FileReader::readAsText(Blob* blob, const String& encoding, ExceptionState& exceptionState)
281 { 273 {
282 if (!blob) { 274 ASSERT(blob);
283 exceptionState.throwTypeError("The argument is not a Blob.");
284 return;
285 }
286
287 WTF_LOG(FileAPI, "FileReader: reading as text: %s %s\n", utf8BlobUUID(blob). data(), utf8FilePath(blob).data()); 275 WTF_LOG(FileAPI, "FileReader: reading as text: %s %s\n", utf8BlobUUID(blob). data(), utf8FilePath(blob).data());
288 276
289 m_encoding = encoding; 277 m_encoding = encoding;
290 readInternal(blob, FileReaderLoader::ReadAsText, exceptionState); 278 readInternal(blob, FileReaderLoader::ReadAsText, exceptionState);
291 } 279 }
292 280
293 void FileReader::readAsText(Blob* blob, ExceptionState& exceptionState) 281 void FileReader::readAsText(Blob* blob, ExceptionState& exceptionState)
294 { 282 {
295 readAsText(blob, String(), exceptionState); 283 readAsText(blob, String(), exceptionState);
296 } 284 }
297 285
298 void FileReader::readAsDataURL(Blob* blob, ExceptionState& exceptionState) 286 void FileReader::readAsDataURL(Blob* blob, ExceptionState& exceptionState)
299 { 287 {
300 if (!blob) { 288 ASSERT(blob);
301 exceptionState.throwTypeError("The argument is not a Blob.");
302 return;
303 }
304
305 WTF_LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(bl ob).data(), utf8FilePath(blob).data()); 289 WTF_LOG(FileAPI, "FileReader: reading as data URL: %s %s\n", utf8BlobUUID(bl ob).data(), utf8FilePath(blob).data());
306 290
307 readInternal(blob, FileReaderLoader::ReadAsDataURL, exceptionState); 291 readInternal(blob, FileReaderLoader::ReadAsDataURL, exceptionState);
308 } 292 }
309 293
310 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep tionState& exceptionState) 294 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep tionState& exceptionState)
311 { 295 {
312 // If multiple concurrent read methods are called on the same FileReader, In validStateError should be thrown when the state is LOADING. 296 // If multiple concurrent read methods are called on the same FileReader, In validStateError should be thrown when the state is LOADING.
313 if (m_state == LOADING) { 297 if (m_state == LOADING) {
314 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs."); 298 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs.");
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return m_loader->stringResult(); 478 return m_loader->stringResult();
495 } 479 }
496 480
497 void FileReader::trace(Visitor* visitor) 481 void FileReader::trace(Visitor* visitor)
498 { 482 {
499 visitor->trace(m_error); 483 visitor->trace(m_error);
500 EventTargetWithInlineData::trace(visitor); 484 EventTargetWithInlineData::trace(visitor);
501 } 485 }
502 486
503 } // namespace blink 487 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/files/file-reader-methods-illegal-arguments-expected.txt ('k') | Source/core/fileapi/FileReader.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698