Changeset 105395 in webkit
- Timestamp:
- Jan 19, 2012 1:58:56 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r105394 r105395 1 2012-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 1 33 2012-01-19 Mihnea Ovidenie <mihnea@adobe.com> 2 34 … … 1514 1546 * platform/image-decoders/skia/ImageDecoderSkia.cpp: 1515 1547 (WebCore::ImageFrame::setStatus): 1516 1517 1548 2012-01-17 Nate Chapin <japhet@chromium.org> 1518 1549 -
trunk/Source/WebCore/fileapi/DOMFileSystemBase.cpp
r96779 r105395 51 51 namespace WebCore { 52 52 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 60 54 bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, AsyncFileSystem::Type& type, String& filePath) 61 55 { 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); 88 57 } 89 58 -
trunk/Source/WebCore/fileapi/DOMFileSystemBase.h
r95901 r105395 63 63 virtual ~DOMFileSystemBase(); 64 64 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;71 65 static bool crackFileSystemURL(const KURL&, AsyncFileSystem::Type&, String& filePath); 72 66 -
trunk/Source/WebCore/fileapi/EntryBase.cpp
r95901 r105395 40 40 #include "SecurityOrigin.h" 41 41 #include <wtf/PassRefPtr.h> 42 #include <wtf/text/StringBuilder.h>43 42 44 43 namespace WebCore { … … 57 56 String EntryBase::toURL() 58 57 { 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); 80 59 } 81 60 -
trunk/Source/WebCore/page/DOMWindow.cpp
r105310 r105395 786 786 787 787 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) { 789 789 DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR)); 790 790 return; … … 819 819 LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath)); 820 820 } 821 822 COMPILE_ASSERT(static_cast<int>(DOMWindow::EXTERNAL) == static_cast<int>(AsyncFileSystem::External), enum_mismatch);823 821 824 822 COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch); -
trunk/Source/WebCore/page/DOMWindow.h
r104654 r105395 371 371 TEMPORARY, 372 372 PERSISTENT, 373 EXTERNAL,374 373 }; 375 374 void webkitRequestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>); -
trunk/Source/WebCore/platform/AsyncFileSystem.cpp
r95901 r105395 37 37 #include "FileSystem.h" 38 38 #include "NotImplemented.h" 39 #include <wtf/text/StringBuilder.h> 39 40 40 41 namespace WebCore { 42 43 const char AsyncFileSystem::kPersistentPathPrefix[] = "persistent"; 44 const size_t AsyncFileSystem::kPersistentPathPrefixLength = sizeof(AsyncFileSystem::kPersistentPathPrefix) - 1; 45 const char AsyncFileSystem::kTemporaryPathPrefix[] = "temporary"; 46 const size_t AsyncFileSystem::kTemporaryPathPrefixLength = sizeof(AsyncFileSystem::kTemporaryPathPrefix) - 1; 47 48 String 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 } 41 65 42 66 #if !PLATFORM(CHROMIUM) … … 45 69 notImplemented(); 46 70 return false; 71 } 72 73 bool 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; 47 98 } 48 99 -
trunk/Source/WebCore/platform/AsyncFileSystem.h
r95901 r105395 55 55 Temporary, 56 56 Persistent, 57 External,58 57 }; 59 58 … … 62 61 63 62 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); 64 75 65 76 // Subclass must implement this if it supports synchronous operations. -
trunk/Source/WebCore/workers/WorkerContext.cpp
r104803 r105395 396 396 397 397 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) { 399 399 DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR)); 400 400 return; … … 413 413 414 414 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) { 416 416 ec = FileException::INVALID_MODIFICATION_ERR; 417 417 return 0; … … 472 472 COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch); 473 473 COMPILE_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);475 474 #endif 476 475 -
trunk/Source/WebKit/chromium/ChangeLog
r105380 r105395 1 2012-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 1 15 2012-01-18 Tom Sepez <tsepez@chromium.org> 2 16 -
trunk/Source/WebKit/chromium/public/platform/WebFileSystem.h
r101224 r105395 47 47 TypeTemporary, 48 48 TypePersistent, 49 50 // Chrome specific filesystem type (used by chromeos). 49 51 TypeExternal, 50 52 }; -
trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp
r105380 r105395 432 432 COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, AsyncFileSystem::Temporary); 433 433 COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypePersistent, AsyncFileSystem::Persistent); 434 COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeExternal, AsyncFileSystem::External);435 434 COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeUnknown, FileMetadata::TypeUnknown); 436 435 COMPILE_ASSERT_MATCHING_ENUM(WebFileInfo::TypeFile, FileMetadata::TypeFile); -
trunk/Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp
r102044 r105395 35 35 #include "AsyncFileSystemCallbacks.h" 36 36 #include "AsyncFileWriterChromium.h" 37 #include "SecurityOrigin.h" 37 38 #include "WebFileInfo.h" 38 39 #include "WebFileSystemCallbacksImpl.h" … … 45 46 namespace WebCore { 46 47 48 namespace { 49 50 // Chrome-specific FileSystem type. 51 const char kExternalPathPrefix[] = "external"; 52 const size_t kExternalPathPrefixLength = sizeof(kExternalPathPrefix) - 1; 53 54 } 55 47 56 bool AsyncFileSystem::isAvailable() 48 57 { 58 return true; 59 } 60 61 bool 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); 49 88 return true; 50 89 } … … 60 99 AsyncFileSystemChromium::~AsyncFileSystemChromium() 61 100 { 101 } 102 103 String 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; 62 112 } 63 113 -
trunk/Source/WebKit/chromium/src/AsyncFileSystemChromium.h
r95901 r105395 55 55 virtual ~AsyncFileSystemChromium(); 56 56 57 virtual String toURL(const String& originString, const String& fullPath); 57 58 virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>); 58 59 virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
Note: See TracChangeset
for help on using the changeset viewer.