Diff
Modified: trunk/Source/WTF/ChangeLog (175781 => 175782)
--- trunk/Source/WTF/ChangeLog 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WTF/ChangeLog 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,3 +1,23 @@
+2014-11-08 Darin Adler <da...@apple.com>
+
+ Replace FileThread class with a single function
+ https://bugs.webkit.org/show_bug.cgi?id=138282
+
+ Reviewed by Alexey Proskuryakov.
+
+ * wtf/MessageQueue.h: Made queue work on any type and not require wrapping
+ everything in a unique_ptr.
+
+ * wtf/Threading.cpp:
+ (WTF::threadEntryPoint): Changed to use a std::function instead of a function pointer.
+ (WTF::createThread): Add a version that takes a std::function. Reimplemented the
+ old version using lambdas. Removed the obsolete versions that were there just to support
+ binary compatibility with very old versions of Safari.
+
+ * wtf/Threading.h: Removed an incorrect license header that covers code that was long ago
+ moved to a different file. Changed createThread to take a std::function instead of a function
+ pointer and data pointer. Moved internal functions after public functions.
+
2014-11-05 Chris Dumez <cdu...@apple.com>
Assertion hit DOMTimer::updateTimerIntervalIfNecessary()
Modified: trunk/Source/WTF/wtf/Threading.cpp (175781 => 175782)
--- trunk/Source/WTF/wtf/Threading.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WTF/wtf/Threading.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,23 +33,14 @@
struct NewThreadContext {
WTF_MAKE_FAST_ALLOCATED;
public:
- NewThreadContext(ThreadFunction entryPoint, void* data, const char* name)
- : entryPoint(entryPoint)
- , data(data)
- , name(name)
- {
- }
-
- ThreadFunction entryPoint;
- void* data;
const char* name;
-
+ std::function<void()> entryPoint;
Mutex creationMutex;
};
static void threadEntryPoint(void* contextData)
{
- NewThreadContext* context = reinterpret_cast<NewThreadContext*>(contextData);
+ NewThreadContext* context = static_cast<NewThreadContext*>(contextData);
// Block until our creating thread has completed any extra setup work, including
// establishing ThreadIdentifier.
@@ -59,15 +50,15 @@
initializeCurrentThreadInternal(context->name);
- // Grab the info that we need out of the context, then deallocate it.
- ThreadFunction entryPoint = context->entryPoint;
- void* data = ""
+ auto entryPoint = WTF::move(context->entryPoint);
+
+ // Delete the context before starting the thread.
delete context;
- entryPoint(data);
+ entryPoint();
}
-ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* name)
+ThreadIdentifier createThread(const char* name, std::function<void()> entryPoint)
{
// Visual Studio has a 31-character limit on thread names. Longer names will
// be truncated silently, but we'd like callers to know about the limit.
@@ -76,7 +67,7 @@
LOG_ERROR("Thread name \"%s\" is longer than 31 characters and will be truncated by Visual Studio", name);
#endif
- NewThreadContext* context = new NewThreadContext(entryPoint, data, name);
+ NewThreadContext* context = new NewThreadContext { name, WTF::move(entryPoint), { } };
// Prevent the thread body from executing until we've established the thread identifier.
MutexLocker locker(context->creationMutex);
@@ -84,6 +75,13 @@
return createThreadInternal(threadEntryPoint, context, name);
}
+ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* name)
+{
+ return createThread(name, [entryPoint, data] {
+ entryPoint(data);
+ });
+}
+
void setCurrentThreadIsUserInteractive()
{
#if HAVE(QOS_CLASSES)
@@ -98,61 +96,4 @@
#endif
}
-#if PLATFORM(MAC) || PLATFORM(WIN)
-
-// For ABI compatibility with Safari on Mac / Windows: Safari uses the private
-// createThread() and waitForThreadCompletion() functions directly and we need
-// to keep the old ABI compatibility until it's been rebuilt.
-
-typedef void* (*ThreadFunctionWithReturnValue)(void* argument);
-
-WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data, const char* name);
-
-struct ThreadFunctionWithReturnValueInvocation {
- ThreadFunctionWithReturnValueInvocation(ThreadFunctionWithReturnValue function, void* data)
- : function(function)
- , data(data)
- {
- }
-
- ThreadFunctionWithReturnValue function;
- void* data;
-};
-
-static void compatEntryPoint(void* param)
-{
- // Balanced by .release() in createThread.
- auto invocation = std::unique_ptr<ThreadFunctionWithReturnValueInvocation>(static_cast<ThreadFunctionWithReturnValueInvocation*>(param));
- invocation->function(invocation->data);
-}
-
-ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data, const char* name)
-{
- auto invocation = std::make_unique<ThreadFunctionWithReturnValueInvocation>(entryPoint, data);
-
- // Balanced by std::unique_ptr constructor in compatEntryPoint.
- return createThread(compatEntryPoint, invocation.release(), name);
-}
-
-WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier, void**);
-
-int waitForThreadCompletion(ThreadIdentifier threadID, void**)
-{
- return waitForThreadCompletion(threadID);
-}
-
-// This function is deprecated but needs to be kept around for backward
-// compatibility. Use the 3-argument version of createThread above.
-
-WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data);
-
-ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data)
-{
- auto invocation = std::make_unique<ThreadFunctionWithReturnValueInvocation>(entryPoint, data);
-
- // Balanced by adoptPtr() in compatEntryPoint.
- return createThread(compatEntryPoint, invocation.release(), 0);
-}
-#endif
-
} // namespace WTF
Modified: trunk/Source/WTF/wtf/Threading.h (175781 => 175782)
--- trunk/Source/WTF/wtf/Threading.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WTF/wtf/Threading.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2010, 2014 Apple Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhayg...@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
@@ -25,40 +25,16 @@
* 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.
- *
- *
- * Note: The implementations of InterlockedIncrement and InterlockedDecrement are based
- * on atomic_increment and atomic_exchange_and_add from the Boost C++ Library. The license
- * is virtually identical to the Apple license above but is included here for completeness.
- *
- * Boost Software License - Version 1.0 - August 17th, 2003
- *
- * Permission is hereby granted, free of charge, to any person or organization
- * obtaining a copy of the software and accompanying documentation covered by
- * this license (the "Software") to use, reproduce, display, distribute,
- * execute, and transmit the Software, and to prepare derivative works of the
- * Software, and to permit third-parties to whom the Software is furnished to
- * do so, all subject to the following:
- *
- * The copyright notices in the Software and this entire statement, including
- * the above license grant, this restriction and the following disclaimer,
- * must be included in all copies of the Software, in whole or in part, and
- * all derivative works of the Software, unless such copies or derivative
- * works are solely in the form of machine-executable object code generated by
- * a source language processor.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
*/
#ifndef Threading_h
#define Threading_h
+// FIXME: Not sure why there are so many includes here.
+// Is this intended to be convenience so that others don't have to include the individual files?
+// Nothing in this header depends on Assertions, Atomics, Locker, Noncopyable, ThreadSafeRefCounted, or ThreadingPrimitives.
+
+#include <functional>
#include <stdint.h>
#include <wtf/Assertions.h>
#include <wtf/Atomics.h>
@@ -79,13 +55,20 @@
// Returns 0 if thread creation failed.
// The thread name must be a literal since on some platforms it's passed in to the thread.
-WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(const char* threadName, std::function<void()>);
// Mark the current thread as requiring UI responsiveness.
WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive();
-
WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInitiated();
+WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
+WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int);
+WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
+WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
+
+// Deprecated function-pointer-based thread creation.
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
+
// Internal platform-specific createThread implementation.
ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadName);
@@ -93,11 +76,6 @@
// Helpful for platforms where the thread name must be set from within the thread.
void initializeCurrentThreadInternal(const char* threadName);
-WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
-WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int);
-WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
-WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
-
} // namespace WTF
using WTF::ThreadIdentifier;
Modified: trunk/Source/WebCore/CMakeLists.txt (175781 => 175782)
--- trunk/Source/WebCore/CMakeLists.txt 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/CMakeLists.txt 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1505,7 +1505,6 @@
fileapi/FileReader.cpp
fileapi/FileReaderLoader.cpp
fileapi/FileReaderSync.cpp
- fileapi/FileThread.cpp
fileapi/ThreadableBlobRegistry.cpp
fileapi/WebKitBlobBuilder.cpp
Modified: trunk/Source/WebCore/ChangeLog (175781 => 175782)
--- trunk/Source/WebCore/ChangeLog 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/ChangeLog 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,3 +1,77 @@
+2014-11-08 Darin Adler <da...@apple.com>
+
+ Replace FileThread class with a single function
+ https://bugs.webkit.org/show_bug.cgi?id=138282
+
+ Reviewed by Alexey Proskuryakov.
+
+ * CMakeLists.txt: Removed FileThread.cpp.
+
+ * WebCore.vcxproj/WebCore.vcxproj: Removed FileThread.cpp/.h.
+ * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+
+ * bindings/generic/ActiveDOMCallback.cpp: Removed unneeded includes.
+ * dom/ActiveDOMObject.cpp: Ditto.
+
+ * fileapi/AsyncFileStream.cpp:
+ (WebCore::callOnFileThread): Added. Implements the file thread.
+ (WebCore::AsyncFileStream::AsyncFileStream): Take a reference to the client.
+ Make m_internals. Use the destroyed flag instead of trickier techniques to
+ handle stopping. Once the stream is destroyed, there will be no further callbacks.
+ (WebCore::AsyncFileStream::~AsyncFileStream): Added assertions and merged in the
+ stop behavior here. This class no longer requires an explicit stop function.
+ (WebCore::AsyncFileStream::perform): Added. Helper used for all the operations
+ below. Takes a function that performs an operation and then returns a client
+ callback function. Respects the m_stopped boolean on the file thread (so we
+ don't do extra operations) and on the client thread (so we are guaranteed not
+ to get any client callbacks even if the file thread was partway through an
+ operation).
+ (WebCore::AsyncFileStream::getSize): Changed to use the perform function.
+ (WebCore::AsyncFileStream::openForRead): Ditto. Also fixed reference count
+ thread safety issue by capturing a StringCapture rather than a String.
+ (WebCore::AsyncFileStream::openForWrite): Ditto.
+ (WebCore::AsyncFileStream::close): Changed to use callOnFileThread.
+ (WebCore::AsyncFileStream::read): Changed to use the perform function.
+ (WebCore::AsyncFileStream::write): Ditto. Also fixed reference count
+ thread safety issue by capturing a StringCapture rather than a URL.
+ (WebCore::AsyncFileStream::truncate): Ditto.
+
+ * fileapi/AsyncFileStream.h: Removed use of RefCounted since we only need
+ single ownership. Removed the stop function, since we can now stop when
+ the stream is destroyed since we have single ownership. Made a new Internals
+ object to handle destruction while operations are still going on the file thread.
+
+ * fileapi/FileThread.cpp: Removed.
+ * fileapi/FileThread.h: Removed.
+
+ * loader/ResourceLoader.cpp: Removed unneeded include.
+
+ * platform/FileStream.cpp:
+ (WebCore::FileStream::~FileStream): Merged the stop function in here.
+
+ * platform/FileStream.h: Removed use of RefCounted since we only need
+ single ownership. Removed the empty start function. Removed the stop function,
+ since we can now stop when the stream is destroyed since we have single ownership.
+
+ * platform/FileStreamClient.h: Removed unneeded didStart and didStop.
+
+ * platform/network/BlobResourceHandle.cpp:
+ (WebCore::BlobResourceHandle::BlobResourceHandle): Use make_unique to make the
+ stream objects instead of custom create functions.
+ (WebCore::BlobResourceHandle::~BlobResourceHandle): Removed now-unneeded code
+ to call stop functions. Destroying the objects now takes care of the this, and
+ that's done by the unique_ptrs.
+ (WebCore::BlobResourceHandle::cancel): Removed the rest of the code to stop the
+ m_asyncStream, keeping only the code that sets it to null. That now stops the
+ stream by destroying it.
+
+ * platform/network/BlobResourceHandle.h: Use std::unique_ptr rather than
+ RefPtr for the file stream objects.
+
+ * storage/StorageThread.h: Tweaked formatting of std::function<void()> to
+ match the format used elsewhere in WebKit.
+
2014-11-08 Simon Fraser <simon.fra...@apple.com>
Don't try to schedule a GraphicsLayer flush when propagating changes to replicas inside a flush
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (175781 => 175782)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-11-09 01:01:22 UTC (rev 175782)
@@ -14935,7 +14935,6 @@
<ClCompile Include="..\fileapi\FileReader.cpp" />
<ClCompile Include="..\fileapi\FileReaderLoader.cpp" />
<ClCompile Include="..\fileapi\FileReaderSync.cpp" />
- <ClCompile Include="..\fileapi\FileThread.cpp" />
<ClCompile Include="..\html\FormAssociatedElement.cpp" />
<ClCompile Include="..\html\FormController.cpp" />
<ClCompile Include="..\html\FormDataList.cpp" />
@@ -20714,7 +20713,6 @@
<ClInclude Include="..\fileapi\FileReaderLoader.h" />
<ClInclude Include="..\fileapi\FileReaderLoaderClient.h" />
<ClInclude Include="..\fileapi\FileReaderSync.h" />
- <ClInclude Include="..\fileapi\FileThread.h" />
<ClInclude Include="..\html\FormAssociatedElement.h" />
<ClInclude Include="..\html\FormController.h" />
<ClInclude Include="..\html\FormDataList.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (175781 => 175782)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2014-11-09 01:01:22 UTC (rev 175782)
@@ -3717,9 +3717,6 @@
<ClCompile Include="..\fileapi\FileReaderSync.cpp">
<Filter>html</Filter>
</ClCompile>
- <ClCompile Include="..\fileapi\FileThread.cpp">
- <Filter>html</Filter>
- </ClCompile>
<ClCompile Include="..\html\FormAssociatedElement.cpp">
<Filter>html</Filter>
</ClCompile>
@@ -10869,9 +10866,6 @@
<ClInclude Include="..\fileapi\FileReaderSync.h">
<Filter>html</Filter>
</ClInclude>
- <ClInclude Include="..\fileapi\FileThread.h">
- <Filter>html</Filter>
- </ClInclude>
<ClInclude Include="..\html\FormAssociatedElement.h">
<Filter>html</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (175781 => 175782)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-11-09 01:01:22 UTC (rev 175782)
@@ -3475,8 +3475,6 @@
976D6C86122B8A3D001FD1F7 /* FileList.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C67122B8A3D001FD1F7 /* FileList.h */; };
976D6C88122B8A3D001FD1F7 /* FileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C69122B8A3D001FD1F7 /* FileReader.cpp */; };
976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C6A122B8A3D001FD1F7 /* FileReader.h */; };
- 976D6C8D122B8A3D001FD1F7 /* FileThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */; };
- 976D6C8E122B8A3D001FD1F7 /* FileThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C6F122B8A3D001FD1F7 /* FileThread.h */; };
976D6C94122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */; };
976D6C95122B8A3D001FD1F7 /* ThreadableBlobRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */; };
976F36EA14686225005E93B4 /* SecurityContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976F36E814686225005E93B4 /* SecurityContext.cpp */; };
@@ -10641,8 +10639,6 @@
976D6C67122B8A3D001FD1F7 /* FileList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileList.h; path = fileapi/FileList.h; sourceTree = "<group>"; };
976D6C69122B8A3D001FD1F7 /* FileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileReader.cpp; path = fileapi/FileReader.cpp; sourceTree = "<group>"; };
976D6C6A122B8A3D001FD1F7 /* FileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileReader.h; path = fileapi/FileReader.h; sourceTree = "<group>"; };
- 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileThread.cpp; path = fileapi/FileThread.cpp; sourceTree = "<group>"; };
- 976D6C6F122B8A3D001FD1F7 /* FileThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileThread.h; path = fileapi/FileThread.h; sourceTree = "<group>"; };
976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadableBlobRegistry.cpp; path = fileapi/ThreadableBlobRegistry.cpp; sourceTree = "<group>"; };
976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadableBlobRegistry.h; path = fileapi/ThreadableBlobRegistry.h; sourceTree = "<group>"; };
976F36E814686225005E93B4 /* SecurityContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityContext.cpp; sourceTree = "<group>"; };
@@ -18229,8 +18225,6 @@
2EDF369A122C94B4002F7D4E /* FileReaderSync.cpp */,
2EDF369B122C94B4002F7D4E /* FileReaderSync.h */,
E1AB1EBD14E9E3A800449E13 /* FileReaderSync.idl */,
- 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */,
- 976D6C6F122B8A3D001FD1F7 /* FileThread.h */,
976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */,
976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */,
976D6C5C122B8A3D001FD1F7 /* WebKitBlobBuilder.cpp */,
@@ -24324,7 +24318,6 @@
2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */,
514B3F730C722047000530DF /* FileSystem.h in Headers */,
26C17A3E1491D2D400D12BA2 /* FileSystemIOS.h in Headers */,
- 976D6C8E122B8A3D001FD1F7 /* FileThread.h in Headers */,
BC5EB69F0E81DAEB00B25965 /* FillLayer.h in Headers */,
845E72F80FD261EE00A87D79 /* Filter.h in Headers */,
08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */,
@@ -27820,7 +27813,6 @@
26C17A3F1491D2D400D12BA2 /* FileSystemIOS.mm in Sources */,
514B3F760C722055000530DF /* FileSystemMac.mm in Sources */,
5160300B0CC4251200C8AC25 /* FileSystemPOSIX.cpp in Sources */,
- 976D6C8D122B8A3D001FD1F7 /* FileThread.cpp in Sources */,
BC5EB69E0E81DAEB00B25965 /* FillLayer.cpp in Sources */,
08C925190FCC7C4A00480DEC /* FilterEffect.cpp in Sources */,
31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/generic/ActiveDOMCallback.cpp (175781 => 175782)
--- trunk/Source/WebCore/bindings/generic/ActiveDOMCallback.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/bindings/generic/ActiveDOMCallback.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -31,9 +31,7 @@
#include "config.h"
#include "ActiveDOMCallback.h"
-#include "ActiveDOMObject.h"
#include "ScriptExecutionContext.h"
-#include "WorkerGlobalScope.h"
namespace WebCore {
Modified: trunk/Source/WebCore/dom/ActiveDOMObject.cpp (175781 => 175782)
--- trunk/Source/WebCore/dom/ActiveDOMObject.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -28,8 +28,6 @@
#include "ActiveDOMObject.h"
#include "ScriptExecutionContext.h"
-#include "WorkerGlobalScope.h"
-#include "WorkerThread.h"
namespace WebCore {
Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.cpp (175781 => 175782)
--- trunk/Source/WebCore/fileapi/AsyncFileStream.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,162 +30,186 @@
*/
#include "config.h"
-
#include "AsyncFileStream.h"
-#include "Blob.h"
#include "FileStream.h"
#include "FileStreamClient.h"
-#include "FileThread.h"
+#include "URL.h"
+#include <wtf/AutodrainedPool.h>
#include <wtf/MainThread.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/MessageQueue.h>
+#include <wtf/NeverDestroyed.h>
-#if PLATFORM(IOS)
-#include "WebCoreThread.h"
-#endif
-
namespace WebCore {
-static PassRefPtr<FileThread> createFileThread()
-{
- RefPtr<FileThread> thread = FileThread::create();
- if (!thread->start())
- return 0;
- return thread.release();
-}
+struct AsyncFileStream::Internals {
+ explicit Internals(FileStreamClient&);
-static FileThread* fileThread()
+ FileStream stream;
+ FileStreamClient& client;
+#if !COMPILER(MSVC)
+ std::atomic_bool destroyed { false };
+#else
+ std::atomic_bool destroyed;
+#endif
+};
+
+inline AsyncFileStream::Internals::Internals(FileStreamClient& client)
+ : client(client)
{
- ASSERT(isMainThread());
- static FileThread* thread = createFileThread().leakRef();
- return thread;
+#if COMPILER(MSVC)
+ // Work around a bug that prevents the default value above from compiling.
+ atomic_init(&destroyed, false);
+#endif
}
-inline AsyncFileStream::AsyncFileStream(FileStreamClient* client)
- : m_stream(FileStream::create())
- , m_client(client)
+static void callOnFileThread(std::function<void()>&& function)
{
ASSERT(isMainThread());
-}
+ ASSERT(function);
-PassRefPtr<AsyncFileStream> AsyncFileStream::create(FileStreamClient* client)
-{
- RefPtr<AsyncFileStream> proxy = adoptRef(new AsyncFileStream(client));
+ static NeverDestroyed<MessageQueue<std::function<void()>>> queue;
- // Hold a reference so that the instance will not get deleted while there are tasks on the file thread.
- // This is balanced by the deref in derefProxyOnContext below.
- proxy->ref();
+ static std::once_flag createFileThreadOnce;
+ std::call_once(createFileThreadOnce, [] {
+ createThread("WebCore: AsyncFileStream", [] {
+ for (;;) {
+ AutodrainedPool pool;
- AsyncFileStream* proxyPtr = proxy.get();
- fileThread()->postTask({ proxyPtr, [=] {
- // FIXME: It is not correct to check m_client from a secondary thread - stop() could be racing with this check.
- if (!proxyPtr->client())
- return;
+ auto function = queue.get().waitForMessage();
- proxyPtr->m_stream->start();
- callOnMainThread([proxyPtr] {
- if (proxyPtr->client())
- proxyPtr->client()->didStart();
+ // This can never be null because we never kill the MessageQueue.
+ ASSERT(function);
+
+ // This can bever be null because we never queue a function that is null.
+ ASSERT(*function);
+
+ (*function)();
+ }
});
- } });
+ });
- return proxy.release();
+ queue.get().append(std::make_unique<std::function<void()>>(WTF::move(function)));
}
-AsyncFileStream::~AsyncFileStream()
+AsyncFileStream::AsyncFileStream(FileStreamClient& client)
+ : m_internals(std::make_unique<Internals>(client))
{
+ ASSERT(isMainThread());
}
-void AsyncFileStream::stop()
+AsyncFileStream::~AsyncFileStream()
{
- // Clear the client so that we won't be invoking callbacks on the client.
- setClient(0);
+ ASSERT(isMainThread());
- fileThread()->unscheduleTasks(m_stream.get());
- fileThread()->postTask({ this, [this] {
- m_stream->stop();
- callOnMainThread([this] {
- ASSERT(hasOneRef());
- deref();
+ // Release so that we can control the timing of deletion below.
+ auto& internals = *m_internals.release();
+
+ // Set flag to prevent client callbacks and also prevent queued operations from starting.
+ internals.destroyed = true;
+
+ // Call through file thread and back to main thread to make sure deletion happens
+ // after all file thread functions and all main thread functions called from them.
+ callOnFileThread([&internals] {
+ callOnMainThread([&internals] {
+ delete &internals;
});
- } });
+ });
}
-void AsyncFileStream::getSize(const String& path, double expectedModificationTime)
+void AsyncFileStream::perform(std::function<std::function<void(FileStreamClient&)>(FileStream&)> operation)
{
- String pathCopy = path.isolatedCopy();
- fileThread()->postTask({ this, [this, pathCopy, expectedModificationTime] {
- long long size = m_stream->getSize(pathCopy, expectedModificationTime);
- callOnMainThread([this, size] {
- if (client())
- client()->didGetSize(size);
+ auto& internals = *m_internals;
+ callOnFileThread([&internals, operation] {
+ // Don't do the operation if stop was already called on the main thread. Note that there is
+ // a race here, but since skipping the operation is an optimization it's OK that we can't
+ // guarantee exactly which operations are skipped. Note that this is also the only reason
+ // we use an atomic_bool rather than just a bool for destroyed.
+ if (internals.destroyed)
+ return;
+ auto mainThreadWork = operation(internals.stream);
+ callOnMainThread([&internals, mainThreadWork] {
+ if (internals.destroyed)
+ return;
+ mainThreadWork(internals.client);
});
- } });
+ });
}
+void AsyncFileStream::getSize(const String& path, double expectedModificationTime)
+{
+ StringCapture capturedPath(path);
+ // FIXME: Explicit return type here and in all the other cases like this below is a workaround for a deficiency
+ // in the Windows compiler at the time of this writing. Could remove it if that is resolved.
+ perform([capturedPath, expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ long long size = stream.getSize(capturedPath.string(), expectedModificationTime);
+ return [size](FileStreamClient& client) {
+ client.didGetSize(size);
+ };
+ });
+}
+
void AsyncFileStream::openForRead(const String& path, long long offset, long long length)
{
- String pathCopy = path.isolatedCopy();
- fileThread()->postTask({ this, [this, pathCopy, offset, length] {
- bool success = m_stream->openForRead(pathCopy, offset, length);
- callOnMainThread([this, success] {
- if (client())
- client()->didOpen(success);
- });
- } });
+ StringCapture capturedPath(path);
+ // FIXME: Explicit return type here is a workaround for a deficiency in the Windows compiler at the time of this writing.
+ perform([capturedPath, offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ bool success = stream.openForRead(capturedPath.string(), offset, length);
+ return [success](FileStreamClient& client) {
+ client.didOpen(success);
+ };
+ });
}
void AsyncFileStream::openForWrite(const String& path)
{
- String pathCopy = path.isolatedCopy();
- fileThread()->postTask({ this, [this, pathCopy] {
- bool success = m_stream->openForWrite(pathCopy);
- callOnMainThread([this, success] {
- if (client())
- client()->didOpen(success);
- });
- } });
+ StringCapture capturedPath(path);
+ perform([capturedPath](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ bool success = stream.openForWrite(capturedPath.string());
+ return [success](FileStreamClient& client) {
+ client.didOpen(success);
+ };
+ });
}
void AsyncFileStream::close()
{
- fileThread()->postTask({this, [this] {
- m_stream->close();
- } });
+ auto& internals = *m_internals;
+ callOnFileThread([&internals] {
+ internals.stream.close();
+ });
}
void AsyncFileStream::read(char* buffer, int length)
{
- fileThread()->postTask({ this, [this, buffer, length] {
- int bytesRead = m_stream->read(buffer, length);
- callOnMainThread([this, bytesRead] {
- if (client())
- client()->didRead(bytesRead);
- });
- } });
+ perform([buffer, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ int bytesRead = stream.read(buffer, length);
+ return [bytesRead](FileStreamClient& client) {
+ client.didRead(bytesRead);
+ };
+ });
}
void AsyncFileStream::write(const URL& blobURL, long long position, int length)
{
- URL blobURLCopy = blobURL.copy();
- fileThread()->postTask({ this, [this, blobURLCopy, position, length] {
- int bytesWritten = m_stream->write(blobURLCopy, position, length);
- callOnMainThread([this, bytesWritten] {
- if (client())
- client()->didWrite(bytesWritten);
- });
- } });
+ // FIXME: Would be more elegant to have a URLCapture for cases like this to avoid re-parsing the URL.
+ StringCapture capturedURL(blobURL.string());
+ perform([capturedURL, position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ int bytesWritten = stream.write(URL(ParsedURLString, capturedURL.string()), position, length);
+ return [bytesWritten](FileStreamClient& client) {
+ client.didWrite(bytesWritten);
+ };
+ });
}
void AsyncFileStream::truncate(long long position)
{
- fileThread()->postTask({ this, [this, position] {
- bool success = m_stream->truncate(position);
- callOnMainThread([this, success] {
- if (client())
- client()->didTruncate(success);
- });
- } });
+ perform([position](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+ bool success = stream.truncate(position);
+ return [success](FileStreamClient& client) {
+ client.didTruncate(success);
+ };
+ });
}
} // namespace WebCore
Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.h (175781 => 175782)
--- trunk/Source/WebCore/fileapi/AsyncFileStream.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010, 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,9 +32,8 @@
#ifndef AsyncFileStream_h
#define AsyncFileStream_h
+#include <functional>
#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
namespace WebCore {
@@ -42,9 +41,9 @@
class FileStream;
class URL;
-class AsyncFileStream : public RefCounted<AsyncFileStream> {
+class AsyncFileStream {
public:
- static PassRefPtr<AsyncFileStream> create(FileStreamClient*);
+ explicit AsyncFileStream(FileStreamClient&);
~AsyncFileStream();
void getSize(const String& path, double expectedModificationTime);
@@ -55,18 +54,12 @@
void write(const URL& blobURL, long long position, int length);
void truncate(long long position);
- // Stops the proxy and schedules it to be destructed. All the pending tasks will be aborted and the file stream will be closed.
- // Note: the caller should deref the instance immediately after calling stop().
- void stop();
-
- FileStreamClient* client() const { return m_client; }
- void setClient(FileStreamClient* client) { m_client = client; }
-
private:
- AsyncFileStream(FileStreamClient*);
+ void start();
+ void perform(std::function<std::function<void(FileStreamClient&)>(FileStream&)>);
- RefPtr<FileStream> m_stream;
- FileStreamClient* m_client;
+ struct Internals;
+ std::unique_ptr<Internals> m_internals;
};
} // namespace WebCore
Deleted: trunk/Source/WebCore/fileapi/FileThread.cpp (175781 => 175782)
--- trunk/Source/WebCore/fileapi/FileThread.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/fileapi/FileThread.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,113 +0,0 @@
-/*
- * 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"
-
-#include "FileThread.h"
-
-#include "Logging.h"
-#include <wtf/AutodrainedPool.h>
-
-namespace WebCore {
-
-FileThread::FileThread()
- : m_threadID(0)
-{
- m_selfRef = this;
-}
-
-FileThread::~FileThread()
-{
- ASSERT(m_queue.killed());
-}
-
-bool FileThread::start()
-{
- MutexLocker lock(m_threadCreationMutex);
- if (m_threadID)
- return true;
- m_threadID = createThread(FileThread::fileThreadStart, this, "WebCore: File");
- return m_threadID;
-}
-
-void FileThread::stop()
-{
- m_queue.kill();
-}
-
-void FileThread::postTask(Task task)
-{
- m_queue.append(std::make_unique<FileThread::Task>(WTF::move(task)));
-}
-
-class SameInstancePredicate {
-public:
- SameInstancePredicate(const void* instance) : m_instance(instance) { }
- bool operator()(FileThread::Task& task) const { return task.instance() == m_instance; }
-private:
- const void* m_instance;
-};
-
-void FileThread::unscheduleTasks(const void* instance)
-{
- SameInstancePredicate predicate(instance);
- m_queue.removeIf(predicate);
-}
-
-void FileThread::fileThreadStart(void* arg)
-{
- FileThread* fileThread = static_cast<FileThread*>(arg);
- fileThread->runLoop();
-}
-
-void FileThread::runLoop()
-{
- {
- // Wait for FileThread::start() to complete to have m_threadID
- // established before starting the main loop.
- MutexLocker lock(m_threadCreationMutex);
- LOG(FileAPI, "Started FileThread %p", this);
- }
-
- while (auto task = m_queue.waitForMessage()) {
- AutodrainedPool pool;
-
- task->performTask();
- }
-
- LOG(FileAPI, "About to detach thread %i and clear the ref to FileThread %p, which currently has %i ref(s)", m_threadID, this, refCount());
-
- detachThread(m_threadID);
-
- // Clear the self refptr, possibly resulting in deletion
- m_selfRef = 0;
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/fileapi/FileThread.h (175781 => 175782)
--- trunk/Source/WebCore/fileapi/FileThread.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/fileapi/FileThread.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,101 +0,0 @@
-/*
- * 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 FileThread_h
-#define FileThread_h
-
-#include <functional>
-#include <wtf/MessageQueue.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/Threading.h>
-
-namespace WebCore {
-
-class FileStream;
-
-class FileThread : public ThreadSafeRefCounted<FileThread> {
-public:
- static PassRefPtr<FileThread> create()
- {
- return adoptRef(new FileThread());
- }
-
- ~FileThread();
-
- bool start();
- void stop();
-
- class Task {
- WTF_MAKE_NONCOPYABLE(Task);
- public:
- template<typename T, typename U, typename = typename std::enable_if<!std::is_base_of<Task, U>::value && std::is_convertible<U, std::function<void ()>>::value>::type>
- Task(T* instance, U method)
- : m_task(WTF::move(method))
- , m_instance(instance)
- {
- }
-
- Task(Task&& other)
- : m_task(WTF::move(other.m_task))
- , m_instance(other.m_instance)
- {
- }
-
- void performTask()
- {
- m_task();
- }
- void* instance() const { return m_instance; }
-
- private:
- std::function<void ()> m_task;
- void* m_instance;
- };
-
- void postTask(Task);
-
- void unscheduleTasks(const void* instance);
-
-private:
- FileThread();
-
- static void fileThreadStart(void*);
- void runLoop();
-
- ThreadIdentifier m_threadID;
- RefPtr<FileThread> m_selfRef;
- MessageQueue<Task> m_queue;
-
- Mutex m_threadCreationMutex;
-};
-
-} // namespace WebCore
-
-#endif // FileThread_h
Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (175781 => 175782)
--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -31,7 +31,6 @@
#include "ResourceLoader.h"
#include "ApplicationCacheHost.h"
-#include "AsyncFileStream.h"
#include "AuthenticationChallenge.h"
#include "DocumentLoader.h"
#include "Frame.h"
Modified: trunk/Source/WebCore/platform/FileStream.cpp (175781 => 175782)
--- trunk/Source/WebCore/platform/FileStream.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/platform/FileStream.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -46,16 +46,6 @@
FileStream::~FileStream()
{
- ASSERT(!isHandleValid(m_handle));
-}
-
-// FIXME: To be removed when we switch to using BlobData.
-void FileStream::start()
-{
-}
-
-void FileStream::stop()
-{
close();
}
Modified: trunk/Source/WebCore/platform/FileStream.h (175781 => 175782)
--- trunk/Source/WebCore/platform/FileStream.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/platform/FileStream.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -32,29 +32,17 @@
#define FileStream_h
#include "FileSystem.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
namespace WebCore {
class URL;
// All methods are synchronous.
-class FileStream : public RefCounted<FileStream> {
+class FileStream {
public:
- static PassRefPtr<FileStream> create()
- {
- return adoptRef(new FileStream());
- }
+ FileStream();
~FileStream();
- // FIXME: To be removed when we switch to using BlobData.
- void start();
-
- // Aborts the operation.
- void stop();
-
// Gets the size of a file. Also validates if the file has been changed or not if the expected modification time is provided, i.e. non-zero.
// Returns total number of bytes if successful. -1 otherwise.
long long getSize(const String& path, double expectedModificationTime);
@@ -84,8 +72,6 @@
bool truncate(long long position);
private:
- FileStream();
-
PlatformFileHandle m_handle;
long long m_bytesProcessed;
long long m_totalBytesToRead;
Modified: trunk/Source/WebCore/platform/FileStreamClient.h (175781 => 175782)
--- trunk/Source/WebCore/platform/FileStreamClient.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/platform/FileStreamClient.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * 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
@@ -36,15 +36,11 @@
class FileStreamClient {
public:
virtual void didOpen(bool) { } // false signals failure.
- virtual void didStop() { }
virtual void didGetSize(long long) { } // -1 signals failure.
virtual void didRead(int) { } // -1 signals failure.
virtual void didWrite(int) { } // -1 signals failure.
virtual void didTruncate(bool) { } // false signals failure.
- // FIXME: To be removed when we switch to using BlobData.
- virtual void didStart() { }
-
protected:
virtual ~FileStreamClient() { }
};
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (175781 => 175782)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp 2014-11-09 01:01:22 UTC (rev 175782)
@@ -171,30 +171,18 @@
, m_fileOpened(false)
{
if (m_async)
- m_asyncStream = AsyncFileStream::create(this);
+ m_asyncStream = std::make_unique<AsyncFileStream>(*this);
else
- m_stream = FileStream::create();
+ m_stream = std::make_unique<FileStream>();
}
BlobResourceHandle::~BlobResourceHandle()
{
- if (m_async) {
- if (m_asyncStream)
- m_asyncStream->stop();
- } else {
- if (m_stream)
- m_stream->stop();
- }
}
void BlobResourceHandle::cancel()
{
- if (m_async) {
- if (m_asyncStream) {
- m_asyncStream->stop();
- m_asyncStream = 0;
- }
- }
+ m_asyncStream = nullptr;
m_aborted = true;
Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.h (175781 => 175782)
--- trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -92,8 +92,8 @@
RefPtr<BlobData> m_blobData;
bool m_async;
- RefPtr<AsyncFileStream> m_asyncStream; // For asynchronous loading.
- RefPtr<FileStream> m_stream; // For synchronous loading.
+ std::unique_ptr<AsyncFileStream> m_asyncStream; // For asynchronous loading.
+ std::unique_ptr<FileStream> m_stream; // For synchronous loading.
Vector<char> m_buffer;
Vector<long long> m_itemLengthList;
int m_errorCode;
Modified: trunk/Source/WebCore/storage/StorageThread.h (175781 => 175782)
--- trunk/Source/WebCore/storage/StorageThread.h 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebCore/storage/StorageThread.h 2014-11-09 01:01:22 UTC (rev 175782)
@@ -46,7 +46,7 @@
bool start();
void terminate();
- void dispatch(const std::function<void ()>&);
+ void dispatch(const std::function<void()>&);
static void releaseFastMallocFreeMemoryInAllThreads();
@@ -59,7 +59,7 @@
void performTerminate();
ThreadIdentifier m_threadID;
- MessageQueue<std::function<void ()>> m_queue;
+ MessageQueue<std::function<void()>> m_queue;
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (175781 => 175782)
--- trunk/Source/WebKit/ChangeLog 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebKit/ChangeLog 2014-11-09 01:01:22 UTC (rev 175782)
@@ -1,3 +1,13 @@
+2014-11-08 Darin Adler <da...@apple.com>
+
+ Replace FileThread class with a single function
+ https://bugs.webkit.org/show_bug.cgi?id=138282
+
+ Reviewed by Alexey Proskuryakov.
+
+ * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in:
+ Removed exports of obsolete threading functions.
+
2014-11-05 Dan Bernstein <m...@apple.com>
Removed references to deletion UI resources that have been removed.
Modified: trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in (175781 => 175782)
--- trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in 2014-11-08 23:50:43 UTC (rev 175781)
+++ trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in 2014-11-09 01:01:22 UTC (rev 175782)
@@ -125,7 +125,6 @@
symbolWithPointer(?broadcast@ThreadCondition@WTF@@QAEXXZ, ?broadcast@ThreadCondition@WTF@@QEAAXXZ)
symbolWithPointer(?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z, ?callOnMainThread@WTF@@YAXP6AXPEAX@Z0@Z)
symbolWithPointer(?counterValueForElement@WebCore@@YA?AVString@WTF@@PAVElement@1@@Z, ?counterValueForElement@WebCore@@YA?AVString@WTF@@PEAVElement@1@@Z)
- symbolWithPointer(?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z, ?createThread@WTF@@YAIP6APEAXPEAX@Z0PEBD@Z)
symbolWithPointer(?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z, ?createThread@WTF@@YAIP6AXPEAX@Z0PEBD@Z)
?currentThread@WTF@@YAIXZ
?detachThread@WTF@@YAXI@Z
@@ -144,8 +143,6 @@
symbolWithPointer(?unlock@Mutex@WTF@@QAEXXZ, ?unlock@Mutex@WTF@@QEAAXXZ)
symbolWithPointer(?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z, ?wait@ThreadCondition@WTF@@QEAAXAEAVMutex@2@@Z)
?waitForThreadCompletion@WTF@@YAHI@Z
- symbolWithPointer(?waitForThreadCompletion@WTF@@YAHIPAPAX@Z, ?waitForThreadCompletion@WTF@@YAHIPEAPEAX@Z)
- symbolWithPointer(?createThread@WTF@@YAIP6APAXPAX@Z0@Z, ?createThread@WTF@@YAIP6APEAXPEAX@Z0@Z)
; Re-exports from WebCore for test harnesses
symbolWithPointer(??0HitTestResult@WebCore@@QAE@ABVLayoutPoint@1@@Z, ??0HitTestResult@WebCore@@QEAA@AEBVLayoutPoint@1@@Z)