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 #include "core/fileapi/FileReader.h" | 32 #include "core/fileapi/FileReader.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
35 #include "core/dom/CrossThreadTask.h" | 35 #include "core/dom/CrossThreadTask.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/events/ProgressEvent.h" | 39 #include "core/events/ProgressEvent.h" |
40 #include "core/fileapi/File.h" | 40 #include "core/fileapi/File.h" |
41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" |
42 #include "core/workers/WorkerClients.h" | 43 #include "core/workers/WorkerClients.h" |
43 #include "core/workers/WorkerGlobalScope.h" | 44 #include "core/workers/WorkerGlobalScope.h" |
44 #include "platform/Logging.h" | 45 #include "platform/Logging.h" |
45 #include "platform/Supplementable.h" | 46 #include "platform/Supplementable.h" |
46 #include "wtf/ArrayBuffer.h" | 47 #include "wtf/ArrayBuffer.h" |
47 #include "wtf/CurrentTime.h" | 48 #include "wtf/CurrentTime.h" |
48 #include "wtf/Deque.h" | 49 #include "wtf/Deque.h" |
49 #include "wtf/HashSet.h" | 50 #include "wtf/HashSet.h" |
50 #include "wtf/text/CString.h" | 51 #include "wtf/text/CString.h" |
51 | 52 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ~ThrottlingController() { } | 112 ~ThrottlingController() { } |
112 | 113 |
113 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 114 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
114 | 115 |
115 static void pushReader(ExecutionContext* context, FileReader* reader) | 116 static void pushReader(ExecutionContext* context, FileReader* reader) |
116 { | 117 { |
117 ThrottlingController* controller = from(context); | 118 ThrottlingController* controller = from(context); |
118 if (!controller) | 119 if (!controller) |
119 return; | 120 return; |
120 | 121 |
| 122 reader->m_asyncOperationId = InspectorInstrumentation::traceAsyncOperati
onStarting(context, "FileReader"); |
121 controller->pushReader(reader); | 123 controller->pushReader(reader); |
122 } | 124 } |
123 | 125 |
124 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) | 126 static FinishReaderType removeReader(ExecutionContext* context, FileReader*
reader) |
125 { | 127 { |
126 ThrottlingController* controller = from(context); | 128 ThrottlingController* controller = from(context); |
127 if (!controller) | 129 if (!controller) |
128 return DoNotRunPendingReaders; | 130 return DoNotRunPendingReaders; |
129 | 131 |
130 return controller->removeReader(reader); | 132 return controller->removeReader(reader); |
131 } | 133 } |
132 | 134 |
133 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) | 135 static void finishReader(ExecutionContext* context, FileReader* reader, Fini
shReaderType nextStep) |
134 { | 136 { |
| 137 InspectorInstrumentation::traceAsyncOperationCompleted(context, reader->
m_asyncOperationId); |
| 138 |
135 ThrottlingController* controller = from(context); | 139 ThrottlingController* controller = from(context); |
136 if (!controller) | 140 if (!controller) |
137 return; | 141 return; |
138 | 142 |
139 controller->finishReader(reader, nextStep); | 143 controller->finishReader(reader, nextStep); |
140 } | 144 } |
141 | 145 |
142 void trace(Visitor* visitor) | 146 void trace(Visitor* visitor) |
143 { | 147 { |
144 #if ENABLE(OILPAN) | 148 #if ENABLE(OILPAN) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 fileReader->suspendIfNeeded(); | 219 fileReader->suspendIfNeeded(); |
216 return fileReader.release(); | 220 return fileReader.release(); |
217 } | 221 } |
218 | 222 |
219 FileReader::FileReader(ExecutionContext* context) | 223 FileReader::FileReader(ExecutionContext* context) |
220 : ActiveDOMObject(context) | 224 : ActiveDOMObject(context) |
221 , m_state(EMPTY) | 225 , m_state(EMPTY) |
222 , m_loadingState(LoadingStateNone) | 226 , m_loadingState(LoadingStateNone) |
223 , m_readType(FileReaderLoader::ReadAsBinaryString) | 227 , m_readType(FileReaderLoader::ReadAsBinaryString) |
224 , m_lastProgressNotificationTimeMS(0) | 228 , m_lastProgressNotificationTimeMS(0) |
| 229 , m_asyncOperationId(0) |
225 { | 230 { |
226 ScriptWrappable::init(this); | 231 ScriptWrappable::init(this); |
227 } | 232 } |
228 | 233 |
229 FileReader::~FileReader() | 234 FileReader::~FileReader() |
230 { | 235 { |
231 terminate(); | 236 terminate(); |
232 } | 237 } |
233 | 238 |
234 const AtomicString& FileReader::interfaceName() const | 239 const AtomicString& FileReader::interfaceName() const |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 458 |
454 fireEvent(EventTypeNames::error); | 459 fireEvent(EventTypeNames::error); |
455 fireEvent(EventTypeNames::loadend); | 460 fireEvent(EventTypeNames::loadend); |
456 | 461 |
457 // All possible events have fired and we're done, no more pending activity. | 462 // All possible events have fired and we're done, no more pending activity. |
458 ThrottlingController::finishReader(executionContext(), this, finalStep); | 463 ThrottlingController::finishReader(executionContext(), this, finalStep); |
459 } | 464 } |
460 | 465 |
461 void FileReader::fireEvent(const AtomicString& type) | 466 void FileReader::fireEvent(const AtomicString& type) |
462 { | 467 { |
| 468 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
CallbackStarting(executionContext(), m_asyncOperationId); |
463 if (!m_loader) { | 469 if (!m_loader) { |
464 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); | 470 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); |
| 471 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
465 return; | 472 return; |
466 } | 473 } |
467 | 474 |
468 if (m_loader->totalBytes() >= 0) | 475 if (m_loader->totalBytes() >= 0) |
469 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); | 476 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(),
m_loader->totalBytes())); |
470 else | 477 else |
471 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); | 478 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded()
, 0)); |
| 479 |
| 480 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
472 } | 481 } |
473 | 482 |
474 PassRefPtr<ArrayBuffer> FileReader::arrayBufferResult() const | 483 PassRefPtr<ArrayBuffer> FileReader::arrayBufferResult() const |
475 { | 484 { |
476 if (!m_loader || m_error) | 485 if (!m_loader || m_error) |
477 return nullptr; | 486 return nullptr; |
478 return m_loader->arrayBufferResult(); | 487 return m_loader->arrayBufferResult(); |
479 } | 488 } |
480 | 489 |
481 String FileReader::stringResult() | 490 String FileReader::stringResult() |
482 { | 491 { |
483 if (!m_loader || m_error) | 492 if (!m_loader || m_error) |
484 return String(); | 493 return String(); |
485 return m_loader->stringResult(); | 494 return m_loader->stringResult(); |
486 } | 495 } |
487 | 496 |
488 void FileReader::trace(Visitor* visitor) | 497 void FileReader::trace(Visitor* visitor) |
489 { | 498 { |
490 visitor->trace(m_error); | 499 visitor->trace(m_error); |
491 EventTargetWithInlineData::trace(visitor); | 500 EventTargetWithInlineData::trace(visitor); |
492 } | 501 } |
493 | 502 |
494 } // namespace blink | 503 } // namespace blink |
OLD | NEW |