Changeset 85556 in webkit


Ignore:
Timestamp:
May 2, 2011 5:10:45 PM (13 years ago)
Author:
ericu@chromium.org
Message:

2011-05-02 Eric Uhrhane <ericu@chromium.org>

Reviewed by Eric Seidel.

Some FileWriter progress events should be queued
https://bugs.webkit.org/show_bug.cgi?id=50846

  • fileapi/FileWriter.cpp:
  • fileapi/FileWriter.h: Create a new asynchronous Task [FileWriterCompletionEventTask] that will set readyState to DONE and fire off the right events.

2011-05-02 Eric Uhrhane <ericu@chromium.org>

Reviewed by Eric Seidel.

Some FileWriter progress events should be queued
https://bugs.webkit.org/show_bug.cgi?id=50846

  • fast/filesystem/resources/file-writer-events.js: (onWrite): Expect readyState at onwrite to be DONE now, not WRITING.
  • fast/filesystem/resources/file-writer-utils.js: Switch to using onwrite, now that it works.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85553 r85556  
     12011-05-02  Eric Uhrhane  <ericu@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Some FileWriter progress events should be queued
     6        https://bugs.webkit.org/show_bug.cgi?id=50846
     7
     8        * fast/filesystem/resources/file-writer-events.js:
     9        (onWrite): Expect readyState at onwrite to be DONE now, not WRITING.
     10        * fast/filesystem/resources/file-writer-utils.js:
     11        Switch to using onwrite, now that it works.
     12
    1132011-05-02  Mark Pilgrim  <pilgrim@chromium.org>
    214
  • trunk/LayoutTests/fast/filesystem/resources/file-writer-events.js

    r83884 r85556  
    5050
    5151function onWrite(e) {
    52     assert(writer.readyState == writer.WRITING);
     52    assert(writer.readyState == writer.DONE);
    5353    assert(sawWriteStart);
    5454    assert(sawProgress);
  • trunk/LayoutTests/fast/filesystem/resources/file-writer-utils.js

    r84224 r85556  
    117117            var successFunc = getSuccessFunc(fileEntry);
    118118            fileWriter.onError = onError;
    119             // FIXME: This should be onwrite, but the spec and code need to be changed to allow that.  See https://bugs.webkit.org/show_bug.cgi?id=50846.
    120             fileWriter.onwriteend = function() {
     119            fileWriter.onwrite = function() {
     120                fileWriter.onwrite = null;
    121121                verifyFileLength(fileEntry, 0, successFunc);
    122122            };
     
    144144        offset += fileWriter.length;
    145145    assert(offset >= 0);
    146     // FIXME: This should be onwrite, but the spec and code need to be changed to allow that.  See https://bugs.webkit.org/show_bug.cgi?id=50846.
    147     fileWriter.onwriteend = function() {
    148         fileWriter.onwriteend = null;
     146    fileWriter.onwrite = function() {
     147        fileWriter.onwrite = null;
    149148        verifyByteRangeAsString(fileEntry, offset, data, onSuccess);
    150149    };
     
    153152function setFileContents(fileEntry, fileWriter, contents, onSuccess) {
    154153    fileWriter.onerror = onError;
    155     // FIXME: This should be onwrite, but the spec and code need to be changed to allow that.  See https://bugs.webkit.org/show_bug.cgi?id=50846.
    156     fileWriter.onwriteend = function() {
     154    fileWriter.onwrite = function() {
     155        fileWriter.onwrite = null;
    157156        writeString(fileEntry, fileWriter, 0, contents, onSuccess);
    158157    };
  • trunk/Source/WebCore/ChangeLog

    r85551 r85556  
     12011-05-02  Eric Uhrhane  <ericu@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Some FileWriter progress events should be queued
     6        https://bugs.webkit.org/show_bug.cgi?id=50846
     7
     8        * fileapi/FileWriter.cpp:
     9        * fileapi/FileWriter.h:
     10        Create a new asynchronous Task [FileWriterCompletionEventTask] that will set readyState to DONE and fire off the right events.
     11
    1122011-05-02  Jia Pu  <jpu@apple.com>
    213
  • trunk/Source/WebCore/fileapi/FileWriter.cpp

    r72985 r85556  
    134134    }
    135135
    136     m_error = FileError::create(FileError::ABORT_ERR);
    137136    writer()->abort();
    138137}
     
    154153    if (complete) {
    155154        m_blobBeingWritten.clear();
    156         fireEvent(eventNames().writeEvent);
    157         m_readyState = DONE;
    158         fireEvent(eventNames().writeendEvent);
     155        scriptExecutionContext()->postTask(FileWriterCompletionEventTask::create(this, FileError::OK));
    159156    }
    160157}
     
    168165        setPosition(length());
    169166    m_truncateLength = -1;
    170     fireEvent(eventNames().writeEvent);
     167    scriptExecutionContext()->postTask(FileWriterCompletionEventTask::create(this, FileError::OK));
     168}
     169
     170void FileWriter::didFail(FileError::ErrorCode code)
     171{
     172    ASSERT(code != FileError::OK);
     173    m_blobBeingWritten.clear();
     174    scriptExecutionContext()->postTask(FileWriterCompletionEventTask::create(this, code));
     175}
     176
     177void FileWriter::signalCompletion(FileError::ErrorCode code)
     178{
    171179    m_readyState = DONE;
    172     fireEvent(eventNames().writeendEvent);
    173 }
    174 
    175 void FileWriter::didFail(FileError::ErrorCode code)
    176 {
    177     m_error = FileError::create(code);
    178     fireEvent(eventNames().errorEvent);
    179     if (FileError::ABORT_ERR == code)
    180         fireEvent(eventNames().abortEvent);
    181     fireEvent(eventNames().errorEvent);
    182     m_blobBeingWritten.clear();
    183     m_readyState = DONE;
     180    if (FileError::OK != code) {
     181        m_error = FileError::create(code);
     182        fireEvent(eventNames().errorEvent);
     183        if (FileError::ABORT_ERR == code)
     184            fireEvent(eventNames().abortEvent);
     185    } else
     186        fireEvent(eventNames().writeEvent);
    184187    fireEvent(eventNames().writeendEvent);
    185188}
  • trunk/Source/WebCore/fileapi/FileWriter.h

    r72715 r85556  
    3737#include "EventTarget.h"
    3838#include "FileWriterBase.h"
     39#include "ScriptExecutionContext.h"
    3940#include <wtf/PassRefPtr.h>
    4041#include <wtf/RefPtr.h>
     
    103104    void setError(FileError::ErrorCode, ExceptionCode&);
    104105
     106    void signalCompletion(FileError::ErrorCode);
     107
     108    class FileWriterCompletionEventTask : public ScriptExecutionContext::Task {
     109    public:
     110        static PassOwnPtr<FileWriterCompletionEventTask> create(PassRefPtr<FileWriter> fileWriter, FileError::ErrorCode code)
     111        {
     112            return adoptPtr(new FileWriterCompletionEventTask(fileWriter, code));
     113        }
     114
     115
     116        virtual void performTask(ScriptExecutionContext*)
     117        {
     118            m_fileWriter->signalCompletion(m_code);
     119        }
     120    private:
     121        FileWriterCompletionEventTask(PassRefPtr<FileWriter> fileWriter, FileError::ErrorCode code)
     122            : m_fileWriter(fileWriter)
     123            , m_code(code)
     124        {
     125        }
     126
     127        RefPtr<FileWriter> m_fileWriter;
     128        FileError::ErrorCode m_code;
     129    };
     130
    105131    RefPtr<FileError> m_error;
    106132    EventTargetData m_eventTargetData;
Note: See TracChangeset for help on using the changeset viewer.