[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 12:44:58 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 47ce177e096fdfddd11b0c7e69f57fe14999502d
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Aug 28 08:49:02 2010 +0000
2010-08-28 Eric Uhrhane <ericu at chromium.org>
Reviewed by Darin Fisher.
Implement the DOM FileWriter class
https://bugs.webkit.org/show_bug.cgi?id=44362
No new tests until the delegate class has an implementation; bug logged.
Build file additions.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
The AsyncFileWriter is an abstract interface to which FileWriter delegates all the hard work.
* html/AsyncFileWriter.h: Added.
The FileWriterClient is the interface for communications back from the AsyncFileWriter [success/failure, progress events].
* html/FileWriterClient.h: Added.
(WebCore::FileWriterClient::~FileWriterClient):
Added all delegation, state tracking, and progress event processing.
* html/FileWriter.cpp:
(WebCore::FileWriter::FileWriter):
(WebCore::FileWriter::initialize):
(WebCore::FileWriter::~FileWriter):
ActiveDomObject stuff
(WebCore::FileWriter::hasPendingActivity):
(WebCore::FileWriter::stop):
(WebCore::FileWriter::write):
FileWriter public interface
(WebCore::FileWriter::seek):
(WebCore::FileWriter::truncate):
(WebCore::FileWriter::abort):
FileWriterClient interface
(WebCore::FileWriter::didWrite):
(WebCore::FileWriter::didTruncate):
(WebCore::FileWriter::didFail):
Progress events
(WebCore::FileWriter::fireEvent):
* html/FileWriter.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7bb8ce1..10aba06 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-08-28 Eric Uhrhane <ericu at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ Implement the DOM FileWriter class
+ https://bugs.webkit.org/show_bug.cgi?id=44362
+
+ No new tests until the delegate class has an implementation; bug logged.
+
+ Build file additions.
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ The AsyncFileWriter is an abstract interface to which FileWriter delegates all the hard work.
+ * html/AsyncFileWriter.h: Added.
+
+ The FileWriterClient is the interface for communications back from the AsyncFileWriter [success/failure, progress events].
+ * html/FileWriterClient.h: Added.
+ (WebCore::FileWriterClient::~FileWriterClient):
+
+ Added all delegation, state tracking, and progress event processing.
+ * html/FileWriter.cpp:
+ (WebCore::FileWriter::FileWriter):
+ (WebCore::FileWriter::initialize):
+ (WebCore::FileWriter::~FileWriter):
+ ActiveDomObject stuff
+ (WebCore::FileWriter::hasPendingActivity):
+ (WebCore::FileWriter::stop):
+ (WebCore::FileWriter::write):
+ FileWriter public interface
+ (WebCore::FileWriter::seek):
+ (WebCore::FileWriter::truncate):
+ (WebCore::FileWriter::abort):
+ FileWriterClient interface
+ (WebCore::FileWriter::didWrite):
+ (WebCore::FileWriter::didTruncate):
+ (WebCore::FileWriter::didFail):
+ Progress events
+ (WebCore::FileWriter::fireEvent):
+ * html/FileWriter.h:
+
2010-08-28 Marc-Antoine Ruel <maruel at chromium.org>
Reviewed by Dimitri Glazkov.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 48ea15a..c3ea3dc 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -237,8 +237,6 @@ webcore_built_sources += \
DerivedSources/WebCore/JSFileList.h \
DerivedSources/WebCore/JSFileReader.cpp \
DerivedSources/WebCore/JSFileReader.h \
- DerivedSources/WebCore/JSFileWriter.cpp \
- DerivedSources/WebCore/JSFileWriter.h \
DerivedSources/WebCore/JSFloat32Array.cpp \
DerivedSources/WebCore/JSFloat32Array.h \
DerivedSources/WebCore/JSGeolocation.cpp \
@@ -1353,8 +1351,6 @@ webcore_sources += \
WebCore/html/FileList.h \
WebCore/html/FileReader.cpp \
WebCore/html/FileReader.h \
- WebCore/html/FileWriter.cpp \
- WebCore/html/FileWriter.h \
WebCore/html/FileStreamProxy.cpp \
WebCore/html/FileStreamProxy.h \
WebCore/html/FileThread.cpp \
@@ -4443,6 +4439,17 @@ endif # END ENABLE_BLOB
if ENABLE_FILE_WRITER
FEATURE_DEFINES += ENABLE_FILE_WRITER=1
webcore_cppflags += -DENABLE_FILE_WRITER=1
+
+webcore_built_sources += \
+ DerivedSources/WebCore/JSFileWriter.cpp \
+ DerivedSources/WebCore/JSFileWriter.h
+
+webcore_sources += \
+ WebCore/html/AsyncFileWriter.h \
+ WebCore/html/FileWriter.cpp \
+ WebCore/html/FileWriter.h \
+ WebCore/html/FileWriterClient.h
+
endif # END ENABLE_FILE_WRITER
DerivedSources/WebCore/CSSPropertyNames.h: $(WEBCORE_CSS_PROPERTY_NAMES) $(WebCore)/css/makeprop.pl
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 9b1a642..36df123 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1436,6 +1436,7 @@
'history/HistoryItem.h',
'history/PageCache.cpp',
'history/PageCache.h',
+ 'html/AsyncFileWriter.h',
'html/AsyncImageResizer.cpp',
'html/AsyncImageResizer.h',
'html/Blob.cpp',
@@ -1521,13 +1522,14 @@
'html/FileList.h',
'html/FileReader.cpp',
'html/FileReader.h',
- 'html/FileWriter.cpp',
- 'html/FileWriter.h',
'html/FileStreamProxy.cpp',
'html/FileStreamProxy.h',
'html/FileThread.cpp',
'html/FileThread.h',
'html/FileThreadTask.h',
+ 'html/FileWriter.cpp',
+ 'html/FileWriter.h',
+ 'html/FileWriterClient.h',
'html/FormDataList.cpp',
'html/FormDataList.h',
'html/HTMLAllCollection.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 37d4f74..dec241e 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1407,6 +1407,7 @@ HEADERS += \
history/CachedPage.h \
history/HistoryItem.h \
history/PageCache.h \
+ html/AsyncFileWriter.h \
html/AsyncImageResizer.h \
html/Blob.h \
html/BlobBuilder.h \
@@ -1431,6 +1432,7 @@ HEADERS += \
html/FileThread.h \
html/FileThreadTask.h \
html/FileWriter.h \
+ html/FileWriterClient.h \
html/FormDataList.h \
html/HTMLAllCollection.h \
html/HTMLAnchorElement.h \
@@ -2601,6 +2603,7 @@ contains(DEFINES, ENABLE_FILE_SYSTEM=1) {
storage/FileEntry.h \
storage/FileSystemCallback.h \
storage/FileSystemCallbacks.h \
+ storage/FileWriterCallback.h \
storage/Flags.h \
storage/LocalFileSystem.h \
storage/Metadata.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index fd6b408..a8b2ad1 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -37077,6 +37077,10 @@
Name="html"
>
<File
+ RelativePath="..\html\AsyncFileWriter.h"
+ >
+ </File>
+ <File
RelativePath="..\html\AsyncImageResizer.cpp"
>
</File>
@@ -37277,6 +37281,10 @@
>
</File>
<File
+ RelativePath="..\html\FileWriterClient.h"
+ >
+ </File>
+ <File
RelativePath="..\html\FormDataList.cpp"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 29cb35a..3a868cf 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -902,14 +902,18 @@
448AD27C0A48137A0023D179 /* JSHTMLOptionsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */; };
449B19F50FA72ECE0015CA4A /* HTMLParserQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 449B19F30FA72ECE0015CA4A /* HTMLParserQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
4614A1FE0B23A8D600446E1C /* copyCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 4614A1FD0B23A8D600446E1C /* copyCursor.png */; };
+ 4617E7B1121E078F005EC8A8 /* AsyncFileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4617E7B0121E078F005EC8A8 /* AsyncFileWriter.h */; };
464EA2730B8A350B00A8E6E3 /* crossHairCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 464EA2710B8A350B00A8E6E3 /* crossHairCursor.png */; };
464EA2740B8A350B00A8E6E3 /* notAllowedCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 464EA2720B8A350B00A8E6E3 /* notAllowedCursor.png */; };
+ 468F5AA4121F1D7400B5C498 /* FileWriterClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 468F5AA3121F1D7400B5C498 /* FileWriterClient.h */; };
46A26905121B6B4300C41F3A /* FileWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A26902121B6B4300C41F3A /* FileWriter.cpp */; };
46A26906121B6B4300C41F3A /* FileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A26903121B6B4300C41F3A /* FileWriter.h */; };
46BD16E30B279473001F0839 /* noneCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46BD16E20B279473001F0839 /* noneCursor.png */; };
46D4F2490AF97E810035385A /* cellCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46D4F2460AF97E810035385A /* cellCursor.png */; };
46D4F24A0AF97E810035385A /* contextMenuCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46D4F2470AF97E810035385A /* contextMenuCursor.png */; };
46D4F24B0AF97E810035385A /* verticalTextCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46D4F2480AF97E810035385A /* verticalTextCursor.png */; };
+ 46DA844D1224A0710060D006 /* JSFileWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46DA844B1224A0710060D006 /* JSFileWriter.cpp */; };
+ 46DA844E1224A0710060D006 /* JSFileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DA844C1224A0710060D006 /* JSFileWriter.h */; };
46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DA0B0D60170028EE36 /* aliasCursor.png */; };
46F9D5DE0B0D60170028EE36 /* noDropCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DB0B0D60170028EE36 /* noDropCursor.png */; };
46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DC0B0D60170028EE36 /* progressCursor.png */; };
@@ -6755,8 +6759,10 @@
449098B10F8F82520076A327 /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
449B19F30FA72ECE0015CA4A /* HTMLParserQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLParserQuirks.h; sourceTree = "<group>"; };
4614A1FD0B23A8D600446E1C /* copyCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = copyCursor.png; sourceTree = "<group>"; };
+ 4617E7B0121E078F005EC8A8 /* AsyncFileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFileWriter.h; sourceTree = "<group>"; };
464EA2710B8A350B00A8E6E3 /* crossHairCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crossHairCursor.png; sourceTree = "<group>"; };
464EA2720B8A350B00A8E6E3 /* notAllowedCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = notAllowedCursor.png; sourceTree = "<group>"; };
+ 468F5AA3121F1D7400B5C498 /* FileWriterClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileWriterClient.h; sourceTree = "<group>"; };
46A26902121B6B4300C41F3A /* FileWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileWriter.cpp; sourceTree = "<group>"; };
46A26903121B6B4300C41F3A /* FileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileWriter.h; sourceTree = "<group>"; };
46A26904121B6B4300C41F3A /* FileWriter.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileWriter.idl; sourceTree = "<group>"; };
@@ -6764,6 +6770,8 @@
46D4F2460AF97E810035385A /* cellCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cellCursor.png; sourceTree = "<group>"; };
46D4F2470AF97E810035385A /* contextMenuCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = contextMenuCursor.png; sourceTree = "<group>"; };
46D4F2480AF97E810035385A /* verticalTextCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = verticalTextCursor.png; sourceTree = "<group>"; };
+ 46DA844B1224A0710060D006 /* JSFileWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileWriter.cpp; sourceTree = "<group>"; };
+ 46DA844C1224A0710060D006 /* JSFileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileWriter.h; sourceTree = "<group>"; };
46F9D5DA0B0D60170028EE36 /* aliasCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = aliasCursor.png; sourceTree = "<group>"; };
46F9D5DB0B0D60170028EE36 /* noDropCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = noDropCursor.png; sourceTree = "<group>"; };
46F9D5DC0B0D60170028EE36 /* progressCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = progressCursor.png; sourceTree = "<group>"; };
@@ -12048,6 +12056,7 @@
49EECDC710503C2300099FAB /* ArrayBufferView.cpp */,
49EECDC810503C2300099FAB /* ArrayBufferView.h */,
49EECDC910503C2300099FAB /* ArrayBufferView.idl */,
+ 4617E7B0121E078F005EC8A8 /* AsyncFileWriter.h */,
6E4E91A710F7FB3100A2779C /* CanvasContextAttributes.cpp */,
6E4E91A810F7FB3100A2779C /* CanvasContextAttributes.h */,
49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */,
@@ -14072,6 +14081,7 @@
895253DE116C4F0600CABF00 /* FileThreadTask.h */,
46A26902121B6B4300C41F3A /* FileWriter.cpp */,
46A26903121B6B4300C41F3A /* FileWriter.h */,
+ 468F5AA3121F1D7400B5C498 /* FileWriterClient.h */,
46A26904121B6B4300C41F3A /* FileWriter.idl */,
A8136D370973A8E700D74463 /* FormDataList.cpp */,
A8136D360973A8E700D74463 /* FormDataList.h */,
@@ -14464,6 +14474,8 @@
BC00F0130E0A189500FD04E3 /* JSFileList.h */,
2E94F439119207DA00B7F75D /* JSFileReader.cpp */,
2E94F43A119207DA00B7F75D /* JSFileReader.h */,
+ 46DA844B1224A0710060D006 /* JSFileWriter.cpp */,
+ 46DA844C1224A0710060D006 /* JSFileWriter.h */,
49EECEF4105070C400099FAB /* JSFloat32Array.cpp */,
49EECEF5105070C400099FAB /* JSFloat32Array.h */,
BC97E410109154FA0010D361 /* JSHTMLAllCollection.cpp */,
@@ -20384,10 +20396,13 @@
46A26906121B6B4300C41F3A /* FileWriter.h in Headers */,
2EF1BFF7121CB0BD00C27627 /* AsyncFileStream.h in Headers */,
2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */,
+ 4617E7B1121E078F005EC8A8 /* AsyncFileWriter.h in Headers */,
+ 468F5AA4121F1D7400B5C498 /* FileWriterClient.h in Headers */,
89C0DD7B121F0C69009E17CA /* FileSystemCallbacks.h in Headers */,
CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
9F0D6B2F121BFEBA006C0288 /* InspectorProfilerAgent.h in Headers */,
2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */,
+ 46DA844E1224A0710060D006 /* JSFileWriter.h in Headers */,
89686CA0122244A00076EAA4 /* DOMFilePath.h in Headers */,
8947A82A12222C4700D95F2D /* JSMetadata.h in Headers */,
8947A82C12222C4700D95F2D /* JSMetadataCallback.h in Headers */,
@@ -22855,6 +22870,7 @@
CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */,
2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */,
+ 46DA844D1224A0710060D006 /* JSFileWriter.cpp in Sources */,
89686C9F122244A00076EAA4 /* DOMFilePath.cpp in Sources */,
8947A82912222C4700D95F2D /* JSMetadata.cpp in Sources */,
8947A82B12222C4700D95F2D /* JSMetadataCallback.cpp in Sources */,
diff --git a/WebCore/html/AsyncFileWriter.h b/WebCore/html/AsyncFileWriter.h
new file mode 100644
index 0000000..cdb815c
--- /dev/null
+++ b/WebCore/html/AsyncFileWriter.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AsyncFileWriter_h
+#define AsyncFileWriter_h
+
+#if ENABLE(FILE_WRITER)
+
+#include "PlatformString.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Blob;
+class FileWriterClient;
+
+class AsyncFileWriter {
+public:
+ virtual ~AsyncFileWriter() {}
+
+ virtual void setFileWriterClient(FileWriterClient* client) = 0;
+
+ virtual void write(long long position, Blob* data) = 0;
+ virtual void truncate(long long length) = 0;
+ virtual void abort() = 0;
+};
+
+} // namespace
+
+#endif // ENABLE(FILE_WRITER)
+
+#endif // AsyncFileWriter_h
+
diff --git a/WebCore/html/FileWriter.cpp b/WebCore/html/FileWriter.cpp
index 7d112e2..7ead354 100644
--- a/WebCore/html/FileWriter.cpp
+++ b/WebCore/html/FileWriter.cpp
@@ -34,20 +34,40 @@
#include "FileWriter.h"
+#include "AsyncFileWriter.h"
+#include "Blob.h"
+#include "ExceptionCode.h"
+#include "FileError.h"
+#include "ProgressEvent.h"
+
namespace WebCore {
FileWriter::FileWriter(ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
+ , m_readyState(INIT)
+ , m_position(0)
+ , m_bytesWritten(0)
+ , m_bytesToWrite(0)
+{
+}
+
+void FileWriter::initialize(PassOwnPtr<AsyncFileWriter> writer, long long length)
{
+ ASSERT(!m_writer);
+ ASSERT(length >= 0);
+ m_writer = writer;
+ m_length = length;
}
FileWriter::~FileWriter()
{
+ if (m_readyState == WRITING)
+ stop();
}
bool FileWriter::hasPendingActivity() const
{
- return false;
+ return m_readyState == WRITING || ActiveDOMObject::hasPendingActivity();
}
bool FileWriter::canSuspend() const
@@ -58,27 +78,120 @@ bool FileWriter::canSuspend() const
void FileWriter::stop()
{
+ if (m_writer && m_readyState == WRITING)
+ m_writer->abort();
+ m_readyState = DONE;
+}
+
+void FileWriter::write(Blob* data, ExceptionCode& ec)
+{
+ ASSERT(m_writer);
+ if (m_readyState == WRITING) {
+ ec = INVALID_STATE_ERR;
+ m_error = FileError::create(ec);
+ return;
+ }
+
+ m_readyState = WRITING;
+ m_bytesWritten = 0;
+ m_bytesToWrite = data->size();
+ fireEvent(eventNames().writestartEvent);
+ m_writer->write(m_position, data);
+}
+
+void FileWriter::seek(long long position, ExceptionCode& ec)
+{
+ ASSERT(m_writer);
+ if (m_readyState == WRITING) {
+ ec = INVALID_STATE_ERR;
+ m_error = FileError::create(ec);
+ return;
+ }
+
+ m_bytesWritten = 0;
+ m_bytesToWrite = 0;
+ if (position > m_length)
+ position = m_length;
+ else if (position < 0)
+ position = m_length + position;
+ if (position < 0)
+ position = 0;
+ m_position = position;
+}
+
+void FileWriter::truncate(long long position, ExceptionCode& ec)
+{
+ ASSERT(m_writer);
+ if (m_readyState == WRITING || position >= m_length) {
+ ec = INVALID_STATE_ERR;
+ m_error = FileError::create(ec);
+ return;
+ }
+ m_readyState = WRITING;
+ m_bytesWritten = 0;
+ m_bytesToWrite = 0;
+ fireEvent(eventNames().writestartEvent);
+ m_writer->truncate(position);
}
-void FileWriter::write(Blob*)
+void FileWriter::abort(ExceptionCode& ec)
{
+ ASSERT(m_writer);
+ if (m_readyState != WRITING) {
+ ec = INVALID_STATE_ERR;
+ m_error = FileError::create(ec);
+ return;
+ }
+ m_error = FileError::create(ABORT_ERR);
+ m_readyState = DONE;
+ fireEvent(eventNames().errorEvent);
+ fireEvent(eventNames().abortEvent);
+ fireEvent(eventNames().writeendEvent);
+ m_writer->abort();
}
-void FileWriter::seek(long long)
+void FileWriter::didWrite(long long bytes, bool complete)
{
+ ASSERT(bytes > 0);
+ ASSERT(bytes + m_bytesWritten > 0);
+ ASSERT(bytes + m_bytesWritten <= m_bytesToWrite);
+ m_bytesWritten += bytes;
+ ASSERT((m_bytesWritten == m_bytesToWrite) == complete);
+ m_position += bytes;
+ if (m_position > m_length)
+ m_length = m_position;
+ if (complete)
+ m_readyState = DONE;
+ fireEvent(eventNames().writeEvent);
+ if (complete)
+ fireEvent(eventNames().writeendEvent);
}
-void FileWriter::truncate(long long)
+void FileWriter::didTruncate(long long length)
{
+ ASSERT(length > 0);
+ ASSERT(length >= 0);
+ ASSERT(length < m_length);
+ m_length = length;
+ if (m_position > m_length)
+ m_position = m_length;
+ m_readyState = DONE;
+ fireEvent(eventNames().writeEvent);
+ fireEvent(eventNames().writeendEvent);
}
-void FileWriter::abort()
+void FileWriter::didFail(ExceptionCode ec)
{
+ m_error = FileError::create(ec);
+ m_readyState = DONE;
+ fireEvent(eventNames().errorEvent);
+ fireEvent(eventNames().writeendEvent);
}
-FileWriter::ReadyState FileWriter::readyState() const
+void FileWriter::fireEvent(const AtomicString& type)
{
- return EMPTY;
+ // FIXME: the current ProgressEvent uses "unsigned long" for total and loaded attributes. Need to talk with the spec writer to resolve the issue.
+ dispatchEvent(ProgressEvent::create(type, true, static_cast<unsigned>(m_bytesWritten), static_cast<unsigned>(m_bytesToWrite)));
}
} // namespace WebCore
diff --git a/WebCore/html/FileWriter.h b/WebCore/html/FileWriter.h
index fd5babf..b0af7ea 100644
--- a/WebCore/html/FileWriter.h
+++ b/WebCore/html/FileWriter.h
@@ -35,44 +35,54 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
+#include "FileWriterClient.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
+class AsyncFileWriter;
class Blob;
class FileError;
class ScriptExecutionContext;
-// FIXME: This is an empty, do-nothing placeholder for implementation yet to come.
-class FileWriter : public RefCounted<FileWriter>, public ActiveDOMObject, public EventTarget {
+class FileWriter : public RefCounted<FileWriter>, public ActiveDOMObject, public EventTarget, public FileWriterClient {
public:
static PassRefPtr<FileWriter> create(ScriptExecutionContext* context)
{
return adoptRef(new FileWriter(context));
}
+ void initialize(PassOwnPtr<AsyncFileWriter> writer, long long length);
+
enum ReadyState {
- EMPTY = 0,
+ INIT = 0,
WRITING = 1,
DONE = 2
};
- void write(Blob*);
- void seek(long long position);
- void truncate(long long length);
- void abort();
+ void write(Blob* data, ExceptionCode& ec);
+ void seek(long long position, ExceptionCode& ec);
+ void truncate(long long length, ExceptionCode& ec);
+ void abort(ExceptionCode& ec);
+
+ ReadyState readyState() const { return m_readyState; }
+ FileError* error() const { return m_error.get(); }
+ long long position() const { return m_position; }
+ long long length() const { return m_length; }
- ReadyState readyState() const;
- FileError* error() const { return m_error; };
- long long position() const { return 0; };
- long long length() const { return 0; };
+ // FileWriterClient
+ void didWrite(long long bytes, bool complete);
+ void didTruncate(long long length);
+ void didFail(ExceptionCode ec);
// ActiveDOMObject
virtual bool canSuspend() const;
- virtual void stop();
virtual bool hasPendingActivity() const;
+ virtual void stop();
// EventTarget
virtual FileWriter* toFileWriter() { return this; }
@@ -87,7 +97,7 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
DEFINE_ATTRIBUTE_EVENT_LISTENER(writeend);
-
+
private:
FileWriter(ScriptExecutionContext*);
@@ -101,8 +111,16 @@ private:
virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
- RefPtr<FileError*> m_error;
+ void fireEvent(const AtomicString& type);
+
+ RefPtr<FileError> m_error;
EventTargetData m_eventTargetData;
+ OwnPtr<AsyncFileWriter> m_writer;
+ ReadyState m_readyState;
+ long long m_position;
+ long long m_length;
+ long long m_bytesWritten;
+ long long m_bytesToWrite;
};
} // namespace WebCore
diff --git a/WebCore/html/FileWriterClient.h b/WebCore/html/FileWriterClient.h
new file mode 100644
index 0000000..091b1c1
--- /dev/null
+++ b/WebCore/html/FileWriterClient.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FileWriterClient_h
+#define FileWriterClient_h
+
+#if ENABLE(FILE_WRITER)
+
+#include "ExceptionCode.h"
+
+namespace WebCore {
+
+class FileWriterClient {
+public:
+ virtual ~FileWriterClient() {}
+
+ virtual void didWrite(long long bytes, bool complete) = 0;
+ virtual void didTruncate(long long position) = 0;
+ virtual void didFail(ExceptionCode) = 0;
+};
+
+} // namespace
+
+#endif // ENABLE(FILE_WRITER)
+
+#endif // FileWriterClient_h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list