[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kinuko at chromium.org kinuko at chromium.org
Wed Dec 22 13:48:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f65ffcd4c2328762698b1b12dc1fe0320366221f
Author: kinuko at chromium.org <kinuko at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Sep 27 19:05:05 2010 +0000

    2010-09-27  Kinuko Yasuda  <kinuko at chromium.org>
    
            Reviewed by Adam Barth.
    
            [Cleanup] Add create method to FileSystemCallbacks to get rid of naked new's
            https://bugs.webkit.org/show_bug.cgi?id=46561
    
            Also cleanup the callbacks layering to pass AsyncFileSystemCallbacks
            object to LocalFileSystem::requestFileSystem (rather than
            FileSystemCallback and ErrorCallback) so that all the callbacks class
            we pass from WebCore to WebKit/chromium/src will be
            AsyncFileSystemCallbacks.
    
            * src/LocalFileSystemChromium.cpp:
            (WebCore::LocalFileSystem::requestFileSystem): Changed to take
            AsyncFileSystemCallbacks as (a) callback argument(s).
    2010-09-27  Kinuko Yasuda  <kinuko at google.com>
    
            Reviewed by Adam Barth.
    
            [Cleanup] Add create method to FileSystemCallbacks to get rid of naked new's
            https://bugs.webkit.org/show_bug.cgi?id=46561
    
            Also cleanup the callbacks layering to pass AsyncFileSystemCallbacks
            object to LocalFileSystem::requestFileSystem (rather than
            FileSystemCallback and ErrorCallback) so that all the callbacks class
            we pass from WebCore to WebKit/chromium/src will be
            AsyncFileSystemCallbacks.
    
            No new tests; this patch is only for cleanup and there should be no functionality changes.
    
            * fileapi/DOMFileSystem.cpp:
            (WebCore::DOMFileSystem::getMetadata):
            (WebCore::DOMFileSystem::move):
            (WebCore::DOMFileSystem::copy):
            (WebCore::DOMFileSystem::remove):
            (WebCore::DOMFileSystem::getParent):
            (WebCore::DOMFileSystem::getFile):
            (WebCore::DOMFileSystem::getDirectory):
            (WebCore::DOMFileSystem::createWriter):
            (WebCore::DOMFileSystem::readDirectory):
            * fileapi/FileSystemCallbacks.cpp:
            (WebCore::EntryCallbacks::create): Added.
            (WebCore::EntriesCallbacks::create): Added.
            (WebCore::FileSystemCallbacks::create): Added.
            (WebCore::MetadataCallbacks::create): Added.
            (WebCore::FileWriterCallbacks::create): Added.
            (WebCore::VoidCallbacks::create): Added.
            * fileapi/FileSystemCallbacks.h:
            * fileapi/LocalFileSystem.cpp:
            (WebCore::openFileSystem):
            (WebCore::LocalFileSystem::requestFileSystem): Changed to take
            AsyncFileSystemCallbacks as (a) callback argument(s).
            * fileapi/LocalFileSystem.h:
            * page/DOMWindow.cpp:
            (WebCore::DOMWindow::requestFileSystem): Made a corresponding change
            to LocalFileSystem::requestFileSystem.
            * workers/WorkerContext.cpp:
            (WebCore::WorkerContext::requestFileSystem): Made a corresponding change
            to LocalFileSystem::requestFileSystem.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68411 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 71fb0c0..ebf62ef 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,48 @@
+2010-09-27  Kinuko Yasuda  <kinuko at google.com>
+
+        Reviewed by Adam Barth.
+
+        [Cleanup] Add create method to FileSystemCallbacks to get rid of naked new's
+        https://bugs.webkit.org/show_bug.cgi?id=46561
+
+        Also cleanup the callbacks layering to pass AsyncFileSystemCallbacks
+        object to LocalFileSystem::requestFileSystem (rather than
+        FileSystemCallback and ErrorCallback) so that all the callbacks class
+        we pass from WebCore to WebKit/chromium/src will be
+        AsyncFileSystemCallbacks.
+
+        No new tests; this patch is only for cleanup and there should be no functionality changes.
+
+        * fileapi/DOMFileSystem.cpp:
+        (WebCore::DOMFileSystem::getMetadata):
+        (WebCore::DOMFileSystem::move):
+        (WebCore::DOMFileSystem::copy):
+        (WebCore::DOMFileSystem::remove):
+        (WebCore::DOMFileSystem::getParent):
+        (WebCore::DOMFileSystem::getFile):
+        (WebCore::DOMFileSystem::getDirectory):
+        (WebCore::DOMFileSystem::createWriter):
+        (WebCore::DOMFileSystem::readDirectory):
+        * fileapi/FileSystemCallbacks.cpp:
+        (WebCore::EntryCallbacks::create): Added.
+        (WebCore::EntriesCallbacks::create): Added.
+        (WebCore::FileSystemCallbacks::create): Added.
+        (WebCore::MetadataCallbacks::create): Added.
+        (WebCore::FileWriterCallbacks::create): Added.
+        (WebCore::VoidCallbacks::create): Added.
+        * fileapi/FileSystemCallbacks.h:
+        * fileapi/LocalFileSystem.cpp:
+        (WebCore::openFileSystem):
+        (WebCore::LocalFileSystem::requestFileSystem): Changed to take
+        AsyncFileSystemCallbacks as (a) callback argument(s).
+        * fileapi/LocalFileSystem.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::requestFileSystem): Made a corresponding change
+        to LocalFileSystem::requestFileSystem.
+        * workers/WorkerContext.cpp:
+        (WebCore::WorkerContext::requestFileSystem): Made a corresponding change
+        to LocalFileSystem::requestFileSystem.
+
 2010-09-27  Abhishek Arya  <inferno at chromium.org>
 
         Reviewed by Dave Hyatt.
diff --git a/WebCore/fileapi/DOMFileSystem.cpp b/WebCore/fileapi/DOMFileSystem.cpp
index afd3e1e..2bd09c2 100644
--- a/WebCore/fileapi/DOMFileSystem.cpp
+++ b/WebCore/fileapi/DOMFileSystem.cpp
@@ -38,6 +38,7 @@
 #include "DirectoryEntry.h"
 #include "EntriesCallback.h"
 #include "Entry.h"
+#include "EntryArray.h"
 #include "EntryCallback.h"
 #include "ErrorCallback.h"
 #include "FileEntry.h"
@@ -87,7 +88,7 @@ void DOMFileSystem::contextDestroyed()
 void DOMFileSystem::getMetadata(const Entry* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
-    m_asyncFileSystem->readMetadata(platformPath, new MetadataCallbacks(successCallback, errorCallback));
+    m_asyncFileSystem->readMetadata(platformPath, MetadataCallbacks::create(successCallback, errorCallback));
 }
 
 static bool checkValidityForForCopyOrMove(const Entry* src, Entry* parent, const String& newName)
@@ -126,7 +127,7 @@ void DOMFileSystem::move(const Entry* src, PassRefPtr<Entry> parent, const Strin
 
     String srcPlatformPath = m_asyncFileSystem->virtualToPlatformPath(src->fullPath());
     String destPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destPath);
-    m_asyncFileSystem->move(srcPlatformPath, destPlatformPath, new EntryCallbacks(successCallback, errorCallback, this, destPath, src->isDirectory()));
+    m_asyncFileSystem->move(srcPlatformPath, destPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destPath, src->isDirectory()));
 }
 
 void DOMFileSystem::copy(const Entry* src, PassRefPtr<Entry> parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
@@ -144,14 +145,14 @@ void DOMFileSystem::copy(const Entry* src, PassRefPtr<Entry> parent, const Strin
 
     String srcPlatformPath = m_asyncFileSystem->virtualToPlatformPath(src->fullPath());
     String destPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destPath);
-    m_asyncFileSystem->copy(srcPlatformPath, destPlatformPath, new EntryCallbacks(successCallback, errorCallback, this, destPath, src->isDirectory()));
+    m_asyncFileSystem->copy(srcPlatformPath, destPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destPath, src->isDirectory()));
 }
 
 void DOMFileSystem::remove(const Entry* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
     ASSERT(entry);
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
-    m_asyncFileSystem->remove(platformPath, new VoidCallbacks(successCallback, errorCallback));
+    m_asyncFileSystem->remove(platformPath, VoidCallbacks::create(successCallback, errorCallback));
 }
 
 void DOMFileSystem::getParent(const Entry* entry, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
@@ -159,7 +160,7 @@ void DOMFileSystem::getParent(const Entry* entry, PassRefPtr<EntryCallback> succ
     ASSERT(entry);
     String path = DOMFilePath::getDirectory(entry->fullPath());
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
-    m_asyncFileSystem->directoryExists(platformPath, new EntryCallbacks(successCallback, errorCallback, this, path, true));
+    m_asyncFileSystem->directoryExists(platformPath, EntryCallbacks::create(successCallback, errorCallback, this, path, true));
 }
 
 void DOMFileSystem::getFile(const Entry* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
@@ -175,7 +176,7 @@ void DOMFileSystem::getFile(const Entry* base, const String& path, PassRefPtr<Fl
         absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
 
-    OwnPtr<EntryCallbacks> callbacks = adoptPtr(new EntryCallbacks(successCallback, errorCallback, this, absolutePath, false));
+    OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, false);
     if (flags && flags->isCreate())
         m_asyncFileSystem->createFile(platformPath, flags->isExclusive(), callbacks.release());
     else
@@ -195,7 +196,7 @@ void DOMFileSystem::getDirectory(const Entry* base, const String& path, PassRefP
         absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
 
-    OwnPtr<EntryCallbacks> callbacks = adoptPtr(new EntryCallbacks(successCallback, errorCallback, this, absolutePath, true));
+    OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, true);
     if (flags && flags->isCreate())
         m_asyncFileSystem->createDirectory(platformPath, flags->isExclusive(), callbacks.release());
     else
@@ -209,7 +210,7 @@ void DOMFileSystem::createWriter(const FileEntry* file, PassRefPtr<FileWriterCal
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(file->fullPath());
 
     RefPtr<FileWriter> fileWriter = FileWriter::create(scriptExecutionContext());
-    OwnPtr<FileWriterCallbacks> callbacks = adoptPtr(new FileWriterCallbacks(fileWriter, successCallback, errorCallback));
+    OwnPtr<FileWriterCallbacks> callbacks = FileWriterCallbacks::create(fileWriter, successCallback, errorCallback);
     m_asyncFileSystem->createWriter(fileWriter.get(), platformPath, callbacks.release());
 }
 
@@ -217,7 +218,7 @@ void DOMFileSystem::readDirectory(const String& path, PassRefPtr<EntriesCallback
 {
     ASSERT(DOMFilePath::isAbsolute(path));
     String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
-    m_asyncFileSystem->readDirectory(platformPath, new EntriesCallbacks(successCallback, errorCallback, this, path));
+    m_asyncFileSystem->readDirectory(platformPath, EntriesCallbacks::create(successCallback, errorCallback, this, path));
 }
 
 } // namespace
diff --git a/WebCore/fileapi/FileSystemCallbacks.cpp b/WebCore/fileapi/FileSystemCallbacks.cpp
index fcc860f..550b509 100644
--- a/WebCore/fileapi/FileSystemCallbacks.cpp
+++ b/WebCore/fileapi/FileSystemCallbacks.cpp
@@ -110,6 +110,11 @@ void FileSystemCallbacksBase::didFail(int code)
 
 // EntryCallbacks -------------------------------------------------------------
 
+PassOwnPtr<EntryCallbacks> EntryCallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& expectedPath, bool isDirectory)
+{
+    return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSystem, expectedPath, isDirectory));
+}
+
 EntryCallbacks::EntryCallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& expectedPath, bool isDirectory)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
@@ -132,6 +137,11 @@ void EntryCallbacks::didSucceed()
 
 // EntriesCallbacks -----------------------------------------------------------
 
+PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& basePath)
+{
+    return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, fileSystem, basePath));
+}
+
 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& basePath)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
@@ -164,6 +174,11 @@ void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
 
 // FileSystemCallbacks --------------------------------------------------------
 
+PassOwnPtr<FileSystemCallbacks> FileSystemCallbacks::create(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* scriptExecutionContext)
+{
+    return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, scriptExecutionContext));
+}
+
 FileSystemCallbacks::FileSystemCallbacks(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
@@ -183,6 +198,11 @@ void FileSystemCallbacks::didOpenFileSystem(const String& name, PassOwnPtr<Async
 
 // MetadataCallbacks ----------------------------------------------------------
 
+PassOwnPtr<MetadataCallbacks> MetadataCallbacks::create(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+{
+    return adoptPtr(new MetadataCallbacks(successCallback, errorCallback));
+}
+
 MetadataCallbacks::MetadataCallbacks(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
@@ -198,6 +218,11 @@ void MetadataCallbacks::didReadMetadata(double modificationTime)
 
 // FileWriterCallbacks ----------------------------------------------------------
 
+PassOwnPtr<FileWriterCallbacks> FileWriterCallbacks::create(PassRefPtr<FileWriter> fileWriter, PassRefPtr<FileWriterCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+{
+    return adoptPtr(new FileWriterCallbacks(fileWriter, successCallback, errorCallback));
+}
+
 FileWriterCallbacks::FileWriterCallbacks(PassRefPtr<FileWriter> fileWriter, PassRefPtr<FileWriterCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     : FileSystemCallbacksBase(errorCallback)
     , m_fileWriter(fileWriter)
@@ -215,6 +240,11 @@ void FileWriterCallbacks::didCreateFileWriter(PassOwnPtr<AsyncFileWriter> asyncF
 
 // VoidCallbacks --------------------------------------------------------------
 
+PassOwnPtr<VoidCallbacks> VoidCallbacks::create(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+{
+    return adoptPtr(new VoidCallbacks(successCallback, errorCallback));
+}
+
 VoidCallbacks::VoidCallbacks(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
diff --git a/WebCore/fileapi/FileSystemCallbacks.h b/WebCore/fileapi/FileSystemCallbacks.h
index a5e9560..3647ad3 100644
--- a/WebCore/fileapi/FileSystemCallbacks.h
+++ b/WebCore/fileapi/FileSystemCallbacks.h
@@ -85,10 +85,11 @@ protected:
 
 class EntryCallbacks : public FileSystemCallbacksBase {
 public:
-    EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& expectedPath, bool isDirectory);
+    static PassOwnPtr<EntryCallbacks> create(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& expectedPath, bool isDirectory);
     virtual void didSucceed();
 
 private:
+    EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& expectedPath, bool isDirectory);
     RefPtr<EntryCallback> m_successCallback;
     DOMFileSystem* m_fileSystem;
     String m_expectedPath;
@@ -97,11 +98,12 @@ private:
 
 class EntriesCallbacks : public FileSystemCallbacksBase {
 public:
-    EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& basePath);
+    static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& basePath);
     virtual void didReadDirectoryEntry(const String& name, bool isDirectory);
     virtual void didReadDirectoryEntries(bool hasMore);
 
 private:
+    EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& basePath);
     RefPtr<EntriesCallback> m_successCallback;
     DOMFileSystem* m_fileSystem;
     String m_basePath;
@@ -110,39 +112,43 @@ private:
 
 class FileSystemCallbacks : public FileSystemCallbacksBase {
 public:
-    FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*);
+    static PassOwnPtr<FileSystemCallbacks> create(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*);
     virtual void didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem>);
 
 private:
+    FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*);
     RefPtr<FileSystemCallback> m_successCallback;
     RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
 };
 
 class MetadataCallbacks : public FileSystemCallbacksBase {
 public:
-    MetadataCallbacks(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>);
+    static PassOwnPtr<MetadataCallbacks> create(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>);
     virtual void didReadMetadata(double modificationTime);
 
 private:
+    MetadataCallbacks(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>);
     RefPtr<MetadataCallback> m_successCallback;
 };
 
 class FileWriterCallbacks : public FileSystemCallbacksBase {
 public:
-    FileWriterCallbacks(PassRefPtr<FileWriter>, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>);
+    static PassOwnPtr<FileWriterCallbacks> create(PassRefPtr<FileWriter>, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>);
     virtual void didCreateFileWriter(PassOwnPtr<AsyncFileWriter>, long long length);
 
 private:
+    FileWriterCallbacks(PassRefPtr<FileWriter>, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>);
     RefPtr<FileWriter> m_fileWriter;
     RefPtr<FileWriterCallback> m_successCallback;
 };
 
 class VoidCallbacks : public FileSystemCallbacksBase {
 public:
-    VoidCallbacks(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
+    static PassOwnPtr<VoidCallbacks> create(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
     virtual void didSucceed();
 
 private:
+    VoidCallbacks(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
     RefPtr<VoidCallback> m_successCallback;
 };
 
diff --git a/WebCore/fileapi/LocalFileSystem.cpp b/WebCore/fileapi/LocalFileSystem.cpp
index f826b71..567aafe 100644
--- a/WebCore/fileapi/LocalFileSystem.cpp
+++ b/WebCore/fileapi/LocalFileSystem.cpp
@@ -76,20 +76,15 @@ String LocalFileSystem::fileSystemBasePath() const
     return m_basePath;
 }
 
-static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, AsyncFileSystem::Type type, PassOwnPtr<FileSystemCallbacks> callbacks)
+static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     AsyncFileSystem::openFileSystem(basePath, identifier, type, callbacks);
 }
 
-void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    if (type != AsyncFileSystem::Temporary && type != AsyncFileSystem::Persistent) {
-        DOMFileSystem::scheduleCallback(context, errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
-        return;
-    }
-
     // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
-    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, new FileSystemCallbacks(successCallback, errorCallback, context)));
+    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, callbacks));
 }
 
 } // namespace
diff --git a/WebCore/fileapi/LocalFileSystem.h b/WebCore/fileapi/LocalFileSystem.h
index d08d0f0..bb1d045 100644
--- a/WebCore/fileapi/LocalFileSystem.h
+++ b/WebCore/fileapi/LocalFileSystem.h
@@ -52,7 +52,7 @@ public:
     // calling this one.
     static LocalFileSystem& localFileSystem();
 
-    void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
+    void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassOwnPtr<AsyncFileSystemCallbacks>);
 
 #if !PLATFORM(CHROMIUM)
     // This call is not thread-safe; must be called before any worker threads are created.
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 3a7bb93..5efaea7 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -93,6 +93,7 @@
 #include "ErrorCallback.h"
 #include "FileError.h"
 #include "FileSystemCallback.h"
+#include "FileSystemCallbacks.h"
 #include "LocalFileSystem.h"
 #endif
 
@@ -732,7 +733,13 @@ void DOMWindow::requestFileSystem(int type, long long size, PassRefPtr<FileSyste
         return;
     }
 
-    LocalFileSystem::localFileSystem().requestFileSystem(document, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
+    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
+    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
+        DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
+        return;
+    }
+
+    LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document));
 }
 
 COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
diff --git a/WebCore/workers/WorkerContext.cpp b/WebCore/workers/WorkerContext.cpp
index 4964d05..6cee246 100644
--- a/WebCore/workers/WorkerContext.cpp
+++ b/WebCore/workers/WorkerContext.cpp
@@ -69,6 +69,7 @@
 #include "ErrorCallback.h"
 #include "FileError.h"
 #include "FileSystemCallback.h"
+#include "FileSystemCallbacks.h"
 #include "LocalFileSystem.h"
 #endif
 
@@ -356,7 +357,13 @@ void WorkerContext::requestFileSystem(int type, long long size, PassRefPtr<FileS
         return;
     }
 
-    LocalFileSystem::localFileSystem().requestFileSystem(this, static_cast<AsyncFileSystem::Type>(type), size, successCallback, errorCallback);
+    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
+    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
+        DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
+        return;
+    }
+
+    LocalFileSystem::localFileSystem().requestFileSystem(this, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, this));
 }
 
 COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index ded70b7..2489dde 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-27  Kinuko Yasuda  <kinuko at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        [Cleanup] Add create method to FileSystemCallbacks to get rid of naked new's
+        https://bugs.webkit.org/show_bug.cgi?id=46561
+
+        Also cleanup the callbacks layering to pass AsyncFileSystemCallbacks
+        object to LocalFileSystem::requestFileSystem (rather than
+        FileSystemCallback and ErrorCallback) so that all the callbacks class
+        we pass from WebCore to WebKit/chromium/src will be
+        AsyncFileSystemCallbacks.
+
+        * src/LocalFileSystemChromium.cpp:
+        (WebCore::LocalFileSystem::requestFileSystem): Changed to take
+        AsyncFileSystemCallbacks as (a) callback argument(s).
+
 2010-09-24  Tony Chang  <tony at chromium.org>
 
         Reviewed by Kent Tamura.
diff --git a/WebKit/chromium/src/LocalFileSystemChromium.cpp b/WebKit/chromium/src/LocalFileSystemChromium.cpp
index 994f310..7bf4335 100644
--- a/WebKit/chromium/src/LocalFileSystemChromium.cpp
+++ b/WebKit/chromium/src/LocalFileSystemChromium.cpp
@@ -57,18 +57,18 @@ LocalFileSystem& LocalFileSystem::localFileSystem()
     return *localFileSystem;
 }
 
-void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
+void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     ASSERT(context);
     if (context->isDocument()) {
         Document* document = static_cast<Document*>(context);
         WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
-        webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(new FileSystemCallbacks(successCallback, errorCallback, context)));
+        webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks));
     } else {
         WorkerContext* workerContext = static_cast<WorkerContext*>(context);
         WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
         WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
-        webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(new FileSystemCallbacks(successCallback, errorCallback, context)));
+        webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks));
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list