Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: Source/modules/filesystem/DOMFileSystemBase.cpp

Issue 23537011: FileAPI: Add WebFileSystem::resolveURL (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 // For regular types we can just append the entry's fullPath to the m_filesy stemRootURL that should look like 'filesystem:<origin>/<typePrefix>'. 133 // For regular types we can just append the entry's fullPath to the m_filesy stemRootURL that should look like 'filesystem:<origin>/<typePrefix>'.
134 ASSERT(!m_filesystemRootURL.isEmpty()); 134 ASSERT(!m_filesystemRootURL.isEmpty());
135 KURL url = m_filesystemRootURL; 135 KURL url = m_filesystemRootURL;
136 // Remove the extra leading slash. 136 // Remove the extra leading slash.
137 url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)) ); 137 url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)) );
138 return url; 138 return url;
139 } 139 }
140 140
141 bool DOMFileSystemBase::pathToAbsolutePath(FileSystemType type, const EntryBase* base, String path, String& absolutePath)
142 {
143 ASSERT(base);
144
145 if (!DOMFilePath::isAbsolute(path))
146 path = DOMFilePath::append(base->fullPath(), path);
147 absolutePath = DOMFilePath::removeExtraParentReferences(path);
148
149 if ((type == FileSystemTypeTemporary || type == FileSystemTypePersistent) && !DOMFilePath::isValidPath(absolutePath))
150 return false;
151 return true;
152 }
153
141 bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataC allback> successCallback, PassRefPtr<ErrorCallback> errorCallback, SynchronousTy pe synchronousType) 154 bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataC allback> successCallback, PassRefPtr<ErrorCallback> errorCallback, SynchronousTy pe synchronousType)
142 { 155 {
143 OwnPtr<MetadataCallbacks> callbacks(MetadataCallbacks::create(successCallbac k, errorCallback)); 156 OwnPtr<MetadataCallbacks> callbacks(MetadataCallbacks::create(successCallbac k, errorCallback));
144 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 157 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
145 m_asyncFileSystem->readMetadata(createFileSystemURL(entry), callbacks.releas e()); 158 m_asyncFileSystem->readMetadata(createFileSystemURL(entry), callbacks.releas e());
146 return true; 159 return true;
147 } 160 }
148 161
149 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En tryBase* parent, const String& newName, String& destinationPath) 162 static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En tryBase* parent, const String& newName, String& destinationPath)
150 { 163 {
(...skipping 17 matching lines...) Expand all
168 181
169 destinationPath = parent->fullPath(); 182 destinationPath = parent->fullPath();
170 if (!newName.isEmpty()) 183 if (!newName.isEmpty())
171 destinationPath = DOMFilePath::append(destinationPath, newName); 184 destinationPath = DOMFilePath::append(destinationPath, newName);
172 else 185 else
173 destinationPath = DOMFilePath::append(destinationPath, source->name()); 186 destinationPath = DOMFilePath::append(destinationPath, source->name());
174 187
175 return true; 188 return true;
176 } 189 }
177 190
178 static bool pathToAbsolutePath(FileSystemType type, const EntryBase* base, Strin g path, String& absolutePath)
179 {
180 ASSERT(base);
181
182 if (!DOMFilePath::isAbsolute(path))
183 path = DOMFilePath::append(base->fullPath(), path);
184 absolutePath = DOMFilePath::removeExtraParentReferences(path);
185
186 if ((type == FileSystemTypeTemporary || type == FileSystemTypePersistent) && !DOMFilePath::isValidPath(absolutePath))
187 return false;
188 return true;
189 }
190
191 bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S tring& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallb ack> errorCallback, SynchronousType synchronousType) 191 bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S tring& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallb ack> errorCallback, SynchronousType synchronousType)
192 { 192 {
193 String destinationPath; 193 String destinationPath;
194 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath)) 194 if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, desti nationPath))
195 return false; 195 return false;
196 196
197 OwnPtr<EntryCallbacks> callbacks(EntryCallbacks::create(successCallback, err orCallback, parent->filesystem(), destinationPath, source->isDirectory())); 197 OwnPtr<EntryCallbacks> callbacks(EntryCallbacks::create(successCallback, err orCallback, parent->filesystem(), destinationPath, source->isDirectory()));
198 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 198 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
199 199
200 m_asyncFileSystem->move(createFileSystemURL(source), parent->filesystem()->c reateFileSystemURL(destinationPath), callbacks.release()); 200 m_asyncFileSystem->move(createFileSystemURL(source), parent->filesystem()->c reateFileSystemURL(destinationPath), callbacks.release());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 ASSERT(DOMFilePath::isAbsolute(path)); 288 ASSERT(DOMFilePath::isAbsolute(path));
289 289
290 OwnPtr<EntriesCallbacks> callbacks(EntriesCallbacks::create(successCallback, errorCallback, reader, path)); 290 OwnPtr<EntriesCallbacks> callbacks(EntriesCallbacks::create(successCallback, errorCallback, reader, path));
291 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous); 291 callbacks->setShouldBlockUntilCompletion(synchronousType == Synchronous);
292 292
293 m_asyncFileSystem->readDirectory(createFileSystemURL(path), callbacks.releas e()); 293 m_asyncFileSystem->readDirectory(createFileSystemURL(path), callbacks.releas e());
294 return true; 294 return true;
295 } 295 }
296 296
297 } // namespace WebCore 297 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698