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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 void FileSystemCallbacksBase::didFail(int code) | 69 void FileSystemCallbacksBase::didFail(int code) |
70 { | 70 { |
71 if (m_errorCallback) { | 71 if (m_errorCallback) { |
72 m_errorCallback->handleEvent(FileError::create(static_cast<FileError::Er rorCode>(code)).get()); | 72 m_errorCallback->handleEvent(FileError::create(static_cast<FileError::Er rorCode>(code)).get()); |
73 m_errorCallback.clear(); | 73 m_errorCallback.clear(); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 // EntryCallbacks ------------------------------------------------------------- | 77 // EntryCallbacks ------------------------------------------------------------- |
78 | 78 |
79 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<DOMFi leSystemBase> fileSystem, const String& expectedPath, bool isDirectory) | 79 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtr<EntryCall back> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWillBe RawPtr<DOMFileSystemBase> fileSystem, const String& expectedPath, bool isDirecto ry) |
80 { | 80 { |
81 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSyste m, expectedPath, isDirectory)); | 81 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSyste m, expectedPath, isDirectory)); |
82 } | 82 } |
83 | 83 |
84 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, PassRefPtr<DOMFileSystemBase> fileSystem, con st String& expectedPath, bool isDirectory) | 84 EntryCallbacks::EntryCallbacks(PassOwnPtr<EntryCallback> successCallback, PassOw nPtr<ErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<DOMFileSystemBase> fil eSystem, const String& expectedPath, bool isDirectory) |
85 : FileSystemCallbacksBase(errorCallback, fileSystem.get()) | 85 : FileSystemCallbacksBase(errorCallback, fileSystem.get()) |
86 , m_successCallback(successCallback) | 86 , m_successCallback(successCallback) |
87 , m_expectedPath(expectedPath) | 87 , m_expectedPath(expectedPath) |
88 , m_isDirectory(isDirectory) | 88 , m_isDirectory(isDirectory) |
89 { | 89 { |
90 } | 90 } |
91 | 91 |
92 void EntryCallbacks::didSucceed() | 92 void EntryCallbacks::didSucceed() |
93 { | 93 { |
94 if (m_successCallback) { | 94 if (m_successCallback) { |
95 if (m_isDirectory) | 95 if (m_isDirectory) |
96 m_successCallback->handleEvent(DirectoryEntry::create(m_fileSystem, m_expectedPath).get()); | 96 m_successCallback->handleEvent(DirectoryEntry::create(m_fileSystem, m_expectedPath).get()); |
97 else | 97 else |
98 m_successCallback->handleEvent(FileEntry::create(m_fileSystem, m_exp ectedPath).get()); | 98 m_successCallback->handleEvent(FileEntry::create(m_fileSystem, m_exp ectedPath).get()); |
99 } | 99 } |
100 m_successCallback.clear(); | 100 m_successCallback.clear(); |
101 } | 101 } |
102 | 102 |
103 // EntriesCallbacks ----------------------------------------------------------- | 103 // EntriesCallbacks ----------------------------------------------------------- |
104 | 104 |
105 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<D irectoryReaderBase> directoryReader, const String& basePath) | 105 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtr<Entries Callback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWi llBeRawPtr<DirectoryReaderBase> directoryReader, const String& basePath) |
106 { | 106 { |
107 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo ryReader, basePath)); | 107 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directo ryReader, basePath)); |
108 } | 108 } |
109 | 109 |
110 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtr<DirectoryReaderBase> directo ryReader, const String& basePath) | 110 EntriesCallbacks::EntriesCallbacks(PassOwnPtr<EntriesCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<DirectoryReaderB ase> directoryReader, const String& basePath) |
111 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem()) | 111 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem()) |
112 , m_successCallback(successCallback) | 112 , m_successCallback(successCallback) |
113 , m_directoryReader(directoryReader) | 113 , m_directoryReader(directoryReader) |
114 , m_basePath(basePath) | 114 , m_basePath(basePath) |
115 { | 115 { |
116 ASSERT(m_directoryReader); | 116 ASSERT(m_directoryReader); |
117 } | 117 } |
118 | 118 |
119 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) | 119 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) |
120 { | 120 { |
(...skipping 21 matching lines...) Expand all Loading... | |
142 : FileSystemCallbacksBase(errorCallback, 0) | 142 : FileSystemCallbacksBase(errorCallback, 0) |
143 , m_successCallback(successCallback) | 143 , m_successCallback(successCallback) |
144 , m_executionContext(context) | 144 , m_executionContext(context) |
145 , m_type(type) | 145 , m_type(type) |
146 { | 146 { |
147 } | 147 } |
148 | 148 |
149 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL) | 149 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL) |
150 { | 150 { |
151 if (m_successCallback) { | 151 if (m_successCallback) { |
152 RefPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_executionCont ext.get(), name, m_type, rootURL); | 152 RefPtrWillBeRawPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_e xecutionContext.get(), name, m_type, rootURL); |
153 m_successCallback->handleEvent(fileSystem.get()); | 153 m_successCallback->handleEvent(fileSystem.get()); |
154 m_executionContext.clear(); | 154 m_executionContext.clear(); |
155 } | 155 } |
156 m_successCallback.clear(); | 156 m_successCallback.clear(); |
157 } | 157 } |
158 | 158 |
159 // ResolveURICallbacks -------------------------------------------------------- | 159 // ResolveURICallbacks -------------------------------------------------------- |
160 | 160 |
161 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassOwnPtr<Entr yCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCo ntext* executionContext) | 161 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassOwnPtr<Entr yCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback, ExecutionCo ntext* executionContext) |
162 { | 162 { |
163 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, exec utionContext)); | 163 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, exec utionContext)); |
164 } | 164 } |
165 | 165 |
166 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context) | 166 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtr<EntryCallback> successCallba ck, PassOwnPtr<ErrorCallback> errorCallback, ExecutionContext* context) |
167 : FileSystemCallbacksBase(errorCallback, 0) | 167 : FileSystemCallbacksBase(errorCallback, 0) |
168 , m_successCallback(successCallback) | 168 , m_successCallback(successCallback) |
169 , m_executionContext(context) | 169 , m_executionContext(context) |
170 { | 170 { |
171 } | 171 } |
172 | 172 |
173 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) | 173 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) |
174 { | 174 { |
175 RefPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_executionContext. get(), name, type, rootURL); | 175 RefPtrWillBeRawPtr<DOMFileSystem> filesystem = DOMFileSystem::create(m_execu tionContext.get(), name, type, rootURL); |
176 RefPtr<DirectoryEntry> root = filesystem->root(); | 176 RefPtrWillBeRawPtr<DirectoryEntry> root = filesystem->root(); |
177 | 177 |
178 String absolutePath; | 178 String absolutePath; |
179 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) { | 179 if (!DOMFileSystemBase::pathToAbsolutePath(type, root.get(), filePath, absol utePath)) { |
180 m_errorCallback->handleEvent(FileError::create(FileError::INVALID_MODIFI CATION_ERR).get()); | 180 m_errorCallback->handleEvent(FileError::create(FileError::INVALID_MODIFI CATION_ERR).get()); |
181 m_errorCallback.clear(); | 181 m_errorCallback.clear(); |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 if (isDirectory) | 185 if (isDirectory) |
186 m_successCallback->handleEvent(DirectoryEntry::create(filesystem, absolu tePath).get()); | 186 m_successCallback->handleEvent(DirectoryEntry::create(filesystem, absolu tePath).get()); |
(...skipping 17 matching lines...) Expand all Loading... | |
204 | 204 |
205 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) | 205 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) |
206 { | 206 { |
207 if (m_successCallback) | 207 if (m_successCallback) |
208 m_successCallback->handleEvent(Metadata::create(metadata).get()); | 208 m_successCallback->handleEvent(Metadata::create(metadata).get()); |
209 m_successCallback.clear(); | 209 m_successCallback.clear(); |
210 } | 210 } |
211 | 211 |
212 // FileWriterBaseCallbacks ----------------------------------------------------- ----- | 212 // FileWriterBaseCallbacks ----------------------------------------------------- ----- |
213 | 213 |
214 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtr< FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnPtr<ErrorCallback> errorCallback) | 214 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> succe ssCallback, PassOwnPtr<ErrorCallback> errorCallback) |
215 { | 215 { |
216 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback)); | 216 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback)); |
217 } | 217 } |
218 | 218 |
219 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtr<FileWriterBase> file Writer, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnPtr<ErrorCall back> errorCallback) | 219 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, PassOwnPtr<FileWriterBaseCallback> successCallback, PassOwnP tr<ErrorCallback> errorCallback) |
220 : FileSystemCallbacksBase(errorCallback, 0) | 220 : FileSystemCallbacksBase(errorCallback, 0) |
221 , m_fileWriter(fileWriter) | 221 , m_fileWriter(fileWriter) |
222 , m_successCallback(successCallback) | 222 , m_successCallback(successCallback) |
223 { | 223 { |
224 } | 224 } |
225 | 225 |
226 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length) | 226 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<blink::WebFileWrite r> fileWriter, long long length) |
227 { | 227 { |
228 m_fileWriter->initialize(fileWriter, length); | 228 m_fileWriter->initialize(fileWriter, length); |
229 if (m_successCallback) | 229 if (m_successCallback) { |
230 m_successCallback->handleEvent(m_fileWriter.release().get()); | 230 RefPtrWillBeRawPtr<FileWriterBase> writer = m_fileWriter.release(); |
231 m_successCallback->handleEvent(writer.get()); | |
haraken
2014/03/07 08:24:35
I'd write this as:
m_successCallback->handleEve
sof
2014/03/07 09:37:36
Done.
| |
232 } | |
231 m_successCallback.clear(); | 233 m_successCallback.clear(); |
232 } | 234 } |
233 | 235 |
234 // VoidCallbacks -------------------------------------------------------------- | 236 // VoidCallbacks -------------------------------------------------------------- |
235 | 237 |
236 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) | 238 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtr<VoidCallba ck> successCallback, PassOwnPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) |
237 { | 239 { |
238 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, fileSystem )); | 240 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, fileSystem )); |
239 } | 241 } |
240 | 242 |
241 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) | 243 VoidCallbacks::VoidCallbacks(PassOwnPtr<VoidCallback> successCallback, PassOwnPt r<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem) |
242 : FileSystemCallbacksBase(errorCallback, fileSystem) | 244 : FileSystemCallbacksBase(errorCallback, fileSystem) |
243 , m_successCallback(successCallback) | 245 , m_successCallback(successCallback) |
244 { | 246 { |
245 } | 247 } |
246 | 248 |
247 void VoidCallbacks::didSucceed() | 249 void VoidCallbacks::didSucceed() |
248 { | 250 { |
249 if (m_successCallback) | 251 if (m_successCallback) |
250 m_successCallback->handleEvent(); | 252 m_successCallback->handleEvent(); |
251 m_successCallback.clear(); | 253 m_successCallback.clear(); |
252 } | 254 } |
253 | 255 |
254 } // namespace | 256 } // namespace |
OLD | NEW |