WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-37217-20100407103554.patch (text/plain), 16.37 KB, created by
Kinuko Yasuda
on 2010-04-07 10:35:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Kinuko Yasuda
Created:
2010-04-07 10:35:55 PDT
Size:
16.37 KB
patch
obsolete
>diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index ab034d0..15a4285 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,43 @@ >+2010-04-07 Kinuko Yasuda <kinuko@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add skeleton FileStream module for providing sync file operations for FileAPI >+ https://bugs.webkit.org/show_bug.cgi?id=37217 >+ For now the module just defines interfaces and is almost empty. >+ Implementations will be added later. >+ >+ No new tests; will be added when we have complete cimplementation. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * html/FileStream.cpp: Added. >+ (WebCore::FileStream::FileStream): >+ (WebCore::FileStream::~FileStream): >+ (WebCore::FileStream::start): >+ (WebCore::FileStream::openForRead): >+ (WebCore::FileStream::openForWrite): >+ (WebCore::FileStream::close): >+ (WebCore::FileStream::read): >+ (WebCore::FileStream::write): >+ (WebCore::FileStream::truncate): >+ * html/FileStream.h: Added. >+ (WebCore::FileStream::create): >+ * html/FileStreamClient.h: Added. >+ (WebCore::FileStreamClient::didRead): >+ (WebCore::FileStreamClient::didWrite): >+ (WebCore::FileStreamClient::didStart): >+ (WebCore::FileStreamClient::didFinish): >+ (WebCore::FileStreamClient::didFail): >+ (WebCore::FileStreamClient::didGetSize): >+ (WebCore::FileStreamClient::~FileStreamClient): >+ * html/FileThread.cpp: >+ (WebCore::SameFilePredicate::SameFilePredicate): >+ (WebCore::SameFilePredicate::operator()): >+ (WebCore::FileThread::unscheduleTasks): >+ * html/FileThread.h: >+ (WebCore::FileThread::Task::stream): >+ (WebCore::FileThread::Task::Task): >+ > 2010-04-06 Andy Estes <aestes@apple.com> > > Rubber-stamped by Dan Bernstein. >diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj >index be01fb8..7814d9f 100644 >--- a/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2211,6 +2211,9 @@ > 85FF315B0AAFBFCB00374F38 /* DOMKeyboardEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */; }; > 8952535211641B3400CABF00 /* FileThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8952535011641B3400CABF00 /* FileThread.cpp */; }; > 8952535311641B3400CABF00 /* FileThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 8952535111641B3400CABF00 /* FileThread.h */; }; >+ 895253D7116C4C6800CABF00 /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 895253D4116C4C6800CABF00 /* FileStream.cpp */; }; >+ 895253D8116C4C6800CABF00 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 895253D5116C4C6800CABF00 /* FileStream.h */; }; >+ 895253D9116C4C6800CABF00 /* FileStreamClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 895253D6116C4C6800CABF00 /* FileStreamClient.h */; }; > 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */; }; > 9302B0BF0D79F82C00C7EE83 /* PageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 9305B24D098F1B6B00C28855 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9305B24C098F1B6B00C28855 /* Timer.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -7664,6 +7667,9 @@ > 85FF31590AAFBFCB00374F38 /* DOMKeyboardEvent.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMKeyboardEvent.mm; sourceTree = "<group>"; }; > 8952535011641B3400CABF00 /* FileThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileThread.cpp; sourceTree = "<group>"; }; > 8952535111641B3400CABF00 /* FileThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileThread.h; sourceTree = "<group>"; }; >+ 895253D4116C4C6800CABF00 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStream.cpp; sourceTree = "<group>"; }; >+ 895253D5116C4C6800CABF00 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = "<group>"; }; >+ 895253D6116C4C6800CABF00 /* FileStreamClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStreamClient.h; sourceTree = "<group>"; }; > 9302B0BC0D79F82900C7EE83 /* PageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroup.cpp; sourceTree = "<group>"; }; > 9302B0BE0D79F82C00C7EE83 /* PageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroup.h; sourceTree = "<group>"; }; > 9305B24C098F1B6B00C28855 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = "<group>"; }; >@@ -12953,6 +12959,9 @@ > 93EEC1EC09C2877700C515D1 /* html */ = { > isa = PBXGroup; > children = ( >+ 895253D4116C4C6800CABF00 /* FileStream.cpp */, >+ 895253D5116C4C6800CABF00 /* FileStream.h */, >+ 895253D6116C4C6800CABF00 /* FileStreamClient.h */, > 8952535011641B3400CABF00 /* FileThread.cpp */, > 8952535111641B3400CABF00 /* FileThread.h */, > 49484FAE102CF01E00187DD3 /* canvas */, >@@ -18814,6 +18823,8 @@ > 8952535311641B3400CABF00 /* FileThread.h in Headers */, > 97C078501165D5BE003A32EF /* SuffixTree.h in Headers */, > 2542F4DB1166C25A00E89A86 /* UserGestureIndicator.h in Headers */, >+ 895253D8116C4C6800CABF00 /* FileStream.h in Headers */, >+ 895253D9116C4C6800CABF00 /* FileStreamClient.h in Headers */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >@@ -21034,6 +21045,7 @@ > 2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */, > 8952535211641B3400CABF00 /* FileThread.cpp in Sources */, > 2542F4DA1166C25A00E89A86 /* UserGestureIndicator.cpp in Sources */, >+ 895253D7116C4C6800CABF00 /* FileStream.cpp in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >diff --git a/WebCore/html/FileStream.cpp b/WebCore/html/FileStream.cpp >new file mode 100644 >index 0000000..53c992c >--- /dev/null >+++ b/WebCore/html/FileStream.cpp >@@ -0,0 +1,98 @@ >+/* >+ * 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. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) >+ >+#include "FileStream.h" >+ >+#include "Blob.h" >+#include "PlatformString.h" >+ >+namespace WebCore { >+ >+FileStream::FileStream(FileStreamClient* client) >+ : m_client(client) >+ , m_handle(invalidPlatformFileHandle) >+{ >+} >+ >+FileStream::~FileStream() >+{ >+ ASSERT(!isHandleValid(m_handle)); >+} >+ >+void FileStream::start() >+{ >+ ASSERT(!isMainThread()); >+ m_client->didStart(); >+} >+ >+void FileStream::openForRead(Blob*) >+{ >+ ASSERT(!isMainThread()); >+ // FIXME: to be implemented. >+} >+ >+void FileStream::openForWrite(const String&) >+{ >+ ASSERT(!isMainThread()); >+ // FIXME: to be implemented. >+} >+ >+void FileStream::close() >+{ >+ ASSERT(!isMainThread()); >+ if (isHandleValid(m_handle)) >+ closeFile(m_handle); >+} >+ >+void FileStream::read(char*, int) >+{ >+ ASSERT(!isMainThread()); >+ // FIXME: to be implemented. >+} >+ >+void FileStream::write(Blob*, long long, int) >+{ >+ ASSERT(!isMainThread()); >+ // FIXME: to be implemented. >+} >+ >+void FileStream::truncate(long long) >+{ >+ ASSERT(!isMainThread()); >+ // FIXME: to be implemented. >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(FILE_WRITER) || ENABLE_FILE_READER) >diff --git a/WebCore/html/FileStream.h b/WebCore/html/FileStream.h >new file mode 100644 >index 0000000..ba7c056 >--- /dev/null >+++ b/WebCore/html/FileStream.h >@@ -0,0 +1,75 @@ >+/* >+ * 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 FileStream_h >+#define FileStream_h >+ >+#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) >+ >+#include "FileStreamClient.h" >+#include "FileSystem.h" >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+class Blob; >+class String; >+ >+// All methods are synchronous and should be called on File or Worker thread. >+class FileStream : public RefCounted<FileStream> { >+public: >+ static PassRefPtr<FileStream> create(FileStreamClient* client) >+ { >+ return adoptRef(new FileStream(client)); >+ } >+ virtual ~FileStream(); >+ >+ void start(); >+ >+ void openForRead(Blob*); >+ void openForWrite(const String& path); >+ void close(); >+ void read(char* buffer, int length); >+ void write(Blob* blob, long long position, int length); >+ void truncate(long long position); >+ >+private: >+ FileStream(FileStreamClient*); >+ >+ FileStreamClient* m_client; >+ PlatformFileHandle m_handle; >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(FILE_READER) || ENABLE(FILE_WRITER) >+ >+#endif // FileStream_h >diff --git a/WebCore/html/FileStreamClient.h b/WebCore/html/FileStreamClient.h >new file mode 100644 >index 0000000..9d24bdf >--- /dev/null >+++ b/WebCore/html/FileStreamClient.h >@@ -0,0 +1,63 @@ >+/* >+ * 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 FileStreamClient_h >+#define FileStreamClient_h >+ >+#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) >+ >+#include "ExceptionCode.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebCore { >+ >+class FileStreamClient { >+public: >+ // For reading. >+ virtual void didRead(const char*, int) { } >+ >+ // For writing. >+ virtual void didWrite(int) { } >+ >+ // For both reading and writing. >+ virtual void didStart() { } >+ virtual void didFinish() { } >+ virtual void didFail(ExceptionCode) { } >+ virtual void didGetSize(long long) { } >+ >+protected: >+ virtual ~FileStreamClient() { } >+}; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(FILE_READER) || ENABLE(FILE_WRITER) >+ >+#endif // FileStreamClient_h >diff --git a/WebCore/html/FileThread.cpp b/WebCore/html/FileThread.cpp >index 90b66e8..02b1718 100644 >--- a/WebCore/html/FileThread.cpp >+++ b/WebCore/html/FileThread.cpp >@@ -71,15 +71,15 @@ void FileThread::postTask(PassOwnPtr<Task> task) > > class SameFilePredicate { > public: >- SameFilePredicate(const PlatformFileHandle handle) : m_handle(handle) { } >- bool operator()(FileThread::Task* task) const { return task->fileHandle() == m_handle; } >+ SameFilePredicate(const FileStream* stream) : m_stream(stream) { } >+ bool operator()(FileThread::Task* task) const { return task->stream() == m_stream; } > private: >- PlatformFileHandle m_handle; >+ const FileStream* m_stream; > }; > >-void FileThread::removeTask(PlatformFileHandle handle) >+void FileThread::unscheduleTasks(const FileStream* stream) > { >- SameFilePredicate predicate(handle); >+ SameFilePredicate predicate(stream); > m_queue.removeIf(predicate); > } > >diff --git a/WebCore/html/FileThread.h b/WebCore/html/FileThread.h >index ea93cc3..d27273a 100644 >--- a/WebCore/html/FileThread.h >+++ b/WebCore/html/FileThread.h >@@ -33,7 +33,6 @@ > > #if ENABLE(FILE_WRITER) || ENABLE(FILE_READER) > >-#include "FileSystem.h" > #include <wtf/MessageQueue.h> > #include <wtf/PassOwnPtr.h> > #include <wtf/PassRefPtr.h> >@@ -41,6 +40,8 @@ > > namespace WebCore { > >+class FileStream; >+ > class FileThread : public ThreadSafeShared<FileThread> { > public: > static PassRefPtr<FileThread> create() { return adoptRef(new FileThread()); } >@@ -53,14 +54,14 @@ public: > public: > virtual ~Task() { } > virtual void performTask() = 0; >- PlatformFileHandle fileHandle() const { return m_handle; } >+ FileStream* stream() const { return m_stream; } > protected: >- Task(PlatformFileHandle handle) : m_handle(handle) { } >- const PlatformFileHandle m_handle; >+ Task(FileStream* stream) : m_stream(stream) { } >+ FileStream* m_stream; > }; > > void postTask(PassOwnPtr<Task> task); >- void removeTask(PlatformFileHandle); >+ void unscheduleTasks(const FileStream*); > > private: > FileThread();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 37217
:
52750
|
52759