| 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 InspectorInstrumentation::asyncTaskScheduled(context, "FileReader", reader, | 96 probe::asyncTaskScheduled(context, "FileReader", reader, true); |
| 97 true); | |
| 98 controller->pushReader(reader); | 97 controller->pushReader(reader); |
| 99 } | 98 } |
| 100 | 99 |
| 101 static FinishReaderType removeReader(ExecutionContext* context, | 100 static FinishReaderType removeReader(ExecutionContext* context, |
| 102 FileReader* reader) { | 101 FileReader* reader) { |
| 103 ThrottlingController* controller = from(context); | 102 ThrottlingController* controller = from(context); |
| 104 if (!controller) | 103 if (!controller) |
| 105 return DoNotRunPendingReaders; | 104 return DoNotRunPendingReaders; |
| 106 | 105 |
| 107 return controller->removeReader(reader); | 106 return controller->removeReader(reader); |
| 108 } | 107 } |
| 109 | 108 |
| 110 static void finishReader(ExecutionContext* context, | 109 static void finishReader(ExecutionContext* context, |
| 111 FileReader* reader, | 110 FileReader* reader, |
| 112 FinishReaderType nextStep) { | 111 FinishReaderType nextStep) { |
| 113 ThrottlingController* controller = from(context); | 112 ThrottlingController* controller = from(context); |
| 114 if (!controller) | 113 if (!controller) |
| 115 return; | 114 return; |
| 116 | 115 |
| 117 controller->finishReader(reader, nextStep); | 116 controller->finishReader(reader, nextStep); |
| 118 InspectorInstrumentation::asyncTaskCanceled(context, reader); | 117 probe::asyncTaskCanceled(context, reader); |
| 119 } | 118 } |
| 120 | 119 |
| 121 DEFINE_INLINE_TRACE() { | 120 DEFINE_INLINE_TRACE() { |
| 122 visitor->trace(m_pendingReaders); | 121 visitor->trace(m_pendingReaders); |
| 123 visitor->trace(m_runningReaders); | 122 visitor->trace(m_runningReaders); |
| 124 Supplement<ExecutionContext>::trace(visitor); | 123 Supplement<ExecutionContext>::trace(visitor); |
| 125 } | 124 } |
| 126 | 125 |
| 127 private: | 126 private: |
| 128 explicit ThrottlingController(ExecutionContext& context) | 127 explicit ThrottlingController(ExecutionContext& context) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 ThrottlingController::removeReader(getExecutionContext(), this); | 445 ThrottlingController::removeReader(getExecutionContext(), this); |
| 447 | 446 |
| 448 fireEvent(EventTypeNames::error); | 447 fireEvent(EventTypeNames::error); |
| 449 fireEvent(EventTypeNames::loadend); | 448 fireEvent(EventTypeNames::loadend); |
| 450 | 449 |
| 451 // 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. |
| 452 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); | 451 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); |
| 453 } | 452 } |
| 454 | 453 |
| 455 void FileReader::fireEvent(const AtomicString& type) { | 454 void FileReader::fireEvent(const AtomicString& type) { |
| 456 InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), this); | 455 probe::AsyncTask asyncTask(getExecutionContext(), this); |
| 457 if (!m_loader) { | 456 if (!m_loader) { |
| 458 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); | 457 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); |
| 459 return; | 458 return; |
| 460 } | 459 } |
| 461 | 460 |
| 462 if (m_loader->totalBytes() >= 0) | 461 if (m_loader->totalBytes() >= 0) |
| 463 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), | 462 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), |
| 464 m_loader->totalBytes())); | 463 m_loader->totalBytes())); |
| 465 else | 464 else |
| 466 dispatchEvent( | 465 dispatchEvent( |
| 467 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); | 466 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); |
| 468 } | 467 } |
| 469 | 468 |
| 470 DEFINE_TRACE(FileReader) { | 469 DEFINE_TRACE(FileReader) { |
| 471 visitor->trace(m_error); | 470 visitor->trace(m_error); |
| 472 EventTargetWithInlineData::trace(visitor); | 471 EventTargetWithInlineData::trace(visitor); |
| 473 ContextLifecycleObserver::trace(visitor); | 472 ContextLifecycleObserver::trace(visitor); |
| 474 } | 473 } |
| 475 | 474 |
| 476 } // namespace blink | 475 } // namespace blink |
| OLD | NEW |