Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/WebKit/Source/core/fileapi/FileReader.cpp

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: same with scriptpromiseresolver Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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");
dgozman 2016/04/06 02:31:08 Bring it back!
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 visitor->trace(m_pendingReaders); 122 visitor->trace(m_pendingReaders);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return fileReader; 195 return fileReader;
200 } 196 }
201 197
202 FileReader::FileReader(ExecutionContext* context) 198 FileReader::FileReader(ExecutionContext* context)
203 : ActiveScriptWrappable(this) 199 : ActiveScriptWrappable(this)
204 , ActiveDOMObject(context) 200 , ActiveDOMObject(context)
205 , m_state(EMPTY) 201 , m_state(EMPTY)
206 , m_loadingState(LoadingStateNone) 202 , m_loadingState(LoadingStateNone)
207 , m_readType(FileReaderLoader::ReadAsBinaryString) 203 , m_readType(FileReaderLoader::ReadAsBinaryString)
208 , m_lastProgressNotificationTimeMS(0) 204 , m_lastProgressNotificationTimeMS(0)
209 , m_asyncOperationId(0)
210 { 205 {
211 } 206 }
212 207
213 FileReader::~FileReader() 208 FileReader::~FileReader()
214 { 209 {
215 terminate(); 210 terminate();
216 } 211 }
217 212
218 const AtomicString& FileReader::interfaceName() const 213 const AtomicString& FileReader::interfaceName() const
219 { 214 {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 439
445 fireEvent(EventTypeNames::error); 440 fireEvent(EventTypeNames::error);
446 fireEvent(EventTypeNames::loadend); 441 fireEvent(EventTypeNames::loadend);
447 442
448 // All possible events have fired and we're done, no more pending activity. 443 // All possible events have fired and we're done, no more pending activity.
449 ThrottlingController::finishReader(getExecutionContext(), this, finalStep); 444 ThrottlingController::finishReader(getExecutionContext(), this, finalStep);
450 } 445 }
451 446
452 void FileReader::fireEvent(const AtomicString& type) 447 void FileReader::fireEvent(const AtomicString& type)
453 { 448 {
454 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync CallbackStarting(getExecutionContext(), m_asyncOperationId);
455 if (!m_loader) { 449 if (!m_loader) {
456 dispatchEvent(ProgressEvent::create(type, false, 0, 0)); 450 dispatchEvent(ProgressEvent::create(type, false, 0, 0));
457 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie);
458 return; 451 return;
459 } 452 }
460 453
461 if (m_loader->totalBytes() >= 0) 454 if (m_loader->totalBytes() >= 0)
462 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), m_loader->totalBytes())); 455 dispatchEvent(ProgressEvent::create(type, true, m_loader->bytesLoaded(), m_loader->totalBytes()));
463 else 456 else
464 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded() , 0)); 457 dispatchEvent(ProgressEvent::create(type, false, m_loader->bytesLoaded() , 0));
465
466 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie);
467 } 458 }
468 459
469 DEFINE_TRACE(FileReader) 460 DEFINE_TRACE(FileReader)
470 { 461 {
471 visitor->trace(m_error); 462 visitor->trace(m_error);
472 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit or); 463 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit or);
473 ActiveDOMObject::trace(visitor); 464 ActiveDOMObject::trace(visitor);
474 } 465 }
475 466
476 } // namespace blink 467 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698