Commit 35a4a326 authored by kinuko@chromium.org's avatar kinuko@chromium.org

2010-09-09 Kinuko Yasuda <kinuko@chromium.org>

        Reviewed by Dumitru Daniliuc.

        [FileSystem] Do not call EntriesCallback more than once if there're no entries.
        https://bugs.webkit.org/show_bug.cgi?id=45498

        No new tests, layout-tests that confirm the behavior will be added in later patches.

        * fileapi/FileSystemCallbacks.cpp:
        (WebCore::EntriesCallbacks::EntriesCallbacks):
        (WebCore::EntriesCallbacks::didReadDirectoryEntry):
        (WebCore::EntriesCallbacks::didReadDirectoryEntries):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 01ee2ed9
2010-09-09 Kinuko Yasuda <kinuko@chromium.org>
Reviewed by Dumitru Daniliuc.
[FileSystem] Do not call EntriesCallback more than once if there're no entries.
https://bugs.webkit.org/show_bug.cgi?id=45498
No new tests, layout-tests that confirm the behavior will be added in later patches.
* fileapi/FileSystemCallbacks.cpp:
(WebCore::EntriesCallbacks::EntriesCallbacks):
(WebCore::EntriesCallbacks::didReadDirectoryEntry):
(WebCore::EntriesCallbacks::didReadDirectoryEntries):
2010-09-10 Patrick Gansterer <paroga@paroga.com>
Reviewed by Darin Adler.
......@@ -61,7 +61,7 @@ String DOMFilePath::getName(const String& path)
{
int index = path.reverseFind(DOMFilePath::separator);
if (index != -1)
return path.substring(index);
return path.substring(index + 1);
return path;
}
......
......@@ -45,12 +45,8 @@ namespace WebCore {
Entry::Entry(DOMFileSystem* fileSystem, const String& fullPath)
: m_fileSystem(fileSystem)
, m_fullPath(fullPath)
, m_name(DOMFilePath::getName(fullPath))
{
size_t index = fullPath.reverseFind("/");
if (index != notFound)
m_name = fullPath.substring(index);
else
m_name = fullPath;
}
void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
......
......@@ -128,13 +128,12 @@ EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback,
, m_successCallback(successCallback)
, m_fileSystem(fileSystem)
, m_basePath(basePath)
, m_entries(EntryArray::create())
{
}
void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirectory)
{
if (!m_entries)
m_entries = EntryArray::create();
if (isDirectory)
m_entries->append(DirectoryEntry::create(m_fileSystem, DOMFilePath::append(m_basePath, name)));
else
......@@ -143,15 +142,14 @@ void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector
void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
{
ASSERT(m_entries);
if (m_successCallback) {
m_successCallback->handleEvent(m_entries.get());
m_entries->clear();
if (!hasMore) {
// If there're no more entries, call back once more with an empty array.
m_successCallback->handleEvent(m_entries.get());
if (!m_entries->isEmpty() && !hasMore) {
// If we have returned some entries and there're no more coming entries (hasMore==false), call back once more with an empty array.
m_successCallback->handleEvent(EntryArray::create().get());
m_successCallback.clear();
}
m_entries->clear();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment