| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/fileapi/FileReader.h" | 31 #include "core/fileapi/FileReader.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 34 #include "bindings/core/v8/StringOrArrayBuffer.h" | 34 #include "bindings/core/v8/StringOrArrayBuffer.h" |
| 35 #include "core/dom/DOMArrayBuffer.h" | 35 #include "core/dom/DOMArrayBuffer.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
| 39 #include "core/dom/ExecutionContextTask.h" | |
| 40 #include "core/dom/TaskRunnerHelper.h" | 39 #include "core/dom/TaskRunnerHelper.h" |
| 41 #include "core/events/ProgressEvent.h" | 40 #include "core/events/ProgressEvent.h" |
| 42 #include "core/fileapi/File.h" | 41 #include "core/fileapi/File.h" |
| 43 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
| 44 #include "platform/Supplementable.h" | 43 #include "platform/Supplementable.h" |
| 45 #include "wtf/AutoReset.h" | 44 #include "wtf/AutoReset.h" |
| 46 #include "wtf/CurrentTime.h" | 45 #include "wtf/CurrentTime.h" |
| 47 #include "wtf/Deque.h" | 46 #include "wtf/Deque.h" |
| 48 #include "wtf/HashSet.h" | 47 #include "wtf/HashSet.h" |
| 49 #include "wtf/text/CString.h" | 48 #include "wtf/text/CString.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 fireEvent(EventTypeNames::abort); | 345 fireEvent(EventTypeNames::abort); |
| 347 fireEvent(EventTypeNames::loadend); | 346 fireEvent(EventTypeNames::loadend); |
| 348 | 347 |
| 349 // All possible events have fired and we're done, no more pending activity. | 348 // All possible events have fired and we're done, no more pending activity. |
| 350 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); | 349 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); |
| 351 | 350 |
| 352 // ..but perform the loader cancellation asynchronously as abort() could be | 351 // ..but perform the loader cancellation asynchronously as abort() could be |
| 353 // called from the event handler and we do not want the resource loading code | 352 // called from the event handler and we do not want the resource loading code |
| 354 // to be on the stack when doing so. The persistent reference keeps the | 353 // to be on the stack when doing so. The persistent reference keeps the |
| 355 // reader alive until the task has completed. | 354 // reader alive until the task has completed. |
| 356 getExecutionContext()->postTask( | 355 TaskRunnerHelper::get(TaskType::FileReading, getExecutionContext()) |
| 357 TaskType::FileReading, BLINK_FROM_HERE, | 356 ->postTask(BLINK_FROM_HERE, |
| 358 createSameThreadTask(&FileReader::terminate, wrapPersistent(this))); | 357 WTF::bind(&FileReader::terminate, wrapPersistent(this))); |
| 359 } | 358 } |
| 360 | 359 |
| 361 void FileReader::result(StringOrArrayBuffer& resultAttribute) const { | 360 void FileReader::result(StringOrArrayBuffer& resultAttribute) const { |
| 362 if (m_error || !m_loader) | 361 if (m_error || !m_loader) |
| 363 return; | 362 return; |
| 364 | 363 |
| 365 if (m_readType == FileReaderLoader::ReadAsArrayBuffer) | 364 if (m_readType == FileReaderLoader::ReadAsArrayBuffer) |
| 366 resultAttribute.setArrayBuffer(m_loader->arrayBufferResult()); | 365 resultAttribute.setArrayBuffer(m_loader->arrayBufferResult()); |
| 367 else | 366 else |
| 368 resultAttribute.setString(m_loader->stringResult()); | 367 resultAttribute.setString(m_loader->stringResult()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); | 467 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); |
| 469 } | 468 } |
| 470 | 469 |
| 471 DEFINE_TRACE(FileReader) { | 470 DEFINE_TRACE(FileReader) { |
| 472 visitor->trace(m_error); | 471 visitor->trace(m_error); |
| 473 EventTargetWithInlineData::trace(visitor); | 472 EventTargetWithInlineData::trace(visitor); |
| 474 ContextLifecycleObserver::trace(visitor); | 473 ContextLifecycleObserver::trace(visitor); |
| 475 } | 474 } |
| 476 | 475 |
| 477 } // namespace blink | 476 } // namespace blink |
| OLD | NEW |