| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 ~ThrottlingController() { } | 90 ~ThrottlingController() { } |
| 91 | 91 |
| 92 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 92 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
| 93 | 93 |
| 94 static void pushReader(ExecutionContext* context, FileReader* reader) | 94 static void pushReader(ExecutionContext* context, FileReader* reader) |
| 95 { | 95 { |
| 96 ThrottlingController* controller = from(context); | 96 ThrottlingController* controller = from(context); |
| 97 if (!controller) | 97 if (!controller) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 reader->m_asyncOperationId = InspectorInstrumentation::traceAsyncOperati
onStarting(context, "FileReader"); | 100 InspectorInstrumentation::asyncTaskScheduled(context, "FileReader", read
er, true); |
| 101 controller->pushReader(reader); | 101 controller->pushReader(reader); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) | 104 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) |
| 105 { | 105 { |
| 106 ThrottlingController* controller = from(context); | 106 ThrottlingController* controller = from(context); |
| 107 if (!controller) | 107 if (!controller) |
| 108 return DoNotRunPendingReaders; | 108 return DoNotRunPendingReaders; |
| 109 | 109 |
| 110 return controller->removeReader(reader); | 110 return controller->removeReader(reader); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) | 113 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) |
| 114 { | 114 { |
| 115 InspectorInstrumentation::traceAsyncOperationCompleted(context, reader->
m_asyncOperationId); | |
| 116 | |
| 117 ThrottlingController* controller = from(context); | 115 ThrottlingController* controller = from(context); |
| 118 if (!controller) | 116 if (!controller) |
| 119 return; | 117 return; |
| 120 | 118 |
| 121 controller->finishReader(reader, nextStep); | 119 controller->finishReader(reader, nextStep); |
| 120 InspectorInstrumentation::asyncTaskCanceled(context, reader); |
| 122 } | 121 } |
| 123 | 122 |
| 124 DEFINE_INLINE_TRACE() | 123 DEFINE_INLINE_TRACE() |
| 125 { | 124 { |
| 126 visitor->trace(m_pendingReaders); | 125 visitor->trace(m_pendingReaders); |
| 127 visitor->trace(m_runningReaders); | 126 visitor->trace(m_runningReaders); |
| 128 Supplement<ExecutionContext>::trace(visitor); | 127 Supplement<ExecutionContext>::trace(visitor); |
| 129 } | 128 } |
| 130 | 129 |
| 131 private: | 130 private: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 return fileReader; | 198 return fileReader; |
| 200 } | 199 } |
| 201 | 200 |
| 202 FileReader::FileReader(ExecutionContext* context) | 201 FileReader::FileReader(ExecutionContext* context) |
| 203 : ActiveScriptWrappable(this) | 202 : ActiveScriptWrappable(this) |
| 204 , ActiveDOMObject(context) | 203 , ActiveDOMObject(context) |
| 205 , m_state(EMPTY) | 204 , m_state(EMPTY) |
| 206 , m_loadingState(LoadingStateNone) | 205 , m_loadingState(LoadingStateNone) |
| 207 , m_readType(FileReaderLoader::ReadAsBinaryString) | 206 , m_readType(FileReaderLoader::ReadAsBinaryString) |
| 208 , m_lastProgressNotificationTimeMS(0) | 207 , m_lastProgressNotificationTimeMS(0) |
| 209 , m_asyncOperationId(0) | |
| 210 { | 208 { |
| 211 } | 209 } |
| 212 | 210 |
| 213 FileReader::~FileReader() | 211 FileReader::~FileReader() |
| 214 { | 212 { |
| 215 terminate(); | 213 terminate(); |
| 216 } | 214 } |
| 217 | 215 |
| 218 const AtomicString& FileReader::interfaceName() const | 216 const AtomicString& FileReader::interfaceName() const |
| 219 { | 217 { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 442 |
| 445 fireEvent(EventTypeNames::error); | 443 fireEvent(EventTypeNames::error); |
| 446 fireEvent(EventTypeNames::loadend); | 444 fireEvent(EventTypeNames::loadend); |
| 447 | 445 |
| 448 // All possible events have fired and we're done, no more pending activity. | 446 // All possible events have fired and we're done, no more pending activity. |
| 449 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); | 447 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); |
| 450 } | 448 } |
| 451 | 449 |
| 452 void FileReader::fireEvent(const AtomicString& type) | 450 void FileReader::fireEvent(const AtomicString& type) |
| 453 { | 451 { |
| 454 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
CallbackStarting(getExecutionContext(), m_asyncOperationId); | 452 InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), this); |
| 455 if (!m_loader) { | 453 if (!m_loader) { |
| 456 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); | 454 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); |
| 457 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 458 return; | 455 return; |
| 459 } | 456 } |
| 460 | 457 |
| 461 if (m_loader->totalBytes() >= 0) | 458 if (m_loader->totalBytes() >= 0) |
| 462 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); | 459 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); |
| 463 else | 460 else |
| 464 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); | 461 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); |
| 465 | |
| 466 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 467 } | 462 } |
| 468 | 463 |
| 469 DEFINE_TRACE(FileReader) | 464 DEFINE_TRACE(FileReader) |
| 470 { | 465 { |
| 471 visitor->trace(m_error); | 466 visitor->trace(m_error); |
| 472 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); | 467 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); |
| 473 ActiveDOMObject::trace(visitor); | 468 ActiveDOMObject::trace(visitor); |
| 474 } | 469 } |
| 475 | 470 |
| 476 } // namespace blink | 471 } // namespace blink |
| OLD | NEW |