| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return controller; | 86 return controller; |
| 87 } | 87 } |
| 88 | 88 |
| 89 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 89 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
| 90 | 90 |
| 91 static void pushReader(ExecutionContext* context, FileReader* reader) { | 91 static void pushReader(ExecutionContext* context, FileReader* reader) { |
| 92 ThrottlingController* controller = from(context); | 92 ThrottlingController* controller = from(context); |
| 93 if (!controller) | 93 if (!controller) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 probe::asyncTaskScheduled(context, "FileReader", reader, true); | 96 probe::asyncTaskScheduled(context, "FileReader", reader); |
| 97 controller->pushReader(reader); | 97 controller->pushReader(reader); |
| 98 } | 98 } |
| 99 | 99 |
| 100 static FinishReaderType removeReader(ExecutionContext* context, | 100 static FinishReaderType removeReader(ExecutionContext* context, |
| 101 FileReader* reader) { | 101 FileReader* reader) { |
| 102 ThrottlingController* controller = from(context); | 102 ThrottlingController* controller = from(context); |
| 103 if (!controller) | 103 if (!controller) |
| 104 return DoNotRunPendingReaders; | 104 return DoNotRunPendingReaders; |
| 105 | 105 |
| 106 return controller->removeReader(reader); | 106 return controller->removeReader(reader); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 ThrottlingController::removeReader(getExecutionContext(), this); | 445 ThrottlingController::removeReader(getExecutionContext(), this); |
| 446 | 446 |
| 447 fireEvent(EventTypeNames::error); | 447 fireEvent(EventTypeNames::error); |
| 448 fireEvent(EventTypeNames::loadend); | 448 fireEvent(EventTypeNames::loadend); |
| 449 | 449 |
| 450 // All possible events have fired and we're done, no more pending activity. | 450 // All possible events have fired and we're done, no more pending activity. |
| 451 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); | 451 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); |
| 452 } | 452 } |
| 453 | 453 |
| 454 void FileReader::fireEvent(const AtomicString& type) { | 454 void FileReader::fireEvent(const AtomicString& type) { |
| 455 probe::AsyncTask asyncTask(getExecutionContext(), this); | 455 probe::AsyncTask asyncTask(getExecutionContext(), this, "event"); |
| 456 if (!m_loader) { | 456 if (!m_loader) { |
| 457 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); | 457 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); |
| 458 return; | 458 return; |
| 459 } | 459 } |
| 460 | 460 |
| 461 if (m_loader->totalBytes() >= 0) | 461 if (m_loader->totalBytes() >= 0) |
| 462 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), | 462 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), |
| 463 m_loader->totalBytes())); | 463 m_loader->totalBytes())); |
| 464 else | 464 else |
| 465 dispatchEvent( | 465 dispatchEvent( |
| 466 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); | 466 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 DEFINE_TRACE(FileReader) { | 469 DEFINE_TRACE(FileReader) { |
| 470 visitor->trace(m_error); | 470 visitor->trace(m_error); |
| 471 EventTargetWithInlineData::trace(visitor); | 471 EventTargetWithInlineData::trace(visitor); |
| 472 ContextLifecycleObserver::trace(visitor); | 472 ContextLifecycleObserver::trace(visitor); |
| 473 } | 473 } |
| 474 | 474 |
| 475 } // namespace blink | 475 } // namespace blink |
| OLD | NEW |