Changeset 68735 in webkit
- Timestamp:
- Sep 29, 2010 6:16:43 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r68733 r68735 1 2010-09-29 Kinuko Yasuda <kinuko@chromium.org> 2 3 Reviewed by David Levin. 4 5 Fix DirectoryReader's behavior to trigger only one EntriesCallback per readEntries 6 https://bugs.webkit.org/show_bug.cgi?id=46563 7 8 * fast/filesystem/flags-passing.html: Updated to make it match 9 with the updated TEMPLATE.html. 10 * fast/filesystem/flags-passing-expected.txt: Updated. 11 * fast/filesystem/read-directory.html: Added. 12 * fast/filesystem/read-directory-expected.txt: Added. 13 * fast/filesystem/resources/fs-test-util.js: Added for common test 14 utilities. 15 * fast/filesystem/script-tests/TEMPLATE.html: Updated to include 16 fs-test-util.js. 17 * fast/filesystem/script-tests/flags-passing.js: Updated to use 18 jsTestIsAsync and finishJSTest (so that all the tests look alike). 19 * fast/filesystem/script-tests/read-directory.js: Added. 20 1 21 2010-09-29 MORITA Hajime <morrita@google.com> 2 22 -
trunk/LayoutTests/fast/filesystem/flags-passing-expected.txt
r68105 r68735 4 4 5 5 6 PASS successfullyParsed is true7 8 TEST COMPLETE9 6 * Passing a Flags object. 10 7 * Recycling the same Flags object. … … 15 12 PASS expectedCallbacksCount is 3 16 13 PASS unexpectedCallbacksCount is 0 14 PASS successfullyParsed is true 17 15 16 TEST COMPLETE 17 -
trunk/LayoutTests/fast/filesystem/flags-passing.html
r68105 r68735 3 3 <link rel="stylesheet" href="../js/resources/js-test-style.css"> 4 4 <script src="../js/resources/js-test-pre.js"></script> 5 <script src="resources/fs-test-util.js"></script> 5 6 </head> 6 7 <body> -
trunk/LayoutTests/fast/filesystem/script-tests/TEMPLATE.html
r68105 r68735 3 3 <link rel="stylesheet" href="../js/resources/js-test-style.css"> 4 4 <script src="../js/resources/js-test-pre.js"></script> 5 <script src="resources/fs-test-util.js"></script> 5 6 </head> 6 7 <body> -
trunk/LayoutTests/fast/filesystem/script-tests/flags-passing.js
r68105 r68735 17 17 var testCounter = 0; 18 18 19 function endTest() {20 debug("Finished running tests.");21 shouldBe('expectedCallbacksCount', '3');22 shouldBe('unexpectedCallbacksCount', '0');23 if (window.layoutTestController)24 layoutTestController.notifyDone();25 }26 27 19 function runNextTest(v) { 28 if (testCounter == testsList.length) 29 endTest(); 30 else 20 if (testCounter == testsList.length) { 21 debug("Finished running tests."); 22 shouldBe('expectedCallbacksCount', '3'); 23 shouldBe('unexpectedCallbacksCount', '0'); 24 finishJSTest(); 25 } else 31 26 this[testsList[testCounter++]](); 32 27 } … … 34 29 function errorCallback(error) { 35 30 debug("Error occured during requesting Temporary FileSystem:" + error.code); 36 37 if (window.layoutTestController) 38 layoutTestController.notifyDone(); 31 finishJSTest(); 39 32 } 40 33 … … 94 87 95 88 if (window.requestFileSystem) { 96 if (window.layoutTestController)97 layoutTestController.waitUntilDone();98 99 89 requestFileSystem(window.TEMPORARY, 100, fileSystemCallback, errorCallback); 90 window.jsTestIsAsync = true; 100 91 } else 101 92 debug("This test requires FileSystem API support."); 102 93 103 varsuccessfullyParsed = true;94 window.successfullyParsed = true; -
trunk/WebCore/ChangeLog
r68734 r68735 1 2010-09-29 Kinuko Yasuda <kinuko@chromium.org> 2 3 Reviewed by David Levin. 4 5 Fix DirectoryReader's behavior to trigger only one EntriesCallback per readEntries 6 https://bugs.webkit.org/show_bug.cgi?id=46563 7 8 Test: fast/filesystem/read-directory.html 9 10 * fileapi/DOMFileSystem.cpp: 11 (WebCore::DOMFileSystem::readDirectory): Changed to take DirectoryReader 12 as a parameter. 13 * fileapi/DOMFileSystem.h: 14 (WebCore::DOMFileSystem::scheduleCallback): Added. 15 * fileapi/DirectoryReader.cpp: 16 (WebCore::DirectoryReader::DirectoryReader): Added initializer for 17 m_hasMore flag. 18 (WebCore::DirectoryReader::readEntries): Changed to schedule 19 EntriesCallback with an empty array if m_hasMore flag is set false. 20 * fileapi/DirectoryReader.h: 21 (WebCore::DirectoryReader::filesystem): Added. 22 (WebCore::DirectoryReader::setHasMore): Added. 23 * fileapi/FileSystemCallbacks.cpp: 24 (WebCore::EntriesCallbacks::create): 25 (WebCore::EntriesCallbacks::EntriesCallbacks): Changed to take 26 DirectoryReader as a parameter. 27 (WebCore::EntriesCallbacks::didReadDirectoryEntry): 28 (WebCore::EntriesCallbacks::didReadDirectoryEntries): Changed 1) not to 29 trigger the second callback when hasMore is false, and 2) to update 30 the DirectoryReader's m_hasMore flag. 31 * fileapi/FileSystemCallbacks.h: 32 1 33 2010-09-29 Chris Rogers <crogers@google.com> 2 34 -
trunk/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
r68105 r68735 71 71 } 72 72 } else { 73 EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);74 flags = tmp_flags;73 EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0); 74 flags = tmp_flags; 75 75 } 76 76 RefPtr<EntryCallback> successCallback; -
trunk/WebCore/fileapi/DOMFileSystem.cpp
r68411 r68735 215 215 } 216 216 217 void DOMFileSystem::readDirectory( const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)217 void DOMFileSystem::readDirectory(DirectoryReader* reader, const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) 218 218 { 219 219 ASSERT(DOMFilePath::isAbsolute(path)); 220 220 String platformPath = m_asyncFileSystem->virtualToPlatformPath(path); 221 m_asyncFileSystem->readDirectory(platformPath, EntriesCallbacks::create(successCallback, errorCallback, this, path));221 m_asyncFileSystem->readDirectory(platformPath, EntriesCallbacks::create(successCallback, errorCallback, reader, path)); 222 222 } 223 223 -
trunk/WebCore/fileapi/DOMFileSystem.h
r68101 r68735 45 45 46 46 class DirectoryEntry; 47 class DirectoryReader; 47 48 class Entry; 48 49 class EntryCallback; … … 79 80 void getFile(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>); 80 81 void getDirectory(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>); 81 void readDirectory( const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>);82 void readDirectory(DirectoryReader* reader, const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>); 82 83 void createWriter(const FileEntry* file, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>); 83 84 84 85 // Schedule a callback. This should not cross threads (should be called on the same context thread). 86 // FIXME: move this to a more generic place. 85 87 template <typename CB, typename CBArg> 86 88 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRefPtr<CBArg>); 89 90 template <typename CB, typename CBArg> 91 void scheduleCallback(PassRefPtr<CB> callback, PassRefPtr<CBArg> callbackArg) 92 { 93 scheduleCallback(scriptExecutionContext(), callback, callbackArg); 94 } 87 95 88 96 private: -
trunk/WebCore/fileapi/DirectoryReader.cpp
r66586 r68735 36 36 #include "DOMFileSystem.h" 37 37 #include "EntriesCallback.h" 38 #include "EntryArray.h" 38 39 #include "ErrorCallback.h" 39 40 … … 43 44 : m_fileSystem(fileSystem) 44 45 , m_fullPath(fullPath) 46 , m_hasMore(true) 45 47 { 46 48 } … … 48 50 void DirectoryReader::readEntries(PassRefPtr<EntriesCallback> entriesCallback, PassRefPtr<ErrorCallback> errorCallback) 49 51 { 50 m_fileSystem->readDirectory(m_fullPath, entriesCallback, errorCallback); 52 if (!m_hasMore) { 53 m_fileSystem->scheduleCallback(entriesCallback, EntryArray::create()); 54 return; 55 } 56 m_fileSystem->readDirectory(this, m_fullPath, entriesCallback, errorCallback); 51 57 } 52 58 -
trunk/WebCore/fileapi/DirectoryReader.h
r66586 r68735 42 42 43 43 class EntriesCallback; 44 class EntriesCallbacks; 44 45 class ErrorCallback; 45 46 … … 51 52 } 52 53 53 void readEntries(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback = 0); 54 DOMFileSystem* filesystem() const { return m_fileSystem.get(); } 55 void readEntries(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback> = 0); 56 void setHasMore(bool hasMore) { m_hasMore = hasMore; } 54 57 55 58 private: … … 58 61 RefPtr<DOMFileSystem> m_fileSystem; 59 62 String m_fullPath; 63 bool m_hasMore; 60 64 }; 61 65 -
trunk/WebCore/fileapi/FileSystemCallbacks.cpp
r68411 r68735 39 39 #include "DOMFileSystem.h" 40 40 #include "DirectoryEntry.h" 41 #include "DirectoryReader.h" 41 42 #include "EntriesCallback.h" 42 43 #include "EntryArray.h" … … 138 139 // EntriesCallbacks ----------------------------------------------------------- 139 140 140 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, D OMFileSystem* fileSystem, const String& basePath)141 { 142 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, fileSystem, basePath));143 } 144 145 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, D OMFileSystem* fileSystem, const String& basePath)146 : FileSystemCallbacksBase(errorCallback) 147 , m_successCallback(successCallback) 148 , m_ fileSystem(fileSystem)141 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader* directoryReader, const String& basePath) 142 { 143 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directoryReader, basePath)); 144 } 145 146 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader* directoryReader, const String& basePath) 147 : FileSystemCallbacksBase(errorCallback) 148 , m_successCallback(successCallback) 149 , m_directoryReader(directoryReader) 149 150 , m_basePath(basePath) 150 151 , m_entries(EntryArray::create()) 151 152 { 153 ASSERT(m_directoryReader); 152 154 } 153 155 … … 155 157 { 156 158 if (isDirectory) 157 m_entries->append(DirectoryEntry::create(m_ fileSystem, DOMFilePath::append(m_basePath, name)));159 m_entries->append(DirectoryEntry::create(m_directoryReader->filesystem(), DOMFilePath::append(m_basePath, name))); 158 160 else 159 m_entries->append(FileEntry::create(m_ fileSystem, DOMFilePath::append(m_basePath, name)));161 m_entries->append(FileEntry::create(m_directoryReader->filesystem(), DOMFilePath::append(m_basePath, name))); 160 162 } 161 163 162 164 void EntriesCallbacks::didReadDirectoryEntries(bool hasMore) 163 165 { 164 if (m_successCallback) { 166 m_directoryReader->setHasMore(hasMore); 167 if (m_successCallback) 165 168 m_successCallback->handleEvent(m_entries.get()); 166 if (!m_entries->isEmpty() && !hasMore) {167 // If we have returned some entries and there're no more coming entries (hasMore==false), call back once more with an empty array.168 m_successCallback->handleEvent(EntryArray::create().get());169 m_successCallback.clear();170 }171 m_entries->clear();172 }173 169 } 174 170 -
trunk/WebCore/fileapi/FileSystemCallbacks.h
r68411 r68735 43 43 class AsyncFileWriter; 44 44 class DOMFileSystem; 45 class DirectoryReader; 45 46 class ErrorCallback; 46 47 class EntriesCallback; … … 99 100 class EntriesCallbacks : public FileSystemCallbacksBase { 100 101 public: 101 static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, D OMFileSystem*, const String& basePath);102 static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReader*, const String& basePath); 102 103 virtual void didReadDirectoryEntry(const String& name, bool isDirectory); 103 104 virtual void didReadDirectoryEntries(bool hasMore); 104 105 105 106 private: 106 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, D OMFileSystem*, const String& basePath);107 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReader*, const String& basePath); 107 108 RefPtr<EntriesCallback> m_successCallback; 108 D OMFileSystem* m_fileSystem;109 DirectoryReader* m_directoryReader; 109 110 String m_basePath; 110 111 RefPtr<EntryArray> m_entries; -
trunk/WebKit/chromium/ChangeLog
r68700 r68735 1 2010-09-29 Kinuko Yasuda <kinuko@chromium.org> 2 3 Reviewed by David Levin. 4 5 Fix DirectoryReader's behavior to trigger only one EntriesCallback per readEntries 6 https://bugs.webkit.org/show_bug.cgi?id=46563 7 8 * src/WebFileSystemCallbacksImpl.cpp: 9 (WebKit::WebFileSystemCallbacksImpl::didReadDirectory): 10 1 11 2010-09-29 Tony Chang <tony@chromium.org> 2 12 -
trunk/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp
r68669 r68735 74 74 m_callbacks->didReadDirectoryEntry(entries[i].name, entries[i].isDirectory); 75 75 m_callbacks->didReadDirectoryEntries(hasMore); 76 if (!hasMore) 77 delete this; 76 delete this; 78 77 } 79 78
Note: See TracChangeset
for help on using the changeset viewer.