Chromium Code Reviews| Index: third_party/WebKit/Source/core/fileapi/FileReader.cpp |
| diff --git a/third_party/WebKit/Source/core/fileapi/FileReader.cpp b/third_party/WebKit/Source/core/fileapi/FileReader.cpp |
| index 648352ed2addfc10b4b0a2af2b9286921e032568..2e5066b471c9b061539ba60a8c043fd8a2b80092 100644 |
| --- a/third_party/WebKit/Source/core/fileapi/FileReader.cpp |
| +++ b/third_party/WebKit/Source/core/fileapi/FileReader.cpp |
| @@ -45,6 +45,7 @@ |
| #include "wtf/CurrentTime.h" |
| #include "wtf/Deque.h" |
| #include "wtf/HashSet.h" |
| +#include "wtf/TemporaryChange.h" |
| #include "wtf/text/CString.h" |
| namespace blink { |
| @@ -199,6 +200,7 @@ FileReader::FileReader(ExecutionContext* context) |
| , ActiveDOMObject(context) |
| , m_state(EMPTY) |
| , m_loadingState(LoadingStateNone) |
| + , m_stillFiringEvents(false) |
| , m_readType(FileReaderLoader::ReadAsBinaryString) |
| , m_lastProgressNotificationTimeMS(0) |
| { |
| @@ -227,7 +229,7 @@ void FileReader::stop() |
| bool FileReader::hasPendingActivity() const |
| { |
| - return m_state == LOADING; |
| + return m_state == LOADING || m_stillFiringEvents; |
| } |
| void FileReader::readAsArrayBuffer(Blob* blob, ExceptionState& exceptionState) |
| @@ -341,6 +343,7 @@ void FileReader::abort() |
| void FileReader::doAbort() |
| { |
| ASSERT(m_state != DONE); |
| + TemporaryChange<bool> firingEvents(m_stillFiringEvents, true); |
| terminate(); |
| @@ -380,6 +383,7 @@ void FileReader::terminate() |
| void FileReader::didStartLoading() |
| { |
| + TemporaryChange<bool> firingEvents(m_stillFiringEvents, true); |
| fireEvent(EventTypeNames::loadstart); |
| } |
| @@ -390,6 +394,7 @@ void FileReader::didReceiveData() |
| if (!m_lastProgressNotificationTimeMS) { |
| m_lastProgressNotificationTimeMS = now; |
| } else if (now - m_lastProgressNotificationTimeMS > progressNotificationIntervalMS) { |
| + TemporaryChange<bool> firingEvents(m_stillFiringEvents, true); |
| fireEvent(EventTypeNames::progress); |
| m_lastProgressNotificationTimeMS = now; |
| } |
| @@ -401,6 +406,8 @@ void FileReader::didFinishLoading() |
| return; |
| ASSERT(m_loadingState == LoadingStateLoading); |
| + TemporaryChange<bool> firingEvents(m_stillFiringEvents, true); |
| + |
| // It's important that we change m_loadingState before firing any events |
| // since any of the events could call abort(), which internally checks |
| // if we're still loading (therefore we need abort process) or not. |
| @@ -425,6 +432,9 @@ void FileReader::didFail(FileError::ErrorCode errorCode) |
| { |
| if (m_loadingState == LoadingStateAborted) |
| return; |
| + |
| + TemporaryChange<bool> firingEvents(m_stillFiringEvents, true); |
|
haraken
2016/07/13 08:04:33
Can we move these TemporalChange<>s into fireEvent
|
| + |
| ASSERT(m_loadingState == LoadingStateLoading); |
| m_loadingState = LoadingStateNone; |