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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include "modules/filesystem/FileSystemCallback.h" | 49 #include "modules/filesystem/FileSystemCallback.h" |
50 #include "modules/filesystem/FileWriterBase.h" | 50 #include "modules/filesystem/FileWriterBase.h" |
51 #include "modules/filesystem/FileWriterBaseCallback.h" | 51 #include "modules/filesystem/FileWriterBaseCallback.h" |
52 #include "modules/filesystem/Metadata.h" | 52 #include "modules/filesystem/Metadata.h" |
53 #include "modules/filesystem/MetadataCallback.h" | 53 #include "modules/filesystem/MetadataCallback.h" |
54 #include "platform/FileMetadata.h" | 54 #include "platform/FileMetadata.h" |
55 #include "public/platform/WebFileWriter.h" | 55 #include "public/platform/WebFileWriter.h" |
56 | 56 |
57 namespace blink { | 57 namespace blink { |
58 | 58 |
59 FileSystemCallbacksBase::FileSystemCallbacksBase(PassOwnPtrWillBeRawPtr<ErrorCal lback> errorCallback, DOMFileSystemBase* fileSystem, ExecutionContext* context) | 59 FileSystemCallbacksBase::FileSystemCallbacksBase(ErrorCallback* errorCallback, D OMFileSystemBase* fileSystem, ExecutionContext* context) |
60 : m_errorCallback(errorCallback) | 60 : m_errorCallback(errorCallback) |
61 , m_fileSystem(fileSystem) | 61 , m_fileSystem(fileSystem) |
62 , m_executionContext(context) | 62 , m_executionContext(context) |
63 , m_asyncOperationId(0) | 63 , m_asyncOperationId(0) |
64 { | 64 { |
65 if (m_fileSystem) | 65 if (m_fileSystem) |
66 m_fileSystem->addPendingCallbacks(); | 66 m_fileSystem->addPendingCallbacks(); |
67 if (m_executionContext) | 67 if (m_executionContext) |
68 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(m_executionContext.get(), "FileSystem"); | 68 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarti ng(m_executionContext.get(), "FileSystem"); |
69 } | 69 } |
70 | 70 |
71 FileSystemCallbacksBase::~FileSystemCallbacksBase() | 71 FileSystemCallbacksBase::~FileSystemCallbacksBase() |
72 { | 72 { |
73 if (m_fileSystem) | 73 if (m_fileSystem) |
74 m_fileSystem->removePendingCallbacks(); | 74 m_fileSystem->removePendingCallbacks(); |
75 if (m_asyncOperationId && m_executionContext) | 75 if (m_asyncOperationId && m_executionContext) |
76 InspectorInstrumentation::traceAsyncOperationCompleted(m_executionContex t.get(), m_asyncOperationId); | 76 InspectorInstrumentation::traceAsyncOperationCompleted(m_executionContex t.get(), m_asyncOperationId); |
77 } | 77 } |
78 | 78 |
79 void FileSystemCallbacksBase::didFail(int code) | 79 void FileSystemCallbacksBase::didFail(int code) |
80 { | 80 { |
81 if (m_errorCallback) | 81 if (m_errorCallback) |
82 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(static_cast<FileError::ErrorCode>(code))); | 82 handleEventOrScheduleCallback(m_errorCallback.get(), FileError::create(s tatic_cast<FileError::ErrorCode>(code))); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
83 } | 83 } |
84 | 84 |
85 bool FileSystemCallbacksBase::shouldScheduleCallback() const | 85 bool FileSystemCallbacksBase::shouldScheduleCallback() const |
86 { | 86 { |
87 return !shouldBlockUntilCompletion() && m_executionContext && m_executionCon text->activeDOMObjectsAreSuspended(); | 87 return !shouldBlockUntilCompletion() && m_executionContext && m_executionCon text->activeDOMObjectsAreSuspended(); |
88 } | 88 } |
89 | 89 |
90 #if !ENABLE(OILPAN) | 90 #if !ENABLE(OILPAN) |
91 template <typename CB, typename CBArg> | 91 template <typename CB, typename CBArg> |
92 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtrWillBeRawP tr<CB> callback, RawPtr<CBArg> arg) | 92 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback, RawPtr <CBArg> arg) |
93 { | 93 { |
94 handleEventOrScheduleCallback(callback, arg.get()); | 94 handleEventOrScheduleCallback(callback, arg.get()); |
95 } | 95 } |
96 #endif | 96 #endif |
97 | 97 |
98 template <typename CB, typename CBArg> | 98 template <typename CB, typename CBArg> |
99 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtrWillBeRawP tr<CB> callback, CBArg* arg) | 99 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback, CBArg* arg) |
100 { | 100 { |
101 ASSERT(callback.get()); | 101 ASSERT(callback); |
102 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; | 102 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; |
103 if (shouldScheduleCallback()) | 103 if (shouldScheduleCallback()) |
104 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ; | 104 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ; |
105 else if (callback) | 105 else if (callback) |
106 callback->handleEvent(arg); | 106 callback->handleEvent(arg); |
107 m_executionContext.clear(); | 107 m_executionContext.clear(); |
108 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 108 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
109 } | 109 } |
110 | 110 |
111 template <typename CB, typename CBArg> | 111 template <typename CB, typename CBArg> |
112 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtrWillBeRawP tr<CB> callback, PassRefPtrWillBeRawPtr<CBArg> arg) | 112 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback, PassRe fPtrWillBeRawPtr<CBArg> arg) |
113 { | 113 { |
114 ASSERT(callback.get()); | 114 ASSERT(callback); |
115 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; | 115 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; |
116 if (shouldScheduleCallback()) | 116 if (shouldScheduleCallback()) |
117 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ; | 117 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg) ; |
118 else if (callback) | 118 else if (callback) |
119 callback->handleEvent(arg.get()); | 119 callback->handleEvent(arg.get()); |
120 m_executionContext.clear(); | 120 m_executionContext.clear(); |
121 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 121 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
122 } | 122 } |
123 | 123 |
124 template <typename CB> | 124 template <typename CB> |
125 void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtrWillBeRawP tr<CB> callback) | 125 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback) |
126 { | 126 { |
127 ASSERT(callback.get()); | 127 ASSERT(callback); |
128 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; | 128 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync OperationCompletedCallbackStarting(m_executionContext.get(), m_asyncOperationId) ; |
129 if (shouldScheduleCallback()) | 129 if (shouldScheduleCallback()) |
130 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback); | 130 DOMFileSystem::scheduleCallback(m_executionContext.get(), callback); |
131 else if (callback) | 131 else if (callback) |
132 callback->handleEvent(); | 132 callback->handleEvent(); |
133 m_executionContext.clear(); | 133 m_executionContext.clear(); |
134 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 134 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
135 } | 135 } |
136 | 136 |
137 // EntryCallbacks ------------------------------------------------------------- | 137 // EntryCallbacks ------------------------------------------------------------- |
138 | 138 |
139 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(PassOwnPtrWillBeRawP tr<EntryCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCa llback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory) | 139 PassOwnPtr<AsyncFileSystemCallbacks> EntryCallbacks::create(EntryCallback* succe ssCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSyst emBase* fileSystem, const String& expectedPath, bool isDirectory) |
140 { | 140 { |
141 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, context, fileSystem, expectedPath, isDirectory)); | 141 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, context, fileSystem, expectedPath, isDirectory)); |
142 } | 142 } |
143 | 143 |
144 EntryCallbacks::EntryCallbacks(PassOwnPtrWillBeRawPtr<EntryCallback> successCall back, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContext* con text, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirector y) | 144 EntryCallbacks::EntryCallbacks(EntryCallback* successCallback, ErrorCallback* er rorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem, const Str ing& expectedPath, bool isDirectory) |
145 : FileSystemCallbacksBase(errorCallback, fileSystem, context) | 145 : FileSystemCallbacksBase(errorCallback, fileSystem, context) |
146 , m_successCallback(successCallback) | 146 , m_successCallback(successCallback) |
147 , m_expectedPath(expectedPath) | 147 , m_expectedPath(expectedPath) |
148 , m_isDirectory(isDirectory) | 148 , m_isDirectory(isDirectory) |
149 { | 149 { |
150 } | 150 } |
151 | 151 |
152 void EntryCallbacks::didSucceed() | 152 void EntryCallbacks::didSucceed() |
153 { | 153 { |
154 if (m_successCallback) { | 154 if (m_successCallback) { |
155 if (m_isDirectory) | 155 if (m_isDirectory) |
156 handleEventOrScheduleCallback(m_successCallback.release(), Directory Entry::create(m_fileSystem, m_expectedPath)); | 156 handleEventOrScheduleCallback(m_successCallback.get(), DirectoryEntr y::create(m_fileSystem, m_expectedPath)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
157 else | 157 else |
158 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry ::create(m_fileSystem, m_expectedPath)); | 158 handleEventOrScheduleCallback(m_successCallback.get(), FileEntry::cr eate(m_fileSystem, m_expectedPath)); |
tkent
2014/09/22 02:04:05
Ditto.
keishi
2014/09/22 05:44:02
Done.
| |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 // EntriesCallbacks ----------------------------------------------------------- | 162 // EntriesCallbacks ----------------------------------------------------------- |
163 | 163 |
164 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(PassOwnPtrWillBeRa wPtr<EntriesCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> err orCallback, ExecutionContext* context, DirectoryReaderBase* directoryReader, con st String& basePath) | 164 PassOwnPtr<AsyncFileSystemCallbacks> EntriesCallbacks::create(EntriesCallback* s uccessCallback, ErrorCallback* errorCallback, ExecutionContext* context, Directo ryReaderBase* directoryReader, const String& basePath) |
165 { | 165 { |
166 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, context , directoryReader, basePath)); | 166 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, context , directoryReader, basePath)); |
167 } | 167 } |
168 | 168 |
169 EntriesCallbacks::EntriesCallbacks(PassOwnPtrWillBeRawPtr<EntriesCallback> succe ssCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContex t* context, DirectoryReaderBase* directoryReader, const String& basePath) | 169 EntriesCallbacks::EntriesCallbacks(EntriesCallback* successCallback, ErrorCallba ck* errorCallback, ExecutionContext* context, DirectoryReaderBase* directoryRead er, const String& basePath) |
170 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem(), cont ext) | 170 : FileSystemCallbacksBase(errorCallback, directoryReader->filesystem(), cont ext) |
171 , m_successCallback(successCallback) | 171 , m_successCallback(successCallback) |
172 , m_directoryReader(directoryReader) | 172 , m_directoryReader(directoryReader) |
173 , m_basePath(basePath) | 173 , m_basePath(basePath) |
174 { | 174 { |
175 ASSERT(m_directoryReader); | 175 ASSERT(m_directoryReader); |
176 } | 176 } |
177 | 177 |
178 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) | 178 void EntriesCallbacks::didReadDirectoryEntry(const String& name, bool isDirector y) |
179 { | 179 { |
(...skipping 12 matching lines...) Expand all Loading... | |
192 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync CallbackStarting(m_executionContext.get(), m_asyncOperationId); | 192 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync CallbackStarting(m_executionContext.get(), m_asyncOperationId); |
193 if (m_successCallback) | 193 if (m_successCallback) |
194 m_successCallback->handleEvent(entries); | 194 m_successCallback->handleEvent(entries); |
195 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 195 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
196 if (!hasMore) | 196 if (!hasMore) |
197 InspectorInstrumentation::traceAsyncOperationCompleted(m_executionContex t.get(), m_asyncOperationId); | 197 InspectorInstrumentation::traceAsyncOperationCompleted(m_executionContex t.get(), m_asyncOperationId); |
198 } | 198 } |
199 | 199 |
200 // FileSystemCallbacks -------------------------------------------------------- | 200 // FileSystemCallbacks -------------------------------------------------------- |
201 | 201 |
202 PassOwnPtr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(PassOwnPtrWillB eRawPtr<FileSystemCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallbac k> errorCallback, ExecutionContext* context, FileSystemType type) | 202 PassOwnPtr<AsyncFileSystemCallbacks> FileSystemCallbacks::create(FileSystemCallb ack* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, F ileSystemType type) |
203 { | 203 { |
204 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, cont ext, type)); | 204 return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, cont ext, type)); |
205 } | 205 } |
206 | 206 |
207 FileSystemCallbacks::FileSystemCallbacks(PassOwnPtrWillBeRawPtr<FileSystemCallba ck> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, Execut ionContext* context, FileSystemType type) | 207 FileSystemCallbacks::FileSystemCallbacks(FileSystemCallback* successCallback, Er rorCallback* errorCallback, ExecutionContext* context, FileSystemType type) |
208 : FileSystemCallbacksBase(errorCallback, nullptr, context) | 208 : FileSystemCallbacksBase(errorCallback, nullptr, context) |
209 , m_successCallback(successCallback) | 209 , m_successCallback(successCallback) |
210 , m_type(type) | 210 , m_type(type) |
211 { | 211 { |
212 } | 212 } |
213 | 213 |
214 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL) | 214 void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& root URL) |
215 { | 215 { |
216 if (m_successCallback) | 216 if (m_successCallback) |
217 handleEventOrScheduleCallback(m_successCallback.release(), DOMFileSystem ::create(m_executionContext.get(), name, m_type, rootURL)); | 217 handleEventOrScheduleCallback(m_successCallback.get(), DOMFileSystem::cr eate(m_executionContext.get(), name, m_type, rootURL)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
218 } | 218 } |
219 | 219 |
220 // ResolveURICallbacks -------------------------------------------------------- | 220 // ResolveURICallbacks -------------------------------------------------------- |
221 | 221 |
222 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(PassOwnPtrWillB eRawPtr<EntryCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> er rorCallback, ExecutionContext* context) | 222 PassOwnPtr<AsyncFileSystemCallbacks> ResolveURICallbacks::create(EntryCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context) |
223 { | 223 { |
224 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, cont ext)); | 224 return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, cont ext)); |
225 } | 225 } |
226 | 226 |
227 ResolveURICallbacks::ResolveURICallbacks(PassOwnPtrWillBeRawPtr<EntryCallback> s uccessCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionCo ntext* context) | 227 ResolveURICallbacks::ResolveURICallbacks(EntryCallback* successCallback, ErrorCa llback* errorCallback, ExecutionContext* context) |
228 : FileSystemCallbacksBase(errorCallback, nullptr, context) | 228 : FileSystemCallbacksBase(errorCallback, nullptr, context) |
229 , m_successCallback(successCallback) | 229 , m_successCallback(successCallback) |
230 { | 230 { |
231 } | 231 } |
232 | 232 |
233 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) | 233 void ResolveURICallbacks::didResolveURL(const String& name, const KURL& rootURL, FileSystemType type, const String& filePath, bool isDirectory) |
234 { | 234 { |
235 DOMFileSystem* filesystem = DOMFileSystem::create(m_executionContext.get(), name, type, rootURL); | 235 DOMFileSystem* filesystem = DOMFileSystem::create(m_executionContext.get(), name, type, rootURL); |
236 DirectoryEntry* root = filesystem->root(); | 236 DirectoryEntry* root = filesystem->root(); |
237 | 237 |
238 String absolutePath; | 238 String absolutePath; |
239 if (!DOMFileSystemBase::pathToAbsolutePath(type, root, filePath, absolutePat h)) { | 239 if (!DOMFileSystemBase::pathToAbsolutePath(type, root, filePath, absolutePat h)) { |
240 handleEventOrScheduleCallback(m_errorCallback.release(), FileError::crea te(FileError::INVALID_MODIFICATION_ERR)); | 240 handleEventOrScheduleCallback(m_errorCallback.get(), FileError::create(F ileError::INVALID_MODIFICATION_ERR)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:02
Done.
| |
241 return; | 241 return; |
242 } | 242 } |
243 | 243 |
244 if (isDirectory) | 244 if (isDirectory) |
245 handleEventOrScheduleCallback(m_successCallback.release(), DirectoryEntr y::create(filesystem, absolutePath)); | 245 handleEventOrScheduleCallback(m_successCallback.get(), DirectoryEntry::c reate(filesystem, absolutePath)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:02
Done.
| |
246 else | 246 else |
247 handleEventOrScheduleCallback(m_successCallback.release(), FileEntry::cr eate(filesystem, absolutePath)); | 247 handleEventOrScheduleCallback(m_successCallback.get(), FileEntry::create (filesystem, absolutePath)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:02
Done.
| |
248 } | 248 } |
249 | 249 |
250 // MetadataCallbacks ---------------------------------------------------------- | 250 // MetadataCallbacks ---------------------------------------------------------- |
251 | 251 |
252 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(PassOwnPtrWillBeR awPtr<MetadataCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> e rrorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem) | 252 PassOwnPtr<AsyncFileSystemCallbacks> MetadataCallbacks::create(MetadataCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFi leSystemBase* fileSystem) |
253 { | 253 { |
254 return adoptPtr(new MetadataCallbacks(successCallback, errorCallback, contex t, fileSystem)); | 254 return adoptPtr(new MetadataCallbacks(successCallback, errorCallback, contex t, fileSystem)); |
255 } | 255 } |
256 | 256 |
257 MetadataCallbacks::MetadataCallbacks(PassOwnPtrWillBeRawPtr<MetadataCallback> su ccessCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionCon text* context, DOMFileSystemBase* fileSystem) | 257 MetadataCallbacks::MetadataCallbacks(MetadataCallback* successCallback, ErrorCal lback* errorCallback, ExecutionContext* context, DOMFileSystemBase* fileSystem) |
258 : FileSystemCallbacksBase(errorCallback, fileSystem, context) | 258 : FileSystemCallbacksBase(errorCallback, fileSystem, context) |
259 , m_successCallback(successCallback) | 259 , m_successCallback(successCallback) |
260 { | 260 { |
261 } | 261 } |
262 | 262 |
263 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) | 263 void MetadataCallbacks::didReadMetadata(const FileMetadata& metadata) |
264 { | 264 { |
265 if (m_successCallback) | 265 if (m_successCallback) |
266 handleEventOrScheduleCallback(m_successCallback.release(), Metadata::cre ate(metadata)); | 266 handleEventOrScheduleCallback(m_successCallback.get(), Metadata::create( metadata)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
267 } | 267 } |
268 | 268 |
269 // FileWriterBaseCallbacks ---------------------------------------------------- | 269 // FileWriterBaseCallbacks ---------------------------------------------------- |
270 | 270 |
271 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, PassOwnPtrWillBeRawPtr<FileWriterBaseCal lback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, Exe cutionContext* context) | 271 PassOwnPtr<AsyncFileSystemCallbacks> FileWriterBaseCallbacks::create(PassRefPtrW illBeRawPtr<FileWriterBase> fileWriter, FileWriterBaseCallback* successCallback, ErrorCallback* errorCallback, ExecutionContext* context) |
272 { | 272 { |
273 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback, context)); | 273 return adoptPtr(new FileWriterBaseCallbacks(fileWriter, successCallback, err orCallback, context)); |
274 } | 274 } |
275 | 275 |
276 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, PassOwnPtrWillBeRawPtr<FileWriterBaseCallback> successCallba ck, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContext* conte xt) | 276 FileWriterBaseCallbacks::FileWriterBaseCallbacks(PassRefPtrWillBeRawPtr<FileWrit erBase> fileWriter, FileWriterBaseCallback* successCallback, ErrorCallback* erro rCallback, ExecutionContext* context) |
277 : FileSystemCallbacksBase(errorCallback, nullptr, context) | 277 : FileSystemCallbacksBase(errorCallback, nullptr, context) |
278 , m_fileWriter(fileWriter.get()) | 278 , m_fileWriter(fileWriter.get()) |
279 , m_successCallback(successCallback) | 279 , m_successCallback(successCallback) |
280 { | 280 { |
281 } | 281 } |
282 | 282 |
283 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<WebFileWriter> file Writer, long long length) | 283 void FileWriterBaseCallbacks::didCreateFileWriter(PassOwnPtr<WebFileWriter> file Writer, long long length) |
284 { | 284 { |
285 m_fileWriter->initialize(fileWriter, length); | 285 m_fileWriter->initialize(fileWriter, length); |
286 if (m_successCallback) | 286 if (m_successCallback) |
287 handleEventOrScheduleCallback(m_successCallback.release(), m_fileWriter. release()); | 287 handleEventOrScheduleCallback(m_successCallback.get(), m_fileWriter.rele ase()); |
tkent
2014/09/22 02:04:05
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
288 } | 288 } |
289 | 289 |
290 // SnapshotFileCallback ------------------------------------------------------- | 290 // SnapshotFileCallback ------------------------------------------------------- |
291 | 291 |
292 PassOwnPtr<AsyncFileSystemCallbacks> SnapshotFileCallback::create(DOMFileSystemB ase* filesystem, const String& name, const KURL& url, PassOwnPtrWillBeRawPtr<Fil eCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContext* context) | 292 PassOwnPtr<AsyncFileSystemCallbacks> SnapshotFileCallback::create(DOMFileSystemB ase* filesystem, const String& name, const KURL& url, FileCallback* successCallb ack, ErrorCallback* errorCallback, ExecutionContext* context) |
293 { | 293 { |
294 return adoptPtr(new SnapshotFileCallback(filesystem, name, url, successCallb ack, errorCallback, context)); | 294 return adoptPtr(new SnapshotFileCallback(filesystem, name, url, successCallb ack, errorCallback, context)); |
295 } | 295 } |
296 | 296 |
297 SnapshotFileCallback::SnapshotFileCallback(DOMFileSystemBase* filesystem, const String& name, const KURL& url, PassOwnPtrWillBeRawPtr<FileCallback> successCallb ack, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContext* cont ext) | 297 SnapshotFileCallback::SnapshotFileCallback(DOMFileSystemBase* filesystem, const String& name, const KURL& url, FileCallback* successCallback, ErrorCallback* err orCallback, ExecutionContext* context) |
298 : FileSystemCallbacksBase(errorCallback, filesystem, context) | 298 : FileSystemCallbacksBase(errorCallback, filesystem, context) |
299 , m_name(name) | 299 , m_name(name) |
300 , m_url(url) | 300 , m_url(url) |
301 , m_successCallback(successCallback) | 301 , m_successCallback(successCallback) |
302 { | 302 { |
303 } | 303 } |
304 | 304 |
305 void SnapshotFileCallback::didCreateSnapshotFile(const FileMetadata& metadata, P assRefPtr<BlobDataHandle> snapshot) | 305 void SnapshotFileCallback::didCreateSnapshotFile(const FileMetadata& metadata, P assRefPtr<BlobDataHandle> snapshot) |
306 { | 306 { |
307 if (!m_successCallback) | 307 if (!m_successCallback) |
308 return; | 308 return; |
309 | 309 |
310 // We can't directly use the snapshot blob data handle because the content t ype on it hasn't been set. | 310 // We can't directly use the snapshot blob data handle because the content t ype on it hasn't been set. |
311 // The |snapshot| param is here to provide a a chain of custody thru thread bridging that is held onto until | 311 // The |snapshot| param is here to provide a a chain of custody thru thread bridging that is held onto until |
312 // *after* we've coined a File with a new handle that has the correct type s et on it. This allows the | 312 // *after* we've coined a File with a new handle that has the correct type s et on it. This allows the |
313 // blob storage system to track when a temp file can and can't be safely del eted. | 313 // blob storage system to track when a temp file can and can't be safely del eted. |
314 | 314 |
315 handleEventOrScheduleCallback(m_successCallback.release(), DOMFileSystemBase ::createFile(metadata, m_url, m_fileSystem->type(), m_name)); | 315 handleEventOrScheduleCallback(m_successCallback.get(), DOMFileSystemBase::cr eateFile(metadata, m_url, m_fileSystem->type(), m_name)); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:02
Done.
| |
316 } | 316 } |
317 | 317 |
318 // VoidCallbacks -------------------------------------------------------------- | 318 // VoidCallbacks -------------------------------------------------------------- |
319 | 319 |
320 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(PassOwnPtrWillBeRawPt r<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCall back, ExecutionContext* context, DOMFileSystemBase* fileSystem) | 320 PassOwnPtr<AsyncFileSystemCallbacks> VoidCallbacks::create(VoidCallback* success Callback, ErrorCallback* errorCallback, ExecutionContext* context, DOMFileSystem Base* fileSystem) |
321 { | 321 { |
322 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, context, f ileSystem)); | 322 return adoptPtr(new VoidCallbacks(successCallback, errorCallback, context, f ileSystem)); |
323 } | 323 } |
324 | 324 |
325 VoidCallbacks::VoidCallbacks(PassOwnPtrWillBeRawPtr<VoidCallback> successCallbac k, PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback, ExecutionContext* contex t, DOMFileSystemBase* fileSystem) | 325 VoidCallbacks::VoidCallbacks(VoidCallback* successCallback, ErrorCallback* error Callback, ExecutionContext* context, DOMFileSystemBase* fileSystem) |
326 : FileSystemCallbacksBase(errorCallback, fileSystem, context) | 326 : FileSystemCallbacksBase(errorCallback, fileSystem, context) |
327 , m_successCallback(successCallback) | 327 , m_successCallback(successCallback) |
328 { | 328 { |
329 } | 329 } |
330 | 330 |
331 void VoidCallbacks::didSucceed() | 331 void VoidCallbacks::didSucceed() |
332 { | 332 { |
333 if (m_successCallback) | 333 if (m_successCallback) |
334 handleEventOrScheduleCallback(m_successCallback.release()); | 334 handleEventOrScheduleCallback(m_successCallback.get()); |
tkent
2014/09/22 02:04:06
Ditto.
keishi
2014/09/22 05:44:01
Done.
| |
335 } | 335 } |
336 | 336 |
337 } // namespace blink | 337 } // namespace blink |
OLD | NEW |