<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168610] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168610">168610</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2014-05-12 00:01:24 -0700 (Mon, 12 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simplify FileThread::Task usage
https://bugs.webkit.org/show_bug.cgi?id=132798
Reviewed by Darin Adler.
Remove the createFileThreadTask functions and the related FileThreadTask helper classes.
Instead, the FileThread::Task class now has a templated constructor that takes in a pointer
to the object instance, a method, and a variadic pack of parameters. The pointer and the
cross-thread copies of all the parameters are then bound to the given method through std::bind().
Instead of createFileThreadTask, std::make_unique<>() should be used to construct unique pointers
that wrap FileThread::Task objects.
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* fileapi/AsyncFileStream.cpp:
(WebCore::AsyncFileStream::create):
(WebCore::AsyncFileStream::stop):
(WebCore::AsyncFileStream::getSize):
(WebCore::AsyncFileStream::openForRead):
(WebCore::AsyncFileStream::openForWrite):
(WebCore::AsyncFileStream::close):
(WebCore::AsyncFileStream::read):
(WebCore::AsyncFileStream::write):
(WebCore::AsyncFileStream::truncate):
* fileapi/FileThread.h:
(WebCore::FileThread::Task::Task):
(WebCore::FileThread::Task::performTask):
(WebCore::FileThread::Task::~Task): Deleted.
* fileapi/FileThreadTask.h: Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorefileapiAsyncFileStreamcpp">trunk/Source/WebCore/fileapi/AsyncFileStream.cpp</a></li>
<li><a href="#trunkSourceWebCorefileapiFileThreadh">trunk/Source/WebCore/fileapi/FileThread.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorefileapiFileThreadTaskh">trunk/Source/WebCore/fileapi/FileThreadTask.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/ChangeLog        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-05-11 Zan Dobersek <zdobersek@igalia.com>
+
+ Simplify FileThread::Task usage
+ https://bugs.webkit.org/show_bug.cgi?id=132798
+
+ Reviewed by Darin Adler.
+
+ Remove the createFileThreadTask functions and the related FileThreadTask helper classes.
+
+ Instead, the FileThread::Task class now has a templated constructor that takes in a pointer
+ to the object instance, a method, and a variadic pack of parameters. The pointer and the
+ cross-thread copies of all the parameters are then bound to the given method through std::bind().
+
+ Instead of createFileThreadTask, std::make_unique<>() should be used to construct unique pointers
+ that wrap FileThread::Task objects.
+
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * fileapi/AsyncFileStream.cpp:
+ (WebCore::AsyncFileStream::create):
+ (WebCore::AsyncFileStream::stop):
+ (WebCore::AsyncFileStream::getSize):
+ (WebCore::AsyncFileStream::openForRead):
+ (WebCore::AsyncFileStream::openForWrite):
+ (WebCore::AsyncFileStream::close):
+ (WebCore::AsyncFileStream::read):
+ (WebCore::AsyncFileStream::write):
+ (WebCore::AsyncFileStream::truncate):
+ * fileapi/FileThread.h:
+ (WebCore::FileThread::Task::Task):
+ (WebCore::FileThread::Task::performTask):
+ (WebCore::FileThread::Task::~Task): Deleted.
+ * fileapi/FileThreadTask.h: Removed.
+
</ins><span class="cx"> 2014-05-11 Benjamin Poulain <benjamin@webkit.org>
</span><span class="cx">
</span><span class="cx"> Do not create a temporary string to append the SVGLength's unit
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -20514,7 +20514,6 @@
</span><span class="cx"> <ClInclude Include="..\fileapi\FileReaderLoaderClient.h" />
</span><span class="cx"> <ClInclude Include="..\fileapi\FileReaderSync.h" />
</span><span class="cx"> <ClInclude Include="..\fileapi\FileThread.h" />
</span><del>- <ClInclude Include="..\fileapi\FileThreadTask.h" />
</del><span class="cx"> <ClInclude Include="..\html\FormAssociatedElement.h" />
</span><span class="cx"> <ClInclude Include="..\html\FormController.h" />
</span><span class="cx"> <ClInclude Include="..\html\FormDataList.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -10765,9 +10765,6 @@
</span><span class="cx"> <ClInclude Include="..\fileapi\FileThread.h">
</span><span class="cx"> <Filter>html</Filter>
</span><span class="cx"> </ClInclude>
</span><del>- <ClInclude Include="..\fileapi\FileThreadTask.h">
- <Filter>html</Filter>
- </ClInclude>
</del><span class="cx"> <ClInclude Include="..\html\FormAssociatedElement.h">
</span><span class="cx"> <Filter>html</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -3393,7 +3393,6 @@
</span><span class="cx">                 976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C6A122B8A3D001FD1F7 /* FileReader.h */; };
</span><span class="cx">                 976D6C8D122B8A3D001FD1F7 /* FileThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */; };
</span><span class="cx">                 976D6C8E122B8A3D001FD1F7 /* FileThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C6F122B8A3D001FD1F7 /* FileThread.h */; };
</span><del>-                976D6C8F122B8A3D001FD1F7 /* FileThreadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C70122B8A3D001FD1F7 /* FileThreadTask.h */; };
</del><span class="cx">                 976D6C94122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */; };
</span><span class="cx">                 976D6C95122B8A3D001FD1F7 /* ThreadableBlobRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */; };
</span><span class="cx">                 976F36EA14686225005E93B4 /* SecurityContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976F36E814686225005E93B4 /* SecurityContext.cpp */; };
</span><span class="lines">@@ -10440,7 +10439,6 @@
</span><span class="cx">                 976D6C6A122B8A3D001FD1F7 /* FileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileReader.h; path = fileapi/FileReader.h; sourceTree = "<group>"; };
</span><span class="cx">                 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileThread.cpp; path = fileapi/FileThread.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 976D6C6F122B8A3D001FD1F7 /* FileThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileThread.h; path = fileapi/FileThread.h; sourceTree = "<group>"; };
</span><del>-                976D6C70122B8A3D001FD1F7 /* FileThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileThreadTask.h; path = fileapi/FileThreadTask.h; sourceTree = "<group>"; };
</del><span class="cx">                 976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadableBlobRegistry.cpp; path = fileapi/ThreadableBlobRegistry.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadableBlobRegistry.h; path = fileapi/ThreadableBlobRegistry.h; sourceTree = "<group>"; };
</span><span class="cx">                 976F36E814686225005E93B4 /* SecurityContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecurityContext.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -17896,7 +17894,6 @@
</span><span class="cx">                                 E1AB1EBD14E9E3A800449E13 /* FileReaderSync.idl */,
</span><span class="cx">                                 976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */,
</span><span class="cx">                                 976D6C6F122B8A3D001FD1F7 /* FileThread.h */,
</span><del>-                                976D6C70122B8A3D001FD1F7 /* FileThreadTask.h */,
</del><span class="cx">                                 976D6C75122B8A3D001FD1F7 /* ThreadableBlobRegistry.cpp */,
</span><span class="cx">                                 976D6C76122B8A3D001FD1F7 /* ThreadableBlobRegistry.h */,
</span><span class="cx">                                 976D6C5C122B8A3D001FD1F7 /* WebKitBlobBuilder.cpp */,
</span><span class="lines">@@ -23916,7 +23913,6 @@
</span><span class="cx">                                 26C17A3E1491D2D400D12BA2 /* FileSystemIOS.h in Headers */,
</span><span class="cx">                                 976D6C8E122B8A3D001FD1F7 /* FileThread.h in Headers */,
</span><span class="cx">                                 1CC6B06D18F8526B0007ECCD /* WebProfilerAgent.h in Headers */,
</span><del>-                                976D6C8F122B8A3D001FD1F7 /* FileThreadTask.h in Headers */,
</del><span class="cx">                                 BC5EB69F0E81DAEB00B25965 /* FillLayer.h in Headers */,
</span><span class="cx">                                 845E72F80FD261EE00A87D79 /* Filter.h in Headers */,
</span><span class="cx">                                 08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiAsyncFileStreamcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.cpp (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/AsyncFileStream.cpp        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.cpp        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -39,7 +39,6 @@
</span><span class="cx"> #include "FileStream.h"
</span><span class="cx"> #include "FileStreamClient.h"
</span><span class="cx"> #include "FileThread.h"
</span><del>-#include "FileThreadTask.h"
</del><span class="cx"> #include "MainThreadTask.h"
</span><span class="cx"> #include <wtf/MainThread.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -80,7 +79,7 @@
</span><span class="cx"> // This is balanced by the deref in derefProxyOnContext below.
</span><span class="cx"> proxy->ref();
</span><span class="cx">
</span><del>- fileThread()->postTask(createFileThreadTask(proxy.get(), &AsyncFileStream::startOnFileThread));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(proxy.get(), &AsyncFileStream::startOnFileThread));
</ins><span class="cx">
</span><span class="cx"> return proxy.release();
</span><span class="cx"> }
</span><span class="lines">@@ -110,7 +109,7 @@
</span><span class="cx"> setClient(0);
</span><span class="cx">
</span><span class="cx"> fileThread()->unscheduleTasks(m_stream.get());
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::stopOnFileThread));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::stopOnFileThread));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void derefProxyOnMainThread(AsyncFileStream* proxy)
</span><span class="lines">@@ -133,7 +132,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::getSize(const String& path, double expectedModificationTime)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::getSizeOnFileThread, path, expectedModificationTime));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::getSizeOnFileThread, path, expectedModificationTime));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::getSizeOnFileThread(const String& path, double expectedModificationTime)
</span><span class="lines">@@ -150,7 +149,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::openForRead(const String& path, long long offset, long long length)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::openForReadOnFileThread, path, offset, length));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::openForReadOnFileThread, path, offset, length));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::openForReadOnFileThread(const String& path, long long offset, long long length)
</span><span class="lines">@@ -161,9 +160,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::openForWrite(const String& path)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(
- createFileThreadTask(this,
- &AsyncFileStream::openForWriteOnFileThread, path));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::openForWriteOnFileThread, path));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::openForWriteOnFileThread(const String& path)
</span><span class="lines">@@ -174,7 +171,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::close()
</span><span class="cx"> {
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::closeOnFileThread));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::closeOnFileThread));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::closeOnFileThread()
</span><span class="lines">@@ -190,9 +187,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::read(char* buffer, int length)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(
- createFileThreadTask(this, &AsyncFileStream::readOnFileThread,
- AllowCrossThreadAccess(buffer), length));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::readOnFileThread, AllowCrossThreadAccess(buffer), length));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::readOnFileThread(char* buffer, int length)
</span><span class="lines">@@ -209,7 +204,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::write(const URL& blobURL, long long position, int length)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::writeOnFileThread, blobURL, position, length));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::writeOnFileThread, blobURL, position, length));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::writeOnFileThread(const URL& blobURL, long long position, int length)
</span><span class="lines">@@ -226,7 +221,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::truncate(long long position)
</span><span class="cx"> {
</span><del>- fileThread()->postTask(createFileThreadTask(this, &AsyncFileStream::truncateOnFileThread, position));
</del><ins>+ fileThread()->postTask(std::make_unique<FileThread::Task>(this, &AsyncFileStream::truncateOnFileThread, position));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void AsyncFileStream::truncateOnFileThread(long long position)
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFileThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/FileThread.h (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/FileThread.h        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/fileapi/FileThread.h        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -33,6 +33,8 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(BLOB)
</span><span class="cx">
</span><ins>+#include "CrossThreadCopier.h"
+#include <functional>
</ins><span class="cx"> #include <wtf/MessageQueue.h>
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/Threading.h>
</span><span class="lines">@@ -56,11 +58,21 @@
</span><span class="cx"> class Task {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(Task);
</span><span class="cx"> public:
</span><del>- virtual ~Task() { }
- virtual void performTask() = 0;
</del><ins>+ template<typename T, typename Method, typename... Parameters>
+ Task(T* instance, Method method, const Parameters&... parameters)
+ : m_task(std::bind(method, instance, typename CrossThreadCopier<Parameters>::Type(CrossThreadCopier<Parameters>::copy(parameters))...))
+ , m_instance(instance)
+ {
+ }
+
+ void performTask()
+ {
+ m_task();
+ }
</ins><span class="cx"> void* instance() const { return m_instance; }
</span><del>- protected:
- Task(void* instance) : m_instance(instance) { }
</del><ins>+
+ private:
+ std::function<void ()> m_task;
</ins><span class="cx"> void* m_instance;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFileThreadTaskh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/fileapi/FileThreadTask.h (168609 => 168610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/FileThreadTask.h        2014-05-12 06:30:37 UTC (rev 168609)
+++ trunk/Source/WebCore/fileapi/FileThreadTask.h        2014-05-12 07:01:24 UTC (rev 168610)
</span><span class="lines">@@ -1,206 +0,0 @@
</span><del>-/*
- * 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 FileThreadTask_h
-#define FileThreadTask_h
-
-#include "CrossThreadCopier.h"
-#include "CrossThreadTask.h"
-#include "FileThread.h"
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
-template<typename T>
-class FileThreadTask0 : public FileThread::Task {
-public:
- typedef void (T::*Method)();
- typedef FileThreadTask0<T> FileThreadTaskImpl;
-
- FileThreadTask0(T* instance, Method method)
- : FileThread::Task(instance)
- , m_method(method)
- {
- }
-
-private:
- virtual void performTask() override
- {
- (*static_cast<T*>(instance()).*m_method)();
- }
-
-private:
- Method m_method;
-};
-
-template<typename T, typename P1, typename MP1>
-class FileThreadTask1 : public FileThread::Task {
-public:
- typedef void (T::*Method)(MP1);
- typedef FileThreadTask1<T, P1, MP1> FileThreadTaskImpl;
- typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
-
- FileThreadTask1(T* instance, Method method, Param1 parameter1)
- : FileThread::Task(instance)
- , m_method(method)
- , m_parameter1(parameter1)
- {
- }
-
-private:
- virtual void performTask() override
- {
- (*static_cast<T*>(instance()).*m_method)(m_parameter1);
- }
-
-private:
- Method m_method;
- P1 m_parameter1;
-};
-
-template<typename T, typename P1, typename MP1, typename P2, typename MP2>
-class FileThreadTask2 : public FileThread::Task {
-public:
- typedef void (T::*Method)(MP1, MP2);
- typedef FileThreadTask2<T, P1, MP1, P2, MP2> FileThreadTaskImpl;
- typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
- typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
-
- FileThreadTask2(T* instance, Method method, Param1 parameter1, Param2 parameter2)
- : FileThread::Task(instance)
- , m_method(method)
- , m_parameter1(parameter1)
- , m_parameter2(parameter2)
- {
- }
-
-private:
- virtual void performTask() override
- {
- (*static_cast<T*>(instance()).*m_method)(m_parameter1, m_parameter2);
- }
-
-private:
- Method m_method;
- P1 m_parameter1;
- P2 m_parameter2;
-};
-
-template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
-class FileThreadTask3 : public FileThread::Task {
-public:
- typedef void (T::*Method)(MP1, MP2, MP3);
- typedef FileThreadTask3<T, P1, MP1, P2, MP2, P3, MP3> FileThreadTaskImpl;
- typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
- typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
- typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
-
- FileThreadTask3(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3)
- : FileThread::Task(instance)
- , m_method(method)
- , m_parameter1(parameter1)
- , m_parameter2(parameter2)
- , m_parameter3(parameter3)
- {
- }
-
-private:
- virtual void performTask() override
- {
- (*static_cast<T*>(instance()).*m_method)(m_parameter1, m_parameter2, m_parameter3);
- }
-
-private:
- Method m_method;
- P1 m_parameter1;
- P2 m_parameter2;
- P3 m_parameter3;
-};
-
-template<typename T>
-std::unique_ptr<FileThread::Task> createFileThreadTask(
- T* const callee,
- void (T::*method)());
-
-template<typename T>
-std::unique_ptr<FileThread::Task> createFileThreadTask(
- T* const callee,
- void (T::*method)())
-{
- return std::make_unique<FileThreadTask0<T>>(
- callee,
- method);
-}
-
-template<typename T, typename P1, typename MP1>
-std::unique_ptr<FileThread::Task> createFileThreadTask(
- T* const callee,
- void (T::*method)(MP1),
- const P1& parameter1)
-{
- return std::make_unique<FileThreadTask1<T, typename CrossThreadCopier<P1>::Type, MP1>>(
- callee,
- method,
- CrossThreadCopier<P1>::copy(parameter1));
-}
-
-template<typename T, typename P1, typename MP1, typename P2, typename MP2>
-std::unique_ptr<FileThread::Task> createFileThreadTask(
- T* const callee,
- void (T::*method)(MP1, MP2),
- const P1& parameter1,
- const P2& parameter2)
-{
- return std::make_unique<FileThreadTask2<T, typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2>>(
- callee,
- method,
- CrossThreadCopier<P1>::copy(parameter1),
- CrossThreadCopier<P2>::copy(parameter2));
-}
-
-template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
-std::unique_ptr<FileThread::Task> createFileThreadTask(
- T* const callee,
- void (T::*method)(MP1, MP2, MP3),
- const P1& parameter1,
- const P2& parameter2,
- const P3& parameter3)
-{
- return std::make_unique<FileThreadTask3<T, typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3>>(
- callee,
- method,
- CrossThreadCopier<P1>::copy(parameter1),
- CrossThreadCopier<P2>::copy(parameter2),
- CrossThreadCopier<P3>::copy(parameter3));
-}
-
-} // namespace WebCore
-
-#endif // FileThreadTask_h
</del></span></pre>
</div>
</div>
</body>
</html>