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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na
me, FileSystemType type, const KURL& rootURL) | 58 DOMFileSystemSync::DOMFileSystemSync(ExecutionContext* context, const String& na
me, FileSystemType type, const KURL& rootURL) |
59 : DOMFileSystemBase(context, name, type, rootURL) | 59 : DOMFileSystemBase(context, name, type, rootURL) |
60 { | 60 { |
61 } | 61 } |
62 | 62 |
63 DOMFileSystemSync::~DOMFileSystemSync() | 63 DOMFileSystemSync::~DOMFileSystemSync() |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 void DOMFileSystemSync::reportError(PassOwnPtrWillBeRawPtr<ErrorCallback> errorC
allback, PassRefPtrWillBeRawPtr<FileError> fileError) | 67 void DOMFileSystemSync::reportError(ErrorCallback* errorCallback, PassRefPtrWill
BeRawPtr<FileError> fileError) |
68 { | 68 { |
69 errorCallback->handleEvent(fileError.get()); | 69 errorCallback->handleEvent(fileError.get()); |
70 } | 70 } |
71 | 71 |
72 DirectoryEntrySync* DOMFileSystemSync::root() | 72 DirectoryEntrySync* DOMFileSystemSync::root() |
73 { | 73 { |
74 return DirectoryEntrySync::create(this, DOMFilePath::root); | 74 return DirectoryEntrySync::create(this, DOMFilePath::root); |
75 } | 75 } |
76 | 76 |
77 namespace { | 77 namespace { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 exceptionState.throwDOMException(result->m_code, "Could not create '" +
fileEntry->name() + "'."); | 158 exceptionState.throwDOMException(result->m_code, "Could not create '" +
fileEntry->name() + "'."); |
159 return nullptr; | 159 return nullptr; |
160 } | 160 } |
161 return result->m_file.get(); | 161 return result->m_file.get(); |
162 } | 162 } |
163 | 163 |
164 namespace { | 164 namespace { |
165 | 165 |
166 class ReceiveFileWriterCallback FINAL : public FileWriterBaseCallback { | 166 class ReceiveFileWriterCallback FINAL : public FileWriterBaseCallback { |
167 public: | 167 public: |
168 static PassOwnPtrWillBeRawPtr<ReceiveFileWriterCallback> create() | 168 static ReceiveFileWriterCallback* create() |
169 { | 169 { |
170 return adoptPtrWillBeNoop(new ReceiveFileWriterCallback()); | 170 return new ReceiveFileWriterCallback(); |
171 } | 171 } |
172 | 172 |
173 virtual void handleEvent(FileWriterBase*) OVERRIDE | 173 virtual void handleEvent(FileWriterBase*) OVERRIDE |
174 { | 174 { |
175 } | 175 } |
176 | 176 |
177 private: | 177 private: |
178 ReceiveFileWriterCallback() | 178 ReceiveFileWriterCallback() |
179 { | 179 { |
180 } | 180 } |
181 }; | 181 }; |
182 | 182 |
183 class LocalErrorCallback FINAL : public ErrorCallback { | 183 class LocalErrorCallback FINAL : public ErrorCallback { |
184 public: | 184 public: |
185 static PassOwnPtrWillBeRawPtr<LocalErrorCallback> create(FileError::ErrorCod
e& errorCode) | 185 static LocalErrorCallback* create(FileError::ErrorCode& errorCode) |
186 { | 186 { |
187 return adoptPtrWillBeNoop(new LocalErrorCallback(errorCode)); | 187 return new LocalErrorCallback(errorCode); |
188 } | 188 } |
189 | 189 |
190 virtual void handleEvent(FileError* error) OVERRIDE | 190 virtual void handleEvent(FileError* error) OVERRIDE |
191 { | 191 { |
192 ASSERT(error->code() != FileError::OK); | 192 ASSERT(error->code() != FileError::OK); |
193 m_errorCode = error->code(); | 193 m_errorCode = error->code(); |
194 } | 194 } |
195 | 195 |
196 private: | 196 private: |
197 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) | 197 explicit LocalErrorCallback(FileError::ErrorCode& errorCode) |
198 : m_errorCode(errorCode) | 198 : m_errorCode(errorCode) |
199 { | 199 { |
200 } | 200 } |
201 | 201 |
202 FileError::ErrorCode& m_errorCode; | 202 FileError::ErrorCode& m_errorCode; |
203 }; | 203 }; |
204 | 204 |
205 } | 205 } |
206 | 206 |
207 FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry,
ExceptionState& exceptionState) | 207 FileWriterSync* DOMFileSystemSync::createWriter(const FileEntrySync* fileEntry,
ExceptionState& exceptionState) |
208 { | 208 { |
209 ASSERT(fileEntry); | 209 ASSERT(fileEntry); |
210 | 210 |
211 FileWriterSync* fileWriter = FileWriterSync::create(); | 211 FileWriterSync* fileWriter = FileWriterSync::create(); |
212 OwnPtrWillBeRawPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileW
riterCallback::create(); | 212 ReceiveFileWriterCallback* successCallback = ReceiveFileWriterCallback::crea
te(); |
213 FileError::ErrorCode errorCode = FileError::OK; | 213 FileError::ErrorCode errorCode = FileError::OK; |
214 OwnPtrWillBeRawPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::c
reate(errorCode); | 214 LocalErrorCallback* errorCallback = LocalErrorCallback::create(errorCode); |
215 | 215 |
216 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create
(fileWriter, successCallback.release(), errorCallback.release(), m_context); | 216 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileWriterBaseCallbacks::create
(fileWriter, successCallback, errorCallback, m_context); |
217 callbacks->setShouldBlockUntilCompletion(true); | 217 callbacks->setShouldBlockUntilCompletion(true); |
218 | 218 |
219 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, c
allbacks.release()); | 219 fileSystem()->createFileWriter(createFileSystemURL(fileEntry), fileWriter, c
allbacks.release()); |
220 if (errorCode != FileError::OK) { | 220 if (errorCode != FileError::OK) { |
221 FileError::throwDOMException(exceptionState, errorCode); | 221 FileError::throwDOMException(exceptionState, errorCode); |
222 return 0; | 222 return 0; |
223 } | 223 } |
224 return fileWriter; | 224 return fileWriter; |
225 } | 225 } |
226 | 226 |
227 } | 227 } |
OLD | NEW |