Title: [120728] trunk/Source/WebCore
- Revision
- 120728
- Author
- [email protected]
- Date
- 2012-06-19 10:25:06 -0700 (Tue, 19 Jun 2012)
Log Message
FileWriter progress events should be throttled to 50ms
https://bugs.webkit.org/show_bug.cgi?id=89022
Reviewed by Kent Tamura.
No new tests; existing tests validate our event sequences, and testing
timing is likely to be flaky.
* Modules/filesystem/FileWriter.cpp:
(WebCore):
(WebCore::FileWriter::FileWriter):
(WebCore::FileWriter::didWrite): Throttle sending progress events.
* Modules/filesystem/FileWriter.h:
(FileWriter): Add a variable that remembers when the last event was
sent.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (120727 => 120728)
--- trunk/Source/WebCore/ChangeLog 2012-06-19 17:10:47 UTC (rev 120727)
+++ trunk/Source/WebCore/ChangeLog 2012-06-19 17:25:06 UTC (rev 120728)
@@ -1,3 +1,21 @@
+2012-06-13 Eric Uhrhane <[email protected]>
+
+ FileWriter progress events should be throttled to 50ms
+ https://bugs.webkit.org/show_bug.cgi?id=89022
+
+ Reviewed by Kent Tamura.
+
+ No new tests; existing tests validate our event sequences, and testing
+ timing is likely to be flaky.
+
+ * Modules/filesystem/FileWriter.cpp:
+ (WebCore):
+ (WebCore::FileWriter::FileWriter):
+ (WebCore::FileWriter::didWrite): Throttle sending progress events.
+ * Modules/filesystem/FileWriter.h:
+ (FileWriter): Add a variable that remembers when the last event was
+ sent.
+
2012-06-19 Dan Bernstein <[email protected]>
WebCore part of: Paginated display API doesn’t allow setting the page progression direction
Modified: trunk/Source/WebCore/Modules/filesystem/FileWriter.cpp (120727 => 120728)
--- trunk/Source/WebCore/Modules/filesystem/FileWriter.cpp 2012-06-19 17:10:47 UTC (rev 120727)
+++ trunk/Source/WebCore/Modules/filesystem/FileWriter.cpp 2012-06-19 17:25:06 UTC (rev 120728)
@@ -40,10 +40,12 @@
#include "FileError.h"
#include "FileException.h"
#include "ProgressEvent.h"
+#include <wtf/CurrentTime.h>
namespace WebCore {
static const int kMaxRecursionDepth = 3;
+static const double progressNotificationIntervalMS = 50;
PassRefPtr<FileWriter> FileWriter::create(ScriptExecutionContext* context)
{
@@ -62,6 +64,7 @@
, m_truncateLength(-1)
, m_numAborts(0)
, m_recursionDepth(0)
+ , m_lastProgressNotificationTimeMS(0)
{
}
@@ -196,11 +199,16 @@
m_blobBeingWritten.clear();
m_operationInProgress = OperationNone;
}
- // TODO: Throttle to no more frequently than every 50ms.
+
int numAborts = m_numAborts;
- fireEvent(eventNames().progressEvent);
// We could get an abort in the handler for this event. If we do, it's
// already handled the cleanup and signalCompletion call.
+ double now = currentTimeMS();
+ if (complete || !m_lastProgressNotificationTimeMS || (now - m_lastProgressNotificationTimeMS > progressNotificationIntervalMS)) {
+ m_lastProgressNotificationTimeMS = now;
+ fireEvent(eventNames().progressEvent);
+ }
+
if (complete) {
if (numAborts == m_numAborts)
signalCompletion(FileError::OK);
Modified: trunk/Source/WebCore/Modules/filesystem/FileWriter.h (120727 => 120728)
--- trunk/Source/WebCore/Modules/filesystem/FileWriter.h 2012-06-19 17:10:47 UTC (rev 120727)
+++ trunk/Source/WebCore/Modules/filesystem/FileWriter.h 2012-06-19 17:25:06 UTC (rev 120728)
@@ -124,6 +124,7 @@
long long m_truncateLength;
long long m_numAborts;
long long m_recursionDepth;
+ double m_lastProgressNotificationTimeMS;
RefPtr<Blob> m_blobBeingWritten;
};
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes