Changeset 105395 in webkit


Ignore:
Timestamp:
Jan 19, 2012 1:58:56 AM (12 years ago)
Author:
kinuko@chromium.org
Message:

Cleanup: Move chrome-specific filesystem type handling code (for FileSystem API) under chromium directory
https://bugs.webkit.org/show_bug.cgi?id=76551

Reviewed by Darin Fisher.

WebKit-svn/Source/WebCore:

Moved the implementation of crackFileSystemURL() and toURL() from
WebCore/fileapi/DOMFileSystemBase into WebCore/platform/AsyncFileSystem
so that each platform can extend/implement their behavior if necessary.

No new tests since this patch has no functionality changes. (Existing
tests should pass)

  • fileapi/DOMFileSystemBase.cpp: Moved the implementation of

crackFileSystemURL() to AsyncFileSystem
(WebCore::DOMFileSystemBase::crackFileSystemURL):

  • fileapi/DOMFileSystemBase.h:
  • fileapi/EntryBase.cpp: Moved the implementation of toURL() to AsyncFileSystem

(WebCore::EntryBase::toURL):

  • page/DOMWindow.cpp: Removed chrome-specific type handling code.

(WebCore::DOMWindow::webkitRequestFileSystem):

  • page/DOMWindow.h: Removed chrome-specific filesystem type

(EXTERNAL).

  • platform/AsyncFileSystem.cpp: Added default implementation of toURL() and crackFileSystemURL()

(WebCore::AsyncFileSystem::toURL):
(WebCore::AsyncFileSystem::crackFileSystemURL):

  • platform/AsyncFileSystem.h:
  • workers/WorkerContext.cpp: Removed chrome-specific type handling code.

(WebCore::WorkerContext::webkitRequestFileSystem):
(WebCore::WorkerContext::webkitRequestFileSystemSync):

WebKit-svn/Source/WebKit/chromium:

  • src/AssertMatchingEnums.cpp: Removed matching assertion for TypeExternal as it's no longer defined separately.
  • src/AsyncFileSystemChromium.cpp: Added crackFileSystemURL() and toURL() implementation that

handle chrome-specific filesystem type (EXTERNAL) as well as regular TEMPORARY/PERSISTENT types.
(WebCore::AsyncFileSystem::crackFileSystemURL): Added.
(WebCore::AsyncFileSystemChromium::toURL): Added.

  • src/AsyncFileSystemChromium.h:
Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r105394 r105395  
     12012-01-18  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Cleanup: Move chrome-specific filesystem type handling code (for FileSystem API) under chromium directory
     4        https://bugs.webkit.org/show_bug.cgi?id=76551
     5
     6        Reviewed by Darin Fisher.
     7
     8        Moved the implementation of crackFileSystemURL() and toURL() from
     9        WebCore/fileapi/DOMFileSystemBase into WebCore/platform/AsyncFileSystem
     10        so that each platform can extend/implement their behavior if necessary.
     11
     12        No new tests since this patch has no functionality changes. (Existing
     13        tests should pass)
     14
     15        * fileapi/DOMFileSystemBase.cpp: Moved the implementation of
     16        crackFileSystemURL() to AsyncFileSystem
     17        (WebCore::DOMFileSystemBase::crackFileSystemURL):
     18        * fileapi/DOMFileSystemBase.h:
     19        * fileapi/EntryBase.cpp: Moved the implementation of toURL() to AsyncFileSystem
     20        (WebCore::EntryBase::toURL):
     21        * page/DOMWindow.cpp: Removed chrome-specific type handling code.
     22        (WebCore::DOMWindow::webkitRequestFileSystem):
     23        * page/DOMWindow.h: Removed chrome-specific filesystem type
     24        (EXTERNAL).
     25        * platform/AsyncFileSystem.cpp: Added default implementation of toURL() and crackFileSystemURL()
     26        (WebCore::AsyncFileSystem::toURL):
     27        (WebCore::AsyncFileSystem::crackFileSystemURL):
     28        * platform/AsyncFileSystem.h:
     29        * workers/WorkerContext.cpp: Removed chrome-specific type handling code.
     30        (WebCore::WorkerContext::webkitRequestFileSystem):
     31        (WebCore::WorkerContext::webkitRequestFileSystemSync):
     32
    1332012-01-19  Mihnea Ovidenie  <mihnea@adobe.com>
    234
     
    15141546        * platform/image-decoders/skia/ImageDecoderSkia.cpp:
    15151547        (WebCore::ImageFrame::setStatus):
    1516 
    151715482012-01-17  Nate Chapin  <japhet@chromium.org>
    15181549
  • trunk/Source/WebCore/fileapi/DOMFileSystemBase.cpp

    r96779 r105395  
    5151namespace WebCore {
    5252
    53 const char DOMFileSystemBase::kPersistentPathPrefix[] = "persistent";
    54 const size_t DOMFileSystemBase::kPersistentPathPrefixLength = sizeof(DOMFileSystemBase::kPersistentPathPrefix) - 1;
    55 const char DOMFileSystemBase::kTemporaryPathPrefix[] = "temporary";
    56 const size_t DOMFileSystemBase::kTemporaryPathPrefixLength = sizeof(DOMFileSystemBase::kTemporaryPathPrefix) - 1;
    57 const char DOMFileSystemBase::kExternalPathPrefix[] = "external";
    58 const size_t DOMFileSystemBase::kExternalPathPrefixLength = sizeof(DOMFileSystemBase::kExternalPathPrefix) - 1;
    59 
     53// static
    6054bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, AsyncFileSystem::Type& type, String& filePath)
    6155{
    62     if (!url.protocolIs("filesystem"))
    63         return false;
    64 
    65     KURL originURL(ParsedURLString, url.path());
    66     String path = decodeURLEscapeSequences(originURL.path());
    67     if (path.isEmpty() || path[0] != '/')
    68         return false;
    69     path = path.substring(1);
    70 
    71     if (path.startsWith(kTemporaryPathPrefix)) {
    72         type = AsyncFileSystem::Temporary;
    73         path = path.substring(kTemporaryPathPrefixLength);
    74     } else if (path.startsWith(kPersistentPathPrefix)) {
    75         type = AsyncFileSystem::Persistent;
    76         path = path.substring(kPersistentPathPrefixLength);
    77     } else if (path.startsWith(kExternalPathPrefix)) {
    78         type = AsyncFileSystem::External;
    79         path = path.substring(kExternalPathPrefixLength);
    80     } else
    81         return false;
    82 
    83     if (path.isEmpty() || path[0] != '/')
    84         return false;
    85 
    86     filePath.swap(path);
    87     return true;
     56    return AsyncFileSystem::crackFileSystemURL(url, type, filePath);
    8857}
    8958
  • trunk/Source/WebCore/fileapi/DOMFileSystemBase.h

    r95901 r105395  
    6363    virtual ~DOMFileSystemBase();
    6464
    65     static const char kPersistentPathPrefix[];
    66     static const size_t kPersistentPathPrefixLength;
    67     static const char kTemporaryPathPrefix[];
    68     static const size_t kTemporaryPathPrefixLength;
    69     static const char kExternalPathPrefix[];
    70     static const size_t kExternalPathPrefixLength;
    7165    static bool crackFileSystemURL(const KURL&, AsyncFileSystem::Type&, String& filePath);
    7266
  • trunk/Source/WebCore/fileapi/EntryBase.cpp

    r95901 r105395  
    4040#include "SecurityOrigin.h"
    4141#include <wtf/PassRefPtr.h>
    42 #include <wtf/text/StringBuilder.h>
    4342
    4443namespace WebCore {
     
    5756String EntryBase::toURL()
    5857{
    59     String originString = m_fileSystem->securityOrigin()->toString();
    60     ASSERT(!originString.isEmpty());
    61     if (originString == "null")
    62         return String();
    63     StringBuilder result;
    64     result.append("filesystem:");
    65     result.append(originString);
    66     result.append("/");
    67     switch (m_fileSystem->asyncFileSystem()->type()) {
    68     case AsyncFileSystem::Temporary:
    69         result.append(DOMFileSystemBase::kTemporaryPathPrefix);
    70         break;
    71     case AsyncFileSystem::Persistent:
    72         result.append(DOMFileSystemBase::kPersistentPathPrefix);
    73         break;
    74     case AsyncFileSystem::External:
    75         result.append(DOMFileSystemBase::kExternalPathPrefix);
    76         break;
    77     }
    78     result.append(m_fullPath);
    79     return result.toString();
     58    return m_fileSystem->asyncFileSystem()->toURL(m_fileSystem->securityOrigin()->toString(), m_fullPath);
    8059}
    8160
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r105310 r105395  
    786786
    787787    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
    788     if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent && fileSystemType != AsyncFileSystem::External) {
     788    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
    789789        DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
    790790        return;
     
    819819    LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
    820820}
    821 
    822 COMPILE_ASSERT(static_cast<int>(DOMWindow::EXTERNAL) == static_cast<int>(AsyncFileSystem::External), enum_mismatch);
    823821
    824822COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
  • trunk/Source/WebCore/page/DOMWindow.h

    r104654 r105395  
    371371            TEMPORARY,
    372372            PERSISTENT,
    373             EXTERNAL,
    374373        };
    375374        void webkitRequestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
  • trunk/Source/WebCore/platform/AsyncFileSystem.cpp

    r95901 r105395  
    3737#include "FileSystem.h"
    3838#include "NotImplemented.h"
     39#include <wtf/text/StringBuilder.h>
    3940
    4041namespace WebCore {
     42
     43const char AsyncFileSystem::kPersistentPathPrefix[] = "persistent";
     44const size_t AsyncFileSystem::kPersistentPathPrefixLength = sizeof(AsyncFileSystem::kPersistentPathPrefix) - 1;
     45const char AsyncFileSystem::kTemporaryPathPrefix[] = "temporary";
     46const size_t AsyncFileSystem::kTemporaryPathPrefixLength = sizeof(AsyncFileSystem::kTemporaryPathPrefix) - 1;
     47
     48String AsyncFileSystem::toURL(const String& originString, const String& fullPath)
     49{
     50    StringBuilder result;
     51    result.append("filesystem:");
     52    result.append(originString);
     53    result.append("/");
     54    switch (type()) {
     55    case Temporary:
     56        result.append(kTemporaryPathPrefix);
     57        break;
     58    case Persistent:
     59        result.append(kPersistentPathPrefix);
     60        break;
     61    }
     62    result.append(fullPath);
     63    return result.toString();
     64}
    4165
    4266#if !PLATFORM(CHROMIUM)
     
    4569    notImplemented();
    4670    return false;
     71}
     72
     73bool AsyncFileSystem::crackFileSystemURL(const KURL& url, AsyncFileSystem::Type& type, String& filePath)
     74{
     75    if (!url.protocolIs("filesystem"))
     76        return false;
     77
     78    KURL originURL(ParsedURLString, url.path());
     79    String path = decodeURLEscapeSequences(originURL.path());
     80    if (path.isEmpty() || path[0] != '/')
     81        return false;
     82    path = path.substring(1);
     83
     84    if (path.startsWith(kTemporaryPathPrefix)) {
     85        type = Temporary;
     86        path = path.substring(kTemporaryPathPrefixLength);
     87    } else if (path.startsWith(kPersistentPathPrefix)) {
     88        type = Persistent;
     89        path = path.substring(kPersistentPathPrefixLength);
     90    } else
     91        return false;
     92
     93    if (path.isEmpty() || path[0] != '/')
     94        return false;
     95
     96    filePath.swap(path);
     97    return true;
    4798}
    4899
  • trunk/Source/WebCore/platform/AsyncFileSystem.h

    r95901 r105395  
    5555        Temporary,
    5656        Persistent,
    57         External,
    5857    };
    5958
     
    6261
    6362    static bool isAvailable();
     63
     64    // Path prefixes that are used in the filesystem URLs (that can be obtained by toURL()).
     65    // http://www.w3.org/TR/file-system-api/#widl-Entry-toURL
     66    static const char kPersistentPathPrefix[];
     67    static const size_t kPersistentPathPrefixLength;
     68    static const char kTemporaryPathPrefix[];
     69    static const size_t kTemporaryPathPrefixLength;
     70
     71    static bool crackFileSystemURL(const KURL&, AsyncFileSystem::Type&, String& filePath);
     72
     73    // Returns the filesystem URL for the given originString and fullPath.
     74    virtual String toURL(const String& originString, const String& fullPath);
    6475
    6576    // Subclass must implement this if it supports synchronous operations.
  • trunk/Source/WebCore/workers/WorkerContext.cpp

    r104803 r105395  
    396396
    397397    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
    398     if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent && fileSystemType != AsyncFileSystem::External) {
     398    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
    399399        DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
    400400        return;
     
    413413
    414414    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
    415     if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent && fileSystemType != AsyncFileSystem::External) {
     415    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
    416416        ec = FileException::INVALID_MODIFICATION_ERR;
    417417        return 0;
     
    472472COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
    473473COMPILE_ASSERT(static_cast<int>(WorkerContext::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
    474 COMPILE_ASSERT(static_cast<int>(WorkerContext::EXTERNAL) == static_cast<int>(AsyncFileSystem::External), enum_mismatch);
    475474#endif
    476475
  • trunk/Source/WebKit/chromium/ChangeLog

    r105380 r105395  
     12012-01-18  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Cleanup: Move chrome-specific filesystem type handling code (for FileSystem API) under chromium directory
     4        https://bugs.webkit.org/show_bug.cgi?id=76551
     5
     6        Reviewed by Darin Fisher.
     7
     8        * src/AssertMatchingEnums.cpp: Removed matching assertion for TypeExternal as it's no longer defined separately.
     9        * src/AsyncFileSystemChromium.cpp: Added crackFileSystemURL() and toURL() implementation that
     10        handle chrome-specific filesystem type (EXTERNAL) as well as regular TEMPORARY/PERSISTENT types.
     11        (WebCore::AsyncFileSystem::crackFileSystemURL): Added.
     12        (WebCore::AsyncFileSystemChromium::toURL): Added.
     13        * src/AsyncFileSystemChromium.h:
     14
    1152012-01-18  Tom Sepez  <tsepez@chromium.org>
    216
  • trunk/Source/WebKit/chromium/public/platform/WebFileSystem.h

    r101224 r105395  
    4747        TypeTemporary,
    4848        TypePersistent,
     49
     50        // Chrome specific filesystem type (used by chromeos).
    4951        TypeExternal,
    5052    };
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r105380 r105395  
    432432COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, AsyncFileSystem::Temporary);
    433433COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypePersistent, AsyncFileSystem::Persistent);
    434 COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeExternal, AsyncFileSystem::External);
    435434COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeUnknown, FileMetadata::TypeUnknown);
    436435COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeFile, FileMetadata::TypeFile);
  • trunk/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp

    r102044 r105395  
    3535#include "AsyncFileSystemCallbacks.h"
    3636#include "AsyncFileWriterChromium.h"
     37#include "SecurityOrigin.h"
    3738#include "WebFileInfo.h"
    3839#include "WebFileSystemCallbacksImpl.h"
     
    4546namespace WebCore {
    4647
     48namespace {
     49
     50// Chrome-specific FileSystem type.
     51const char kExternalPathPrefix[] = "external";
     52const size_t kExternalPathPrefixLength = sizeof(kExternalPathPrefix) - 1;
     53
     54}
     55
    4756bool AsyncFileSystem::isAvailable()
    4857{
     58    return true;
     59}
     60
     61bool AsyncFileSystem::crackFileSystemURL(const KURL& url, AsyncFileSystem::Type& type, String& filePath)
     62{
     63    if (!url.protocolIs("filesystem"))
     64        return false;
     65
     66    KURL originURL(ParsedURLString, url.path());
     67    String path = decodeURLEscapeSequences(originURL.path());
     68    if (path.isEmpty() || path[0] != '/')
     69        return false;
     70    path = path.substring(1);
     71
     72    if (path.startsWith(kTemporaryPathPrefix)) {
     73        type = Temporary;
     74        path = path.substring(kTemporaryPathPrefixLength);
     75    } else if (path.startsWith(kPersistentPathPrefix)) {
     76        type = Persistent;
     77        path = path.substring(kPersistentPathPrefixLength);
     78    } else if (path.startsWith(kExternalPathPrefix)) {
     79        type = static_cast<AsyncFileSystem::Type>(WebKit::WebFileSystem::TypeExternal);
     80        path = path.substring(kExternalPathPrefixLength);
     81    } else
     82        return false;
     83
     84    if (path.isEmpty() || path[0] != '/')
     85        return false;
     86
     87    filePath.swap(path);
    4988    return true;
    5089}
     
    6099AsyncFileSystemChromium::~AsyncFileSystemChromium()
    61100{
     101}
     102
     103String AsyncFileSystemChromium::toURL(const String& originString, const String& fullPath)
     104{
     105    ASSERT(!m_filesystemRootURL.isEmpty());
     106    ASSERT(SecurityOrigin::create(m_filesystemRootURL)->toString() == originString);
     107
     108    KURL url = m_filesystemRootURL;
     109    // Remove the extra leading slash.
     110    url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)));
     111    return url;
    62112}
    63113
  • trunk/Source/WebKit/chromium/src/AsyncFileSystemChromium.h

    r95901 r105395  
    5555    virtual ~AsyncFileSystemChromium();
    5656
     57    virtual String toURL(const String& originString, const String& fullPath);
    5758    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
    5859    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
Note: See TracChangeset for help on using the changeset viewer.