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

Side by Side Diff: WebKit/chromium/src/AsyncFileSystemChromium.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 30 matching lines...) Expand all
41 #include "WebFileSystemCallbacksImpl.h" 41 #include "WebFileSystemCallbacksImpl.h"
42 #include "WebFileWriter.h" 42 #include "WebFileWriter.h"
43 #include <public/Platform.h> 43 #include <public/Platform.h>
44 #include <public/WebFileInfo.h> 44 #include <public/WebFileInfo.h>
45 #include <public/WebFileSystem.h> 45 #include <public/WebFileSystem.h>
46 #include <wtf/text/CString.h> 46 #include <wtf/text/CString.h>
47 #include <wtf/text/StringBuilder.h> 47 #include <wtf/text/StringBuilder.h>
48 48
49 namespace WebCore { 49 namespace WebCore {
50 50
51 namespace {
52
53 // Specialized callback class for createSnapshotFileAndReadMetadata.
54 class SnapshotFileCallbacks : public AsyncFileSystemCallbacks {
55 public:
56 static PassOwnPtr<SnapshotFileCallbacks> create(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks)
57 {
58 return adoptPtr(new SnapshotFileCallbacks(internalBlobURL, callbacks));
59 }
60
61 virtual void didReadMetadata(const FileMetadata& metadata)
62 {
63 ASSERT(m_callbacks);
64
65 // This will create a new File object using the metadata.
66 m_callbacks->didReadMetadata(metadata);
67
68 // Now that we've registered the snapshot file, we can unregister our in ternalBlobURL which has played a placeholder for the file during the IPC.
69 ThreadableBlobRegistry::unregisterBlobURL(m_internalBlobURL);
70 }
71
72 virtual void didFail(int error)
73 {
74 ASSERT(m_callbacks);
75 m_callbacks->didFail(error);
76 }
77
78 private:
79 SnapshotFileCallbacks(const KURL& internalBlobURL, PassOwnPtr<WebCore::Async FileSystemCallbacks> callbacks)
80 : m_internalBlobURL(internalBlobURL)
81 , m_callbacks(callbacks)
82 {
83 }
84
85 KURL m_internalBlobURL;
86 OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
87 };
88
89 } // namespace
90
91 bool AsyncFileSystem::isAvailable() 51 bool AsyncFileSystem::isAvailable()
92 { 52 {
93 return true; 53 return true;
94 } 54 }
95 55
96 PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create() 56 PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create()
97 { 57 {
98 return AsyncFileSystemChromium::create(); 58 return AsyncFileSystemChromium::create();
99 } 59 }
100 60
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (info.type != WebKit::WebFileInfo::TypeFile || info.length < 0) 139 if (info.type != WebKit::WebFileInfo::TypeFile || info.length < 0)
180 m_callbacks->didFail(WebKit::WebFileErrorInvalidState); 140 m_callbacks->didFail(WebKit::WebFileErrorInvalidState);
181 else { 141 else {
182 OwnPtr<AsyncFileWriterChromium> asyncFileWriterChromium = adoptPtr(n ew AsyncFileWriterChromium(m_client)); 142 OwnPtr<AsyncFileWriterChromium> asyncFileWriterChromium = adoptPtr(n ew AsyncFileWriterChromium(m_client));
183 OwnPtr<WebKit::WebFileWriter> webFileWriter = adoptPtr(m_webFileSyst em->createFileWriter(m_path, asyncFileWriterChromium.get())); 143 OwnPtr<WebKit::WebFileWriter> webFileWriter = adoptPtr(m_webFileSyst em->createFileWriter(m_path, asyncFileWriterChromium.get()));
184 asyncFileWriterChromium->setWebFileWriter(webFileWriter.release()); 144 asyncFileWriterChromium->setWebFileWriter(webFileWriter.release());
185 m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(), info.length); 145 m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(), info.length);
186 } 146 }
187 delete this; 147 delete this;
188 } 148 }
189 149 virtual void didCreateSnapshotFile(const WebKit::WebFileInfo& info)
150 {
151 ASSERT_NOT_REACHED();
152 delete this;
153 }
190 virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemE ntry>& entries, bool hasMore) 154 virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemE ntry>& entries, bool hasMore)
191 { 155 {
192 ASSERT_NOT_REACHED(); 156 ASSERT_NOT_REACHED();
193 delete this; 157 delete this;
194 } 158 }
195 virtual void didOpenFileSystem(const WebKit::WebString& name, const WebKit:: WebURL& rootURL) 159 virtual void didOpenFileSystem(const WebKit::WebString& name, const WebKit:: WebURL& rootURL)
196 { 160 {
197 ASSERT_NOT_REACHED(); 161 ASSERT_NOT_REACHED();
198 delete this; 162 delete this;
199 } 163 }
(...skipping 12 matching lines...) Expand all
212 OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks; 176 OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
213 }; 177 };
214 178
215 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 179 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
216 { 180 {
217 m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, pa th, m_webFileSystem, callbacks)); 181 m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, pa th, m_webFileSystem, callbacks));
218 } 182 }
219 183
220 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path , PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 184 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path , PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
221 { 185 {
222 KURL internalBlobURL = BlobURL::createInternalURL(); 186 m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFile SystemCallbacksImpl(callbacks));
223
224 // This will create a snapshot file and register the file to a blob using th e given internalBlobURL.
225 m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, ne w WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks)));
226 }
227
228 PassOwnPtr<AsyncFileSystemCallbacks> AsyncFileSystemChromium::createSnapshotFile Callback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks> callb acks) const
229 {
230 return SnapshotFileCallbacks::create(internalBlobURL, callbacks);
231 } 187 }
232 188
233 } // namespace WebCore 189 } // namespace WebCore
234 190
235 #endif 191 #endif
OLDNEW
« no previous file with comments | « WebKit/chromium/src/AsyncFileSystemChromium.h ('k') | WebKit/chromium/src/AsyncFileWriterChromium.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698