| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 34 #include "bindings/core/v8/UnionTypesCore.h" | 34 #include "bindings/core/v8/UnionTypesCore.h" |
| 35 #include "core/dom/CrossThreadTask.h" | 35 #include "core/dom/CrossThreadTask.h" |
| 36 #include "core/dom/DOMArrayBuffer.h" | 36 #include "core/dom/DOMArrayBuffer.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 39 #include "core/dom/ExecutionContext.h" | 39 #include "core/dom/ExecutionContext.h" |
| 40 #include "core/events/ProgressEvent.h" | 40 #include "core/events/ProgressEvent.h" |
| 41 #include "core/fileapi/File.h" | 41 #include "core/fileapi/File.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | |
| 43 #include "platform/Logging.h" | 42 #include "platform/Logging.h" |
| 44 #include "platform/Supplementable.h" | 43 #include "platform/Supplementable.h" |
| 45 #include "wtf/CurrentTime.h" | 44 #include "wtf/CurrentTime.h" |
| 46 #include "wtf/Deque.h" | 45 #include "wtf/Deque.h" |
| 47 #include "wtf/HashSet.h" | 46 #include "wtf/HashSet.h" |
| 48 #include "wtf/text/CString.h" | 47 #include "wtf/text/CString.h" |
| 49 | 48 |
| 50 namespace blink { | 49 namespace blink { |
| 51 | 50 |
| 52 namespace { | 51 namespace { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 ~ThrottlingController() { } | 89 ~ThrottlingController() { } |
| 91 | 90 |
| 92 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 91 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
| 93 | 92 |
| 94 static void pushReader(ExecutionContext* context, FileReader* reader) | 93 static void pushReader(ExecutionContext* context, FileReader* reader) |
| 95 { | 94 { |
| 96 ThrottlingController* controller = from(context); | 95 ThrottlingController* controller = from(context); |
| 97 if (!controller) | 96 if (!controller) |
| 98 return; | 97 return; |
| 99 | 98 |
| 100 reader->m_asyncOperationId = InspectorInstrumentation::traceAsyncOperati
onStarting(context, "FileReader"); | |
| 101 controller->pushReader(reader); | 99 controller->pushReader(reader); |
| 102 } | 100 } |
| 103 | 101 |
| 104 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) | 102 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) |
| 105 { | 103 { |
| 106 ThrottlingController* controller = from(context); | 104 ThrottlingController* controller = from(context); |
| 107 if (!controller) | 105 if (!controller) |
| 108 return DoNotRunPendingReaders; | 106 return DoNotRunPendingReaders; |
| 109 | 107 |
| 110 return controller->removeReader(reader); | 108 return controller->removeReader(reader); |
| 111 } | 109 } |
| 112 | 110 |
| 113 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) | 111 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) |
| 114 { | 112 { |
| 115 InspectorInstrumentation::traceAsyncOperationCompleted(context, reader->
m_asyncOperationId); | |
| 116 | |
| 117 ThrottlingController* controller = from(context); | 113 ThrottlingController* controller = from(context); |
| 118 if (!controller) | 114 if (!controller) |
| 119 return; | 115 return; |
| 120 | 116 |
| 121 controller->finishReader(reader, nextStep); | 117 controller->finishReader(reader, nextStep); |
| 122 } | 118 } |
| 123 | 119 |
| 124 DEFINE_INLINE_TRACE() | 120 DEFINE_INLINE_TRACE() |
| 125 { | 121 { |
| 126 #if ENABLE(OILPAN) | 122 #if ENABLE(OILPAN) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return fileReader; | 197 return fileReader; |
| 202 } | 198 } |
| 203 | 199 |
| 204 FileReader::FileReader(ExecutionContext* context) | 200 FileReader::FileReader(ExecutionContext* context) |
| 205 : ActiveScriptWrappable(this) | 201 : ActiveScriptWrappable(this) |
| 206 , ActiveDOMObject(context) | 202 , ActiveDOMObject(context) |
| 207 , m_state(EMPTY) | 203 , m_state(EMPTY) |
| 208 , m_loadingState(LoadingStateNone) | 204 , m_loadingState(LoadingStateNone) |
| 209 , m_readType(FileReaderLoader::ReadAsBinaryString) | 205 , m_readType(FileReaderLoader::ReadAsBinaryString) |
| 210 , m_lastProgressNotificationTimeMS(0) | 206 , m_lastProgressNotificationTimeMS(0) |
| 211 , m_asyncOperationId(0) | |
| 212 { | 207 { |
| 213 } | 208 } |
| 214 | 209 |
| 215 FileReader::~FileReader() | 210 FileReader::~FileReader() |
| 216 { | 211 { |
| 217 terminate(); | 212 terminate(); |
| 218 } | 213 } |
| 219 | 214 |
| 220 const AtomicString& FileReader::interfaceName() const | 215 const AtomicString& FileReader::interfaceName() const |
| 221 { | 216 { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 441 |
| 447 fireEvent(EventTypeNames::error); | 442 fireEvent(EventTypeNames::error); |
| 448 fireEvent(EventTypeNames::loadend); | 443 fireEvent(EventTypeNames::loadend); |
| 449 | 444 |
| 450 // All possible events have fired and we're done, no more pending activity. | 445 // All possible events have fired and we're done, no more pending activity. |
| 451 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); | 446 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); |
| 452 } | 447 } |
| 453 | 448 |
| 454 void FileReader::fireEvent(const AtomicString& type) | 449 void FileReader::fireEvent(const AtomicString& type) |
| 455 { | 450 { |
| 456 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
CallbackStarting(getExecutionContext(), m_asyncOperationId); | |
| 457 if (!m_loader) { | 451 if (!m_loader) { |
| 458 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); | 452 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); |
| 459 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 460 return; | 453 return; |
| 461 } | 454 } |
| 462 | 455 |
| 463 if (m_loader->totalBytes() >= 0) | 456 if (m_loader->totalBytes() >= 0) |
| 464 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); | 457 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); |
| 465 else | 458 else |
| 466 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); | 459 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); |
| 467 | |
| 468 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 469 } | 460 } |
| 470 | 461 |
| 471 DEFINE_TRACE(FileReader) | 462 DEFINE_TRACE(FileReader) |
| 472 { | 463 { |
| 473 visitor->trace(m_error); | 464 visitor->trace(m_error); |
| 474 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); | 465 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); |
| 475 ActiveDOMObject::trace(visitor); | 466 ActiveDOMObject::trace(visitor); |
| 476 } | 467 } |
| 477 | 468 |
| 478 } // namespace blink | 469 } // namespace blink |
| OLD | NEW |