RESOLVED FIXED 176091
Implement FileSystemDirectoryReader.readEntries()
https://bugs.webkit.org/show_bug.cgi?id=176091
Summary Implement FileSystemDirectoryReader.readEntries()
Chris Dumez
Reported 2017-08-29 22:19:19 PDT
Implement FileSystemDirectoryReader.readEntries(): - https://wicg.github.io/entries-api/#dom-filesystemdirectoryreader-readentries
Attachments
WIP Patch (34.54 KB, patch)
2017-08-29 22:21 PDT, Chris Dumez
no flags
WIP Patch (33.78 KB, patch)
2017-08-29 22:28 PDT, Chris Dumez
no flags
WIP Patch (34.31 KB, patch)
2017-08-30 09:22 PDT, Chris Dumez
no flags
WIP Patch (35.62 KB, patch)
2017-08-30 11:27 PDT, Chris Dumez
no flags
Patch (42.70 KB, patch)
2017-08-30 12:04 PDT, Chris Dumez
no flags
Patch (47.86 KB, patch)
2017-08-30 16:01 PDT, Chris Dumez
no flags
Patch (53.09 KB, patch)
2017-08-30 19:03 PDT, Chris Dumez
no flags
Patch (53.15 KB, patch)
2017-08-30 19:18 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2017-08-29 22:21:24 PDT
Created attachment 319342 [details] WIP Patch
Build Bot
Comment 2 2017-08-29 22:22:45 PDT
Attachment 319342 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:107: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 21 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 3 2017-08-29 22:28:05 PDT
Created attachment 319344 [details] WIP Patch
Build Bot
Comment 4 2017-08-29 22:29:49 PDT
Attachment 319344 [details] did not pass style-queue: ERROR: Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:107: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 21 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 5 2017-08-30 09:22:08 PDT
Created attachment 319369 [details] WIP Patch
Chris Dumez
Comment 6 2017-08-30 11:27:35 PDT
Created attachment 319383 [details] WIP Patch
Radar WebKit Bug Importer
Comment 7 2017-08-30 11:51:01 PDT
Chris Dumez
Comment 8 2017-08-30 12:04:13 PDT
Andreas Kling
Comment 9 2017-08-30 14:17:08 PDT
Comment on attachment 319385 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=319385&action=review r=me > Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:53 > + Vector<String> childPaths = listDirectory(fullPath, "*"); auto > Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:119 > + Vector<String> components; > + virtualPath.split('/', false /* allowEmpty */, components); auto + overload of split() would look nice :) > Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:157 > + callOnMainThread([this, completionHandler = WTFMove(completionHandler), listedChildren = CrossThreadCopier<ExceptionOr<Vector<ListedChild>>>::copy(listedChildren), directoryPtr]() mutable { It would be cool to have a makeCrossThreadCopy() helper. > Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.cpp:80 > + setPendingActivity(this); I think it would be nice to use a RAII helper object for this so we don't have to unset in every possible code path. > LayoutTests/editing/pasteboard/datatransfer-items-drop-directoryReader-root.html:16 > +function moveMouseToCenterOfElement(element) { > + var centerX = element.offsetLeft + element.offsetWidth / 2; > + var centerY = element.offsetTop + element.offsetHeight / 2; > + eventSender.mouseMoveTo(centerX, centerY); > +} This seems like a very useful function, maybe we could put it somewhere shared so other tests can use it too? > LayoutTests/editing/pasteboard/datatransfer-items-drop-directoryReader.html:16 > +function moveMouseToCenterOfElement(element) { > + var centerX = element.offsetLeft + element.offsetWidth / 2; > + var centerY = element.offsetTop + element.offsetHeight / 2; > + eventSender.mouseMoveTo(centerX, centerY); > +} This seems like a very useful function, maybe we could put it somewhere shared so other tests can use it too?
Chris Dumez
Comment 10 2017-08-30 16:01:59 PDT
Andreas Kling
Comment 11 2017-08-30 17:06:16 PDT
Comment on attachment 319418 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=319418&action=review > Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:159 > + m_workQueue->dispatch([this, completionHandler = WTFMove(completionHandler), fullPath = fullPath.isolatedCopy(), directoryPtr = &directory]() mutable { > + auto listedChildren = listDirectoryWithMetadata(fullPath); > + callOnMainThread([this, completionHandler = WTFMove(completionHandler), listedChildren = crossThreadCopy(listedChildren), directoryPtr]() mutable { > + completionHandler(toFileSystemEntries(*this, WTFMove(listedChildren), directoryPtr->virtualPath())); > + }); > + }); Since the directoryPtr is only used to retrieve the virtualPath() here, we can avoid the mysterious lifetime implications by simply capturing the virtual path instead of the directory. > Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.cpp:39 > + : ActiveDOMObject(&context) The ActiveDOMObject constructor could probably take the ScriptExecutionContext by reference. > Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.cpp:66 > + if (m_isReading) { > + if (errorCallback) > + errorCallback->scheduleCallback(context, DOMException::create(Exception { InvalidStateError, ASCIILiteral("Directory reader is already reading") })); > + return; > + } This case is not covered in the layout tests. > Source/WebCore/Modules/entriesapi/FileSystemDirectoryReader.cpp:72 > + if (m_error) { > + if (errorCallback) > + errorCallback->scheduleCallback(context, DOMException::create(*m_error)); > + return; > + } This is also not covered, although I don't know an easy way to trip an error condition here. > Source/WebCore/dom/ExceptionOr.h:192 > + return CrossThreadCopier<T>::copy(source.returnValue()); This could use crossThreadCopy :)
Chris Dumez
Comment 12 2017-08-30 19:03:55 PDT
Chris Dumez
Comment 13 2017-08-30 19:18:43 PDT
WebKit Commit Bot
Comment 14 2017-08-30 20:48:25 PDT
Comment on attachment 319433 [details] Patch Clearing flags on attachment: 319433 Committed r221414: <http://trac.webkit.org/changeset/221414>
WebKit Commit Bot
Comment 15 2017-08-30 20:48:27 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 16 2017-09-03 20:35:36 PDT
Comment on attachment 319385 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=319385&action=review >> Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:119 >> + virtualPath.split('/', false /* allowEmpty */, components); > > auto + overload of split() would look nice :) You should use StringView::split, which makes a lot of separate StringView. No need to allocate all these strings just to build up a single string at the end. Do it all with StringView.
Note You need to log in before you can comment on or make changes to this bug.