OLD | NEW |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<Async
FileSystemCallbacks> callbacks) | 102 void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<Async
FileSystemCallbacks> callbacks) |
103 { | 103 { |
104 m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImp
l(callbacks)); | 104 m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImp
l(callbacks)); |
105 } | 105 } |
106 | 106 |
107 void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFi
leSystemCallbacks> callbacks) | 107 void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFi
leSystemCallbacks> callbacks) |
108 { | 108 { |
109 m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(
callbacks)); | 109 m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(
callbacks)); |
110 } | 110 } |
111 | 111 |
112 class FileWriterHelperCallbacks : public WebKit::WebFileSystemCallbacks { | |
113 public: | |
114 FileWriterHelperCallbacks(AsyncFileWriterClient* client, const KURL& path, W
ebKit::WebFileSystem* webFileSystem, PassOwnPtr<WebCore::AsyncFileSystemCallback
s> callbacks) | |
115 : m_client(client) | |
116 , m_path(path) | |
117 , m_webFileSystem(webFileSystem) | |
118 , m_callbacks(callbacks) | |
119 { | |
120 } | |
121 | |
122 virtual void didSucceed() | |
123 { | |
124 ASSERT_NOT_REACHED(); | |
125 delete this; | |
126 } | |
127 virtual void didReadMetadata(const WebKit::WebFileInfo& info) | |
128 { | |
129 ASSERT(m_callbacks); | |
130 if (info.type != WebKit::WebFileInfo::TypeFile || info.length < 0) | |
131 m_callbacks->didFail(WebKit::WebFileErrorInvalidState); | |
132 else { | |
133 OwnPtr<AsyncFileWriterChromium> asyncFileWriterChromium = adoptPtr(n
ew AsyncFileWriterChromium(m_client)); | |
134 OwnPtr<WebKit::WebFileWriter> webFileWriter = adoptPtr(m_webFileSyst
em->createFileWriter(m_path, asyncFileWriterChromium.get())); | |
135 asyncFileWriterChromium->setWebFileWriter(webFileWriter.release()); | |
136 m_callbacks->didCreateFileWriter(asyncFileWriterChromium.release(),
info.length); | |
137 } | |
138 delete this; | |
139 } | |
140 virtual void didCreateSnapshotFile(const WebKit::WebFileInfo& info) | |
141 { | |
142 ASSERT_NOT_REACHED(); | |
143 delete this; | |
144 } | |
145 virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemE
ntry>& entries, bool hasMore) | |
146 { | |
147 ASSERT_NOT_REACHED(); | |
148 delete this; | |
149 } | |
150 virtual void didOpenFileSystem(const WebKit::WebString& name, const WebKit::
WebURL& rootURL) | |
151 { | |
152 ASSERT_NOT_REACHED(); | |
153 delete this; | |
154 } | |
155 | |
156 virtual void didFail(WebKit::WebFileError error) | |
157 { | |
158 ASSERT(m_callbacks); | |
159 m_callbacks->didFail(error); | |
160 delete this; | |
161 } | |
162 | |
163 virtual bool shouldBlockUntilCompletion() const | |
164 { | |
165 return m_callbacks->shouldBlockUntilCompletion(); | |
166 } | |
167 | |
168 private: | |
169 AsyncFileWriterClient* m_client; | |
170 KURL m_path; | |
171 WebKit::WebFileSystem* m_webFileSystem; | |
172 OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks; | |
173 }; | |
174 | |
175 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const
KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 112 void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const
KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
176 { | 113 { |
177 m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, pa
th, m_webFileSystem, callbacks)); | 114 OwnPtr<AsyncFileWriterChromium> asyncFileWriter = AsyncFileWriterChromium::c
reate(client); |
| 115 WebKit::WebFileWriterClient* writerClient = asyncFileWriter.get(); |
| 116 |
| 117 m_webFileSystem->createFileWriter(path, writerClient, new WebKit::WebFileSys
temCallbacksImpl(callbacks, asyncFileWriter.release())); |
178 } | 118 } |
179 | 119 |
180 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path
, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) | 120 void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path
, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) |
181 { | 121 { |
182 m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFile
SystemCallbacksImpl(callbacks)); | 122 m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFile
SystemCallbacksImpl(callbacks)); |
183 } | 123 } |
184 | 124 |
185 } // namespace WebCore | 125 } // namespace WebCore |
OLD | NEW |