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

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

Issue 23537011: FileAPI: Add WebFileSystem::resolveURL (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 RefPtr<EntryCallback> m_successCallback; 191 RefPtr<EntryCallback> m_successCallback;
192 RefPtr<ErrorCallback> m_errorCallback; 192 RefPtr<ErrorCallback> m_errorCallback;
193 RefPtr<DirectoryEntry> m_root; 193 RefPtr<DirectoryEntry> m_root;
194 String m_filePath; 194 String m_filePath;
195 }; 195 };
196 196
197 } // namespace 197 } // namespace
198 198
199 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassRefPtr<Entr yCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecu tionContext* scriptExecutionContext, FileSystemType type, const String& filePath ) 199 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassRefPtr<Entr yCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecu tionContext* scriptExecutionContext)
200 { 200 {
201 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new ResolveURICallbac ks(successCallback, errorCallback, scriptExecutionContext, type, filePath))); 201 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new ResolveURICallbac ks(successCallback, errorCallback, scriptExecutionContext)));
202 } 202 }
203 203
204 ResolveURICallbacks::ResolveURICallbacks(PassRefPtr<EntryCallback> successCallba ck, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context, Fi leSystemType type, const String& filePath) 204 ResolveURICallbacks::ResolveURICallbacks(PassRefPtr<EntryCallback> successCallba ck, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context)
205 : FileSystemCallbacksBase(errorCallback, 0) 205 : FileSystemCallbacksBase(errorCallback, 0)
206 , m_successCallback(successCallback) 206 , m_successCallback(successCallback)
207 , m_scriptExecutionContext(context) 207 , m_scriptExecutionContext(context)
208 , m_type(type)
209 , m_filePath(filePath)
210 { 208 {
211 } 209 }
212 210
213 void ResolveURICallbacks::didOpenFileSystem(const String& name, const KURL& root URL) 211 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory)
214 { 212 {
215 RefPtr<DirectoryEntry> root = DOMFileSystem::create(m_scriptExecutionContext .get(), name, m_type, rootURL)->root(); 213 RefPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_scriptExecutionCo ntext.get(), name, type, rootURL);
216 root->getDirectory(m_filePath, Dictionary(), m_successCallback, ErrorCallbac kWrapper::create(m_successCallback, m_errorCallback, root, m_filePath)); 214 RefPtr<DirectoryEntry> root = filesystem->root();
215
216 String absolutePath;
217 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) {
218 m_errorCallback->handleEvent(FileError::create(FileError::INVALID_MODIFI CATION_ERR).get());
219 m_errorCallback.clear();
220 return;
221 }
222
223 if (isDirectory)
224 m_successCallback->handleEvent(DirectoryEntry::create(filesystem, absolu tePath).get());
225 else
226 m_successCallback->handleEvent(FileEntry::create(filesystem, absolutePat h).get());
227 m_successCallback.clear();
217 } 228 }
218 229
219 // MetadataCallbacks ---------------------------------------------------------- 230 // MetadataCallbacks ----------------------------------------------------------
220 231
221 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(PassRefPtr<Metada taCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSys temBase* fileSystem) 232 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(PassRefPtr<Metada taCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSys temBase* fileSystem)
222 { 233 {
223 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new MetadataCallbacks (successCallback, errorCallback, fileSystem))); 234 return adoptPtr(static_cast<AsyncFileSystemCallbacks*>(new MetadataCallbacks (successCallback, errorCallback, fileSystem)));
224 } 235 }
225 236
226 MetadataCallbacks::MetadataCallbacks(PassRefPtr<MetadataCallback> successCallbac k, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) 237 MetadataCallbacks::MetadataCallbacks(PassRefPtr<MetadataCallback> successCallbac k, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 283 }
273 284
274 void VoidCallbacks::didSucceed() 285 void VoidCallbacks::didSucceed()
275 { 286 {
276 if (m_successCallback) 287 if (m_successCallback)
277 m_successCallback->handleEvent(); 288 m_successCallback->handleEvent();
278 m_successCallback.clear(); 289 m_successCallback.clear();
279 } 290 }
280 291
281 } // namespace 292 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698