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

Side by Side Diff: WebCore/Modules/filesystem/DOMFileSystem.cpp

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 11 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 ASSERT(fileEntry); 141 ASSERT(fileEntry);
142 142
143 RefPtr<FileWriter> fileWriter = FileWriter::create(scriptExecutionContext()) ; 143 RefPtr<FileWriter> fileWriter = FileWriter::create(scriptExecutionContext()) ;
144 RefPtr<FileWriterBaseCallback> conversionCallback = ConvertToFileWriterCallb ack::create(successCallback); 144 RefPtr<FileWriterBaseCallback> conversionCallback = ConvertToFileWriterCallb ack::create(successCallback);
145 OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create( fileWriter, conversionCallback, errorCallback); 145 OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create( fileWriter, conversionCallback, errorCallback);
146 m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEn try), callbacks.release()); 146 m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEn try), callbacks.release());
147 } 147 }
148 148
149 namespace { 149 namespace {
150 150
151 class GetMetadataCallback : public FileSystemCallbacksBase { 151 class SnapshotFileCallback : public FileSystemCallbacksBase {
152 public: 152 public:
153 static PassOwnPtr<GetMetadataCallback> create(PassRefPtr<DOMFileSystem> file system, const String& name, const KURL& url, PassRefPtr<FileCallback> successCal lback, PassRefPtr<ErrorCallback> errorCallback) 153 static PassOwnPtr<SnapshotFileCallback> create(PassRefPtr<DOMFileSystem> fil esystem, const String& name, const KURL& url, PassRefPtr<FileCallback> successCa llback, PassRefPtr<ErrorCallback> errorCallback)
154 { 154 {
155 return adoptPtr(new GetMetadataCallback(filesystem, name, url, successCa llback, errorCallback)); 155 return adoptPtr(new SnapshotFileCallback(filesystem, name, url, successC allback, errorCallback));
156 } 156 }
157 157
158 virtual void didReadMetadata(const FileMetadata& metadata) 158 virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr< BlobDataHandle> snapshot)
159 { 159 {
160 ASSERT(!metadata.platformPath.isEmpty()); 160 ASSERT(!metadata.platformPath.isEmpty());
161 if (!m_successCallback) 161 if (!m_successCallback)
162 return; 162 return;
163 163
164 // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics. 164 // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics.
165 // For other filesystem types (which could be platform-specific ones), t here's a chance that the files are on remote filesystem. If the port has returne d metadata just pass it to File constructor (so we may cache the metadata). 165 // For other filesystem types (which could be platform-specific ones), t here's a chance that the files are on remote filesystem. If the port has returne d metadata just pass it to File constructor (so we may cache the metadata).
166 // FIXME: We should use the snapshot metadata for all files. 166 // FIXME: We should use the snapshot metadata for all files.
167 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17746 167 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17746
168 if (m_filesystem->type() == FileSystemTypeTemporary || m_filesystem->typ e() == FileSystemTypePersistent) { 168 if (m_filesystem->type() == FileSystemTypeTemporary || m_filesystem->typ e() == FileSystemTypePersistent) {
169 m_successCallback->handleEvent(File::createWithName(metadata.platfor mPath, m_name).get()); 169 m_successCallback->handleEvent(File::createWithName(metadata.platfor mPath, m_name).get());
170 } else if (!metadata.platformPath.isEmpty()) { 170 } else if (!metadata.platformPath.isEmpty()) {
171 // If the platformPath in the returned metadata is given, we create a File object for the path. 171 // If the platformPath in the returned metadata is given, we create a File object for the path.
172 m_successCallback->handleEvent(File::createForFileSystemFile(m_name, metadata).get()); 172 m_successCallback->handleEvent(File::createForFileSystemFile(m_name, metadata).get());
173 } else { 173 } else {
174 // Otherwise create a File from the FileSystem URL. 174 // Otherwise create a File from the FileSystem URL.
175 m_successCallback->handleEvent(File::createForFileSystemFile(m_url, metadata).get()); 175 m_successCallback->handleEvent(File::createForFileSystemFile(m_url, metadata).get());
176 } 176 }
177 177
178 m_successCallback.release(); 178 m_successCallback.release();
179
180 // We can't directly use the snapshot blob data handle because the conte nt type on it hasn't been set.
181 // Having a chain of custody thru thread bridging of that instance up un til now, *after* we've coined a File with a new handle
182 // that has the correct type set on it, allows the blob storage system t o track when a temp file can and can't
183 // be safely deleted.
184 // FIXME: Maybe add a BlobDataHandle/BlobRegistry methods to clone a blo b with a new type?
179 } 185 }
180 186
181 private: 187 private:
182 GetMetadataCallback(PassRefPtr<DOMFileSystem> filesystem, const String& name , const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCa llback> errorCallback) 188 SnapshotFileCallback(PassRefPtr<DOMFileSystem> filesystem, const String& nam e, const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorC allback> errorCallback)
183 : FileSystemCallbacksBase(errorCallback) 189 : FileSystemCallbacksBase(errorCallback)
184 , m_filesystem(filesystem) 190 , m_filesystem(filesystem)
185 , m_name(name) 191 , m_name(name)
186 , m_url(url) 192 , m_url(url)
187 , m_successCallback(successCallback) 193 , m_successCallback(successCallback)
188 { 194 {
189 } 195 }
190 196
191 RefPtr<DOMFileSystem> m_filesystem; 197 RefPtr<DOMFileSystem> m_filesystem;
192 String m_name; 198 String m_name;
193 KURL m_url; 199 KURL m_url;
194 RefPtr<FileCallback> m_successCallback; 200 RefPtr<FileCallback> m_successCallback;
195 }; 201 };
196 202
197 } // namespace 203 } // namespace
198 204
199 void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallba ck> successCallback, PassRefPtr<ErrorCallback> errorCallback) 205 void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallba ck> successCallback, PassRefPtr<ErrorCallback> errorCallback)
200 { 206 {
201 KURL fileSystemURL = createFileSystemURL(fileEntry); 207 KURL fileSystemURL = createFileSystemURL(fileEntry);
202 m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, GetMetad ataCallback::create(this, fileEntry->name(), fileSystemURL, successCallback, err orCallback)); 208 m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, Snapshot FileCallback::create(this, fileEntry->name(), fileSystemURL, successCallback, er rorCallback));
203 } 209 }
204 210
205 } // namespace WebCore 211 } // namespace WebCore
206 212
207 #endif // ENABLE(FILE_SYSTEM) 213 #endif // ENABLE(FILE_SYSTEM)
OLDNEW
« no previous file with comments | « Platform/chromium/public/WebHTTPBody.h ('k') | WebCore/Modules/filesystem/DOMFileSystemSync.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698