Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #ifndef SyncCallbackHelper_h | 32 #ifndef SyncCallbackHelper_h |
| 33 #define SyncCallbackHelper_h | 33 #define SyncCallbackHelper_h |
| 34 | 34 |
| 35 #include "bindings/v8/ExceptionState.h" | 35 #include "bindings/v8/ExceptionState.h" |
| 36 #include "core/fileapi/FileError.h" | 36 #include "core/fileapi/FileError.h" |
| 37 #include "core/html/VoidCallback.h" | 37 #include "core/html/VoidCallback.h" |
| 38 #include "heap/Handle.h" | |
| 38 #include "modules/filesystem/DirectoryEntry.h" | 39 #include "modules/filesystem/DirectoryEntry.h" |
| 39 #include "modules/filesystem/DirectoryReaderSync.h" | 40 #include "modules/filesystem/DirectoryReaderSync.h" |
| 40 #include "modules/filesystem/EntriesCallback.h" | 41 #include "modules/filesystem/EntriesCallback.h" |
| 41 #include "modules/filesystem/EntryCallback.h" | 42 #include "modules/filesystem/EntryCallback.h" |
| 42 #include "modules/filesystem/EntrySync.h" | 43 #include "modules/filesystem/EntrySync.h" |
| 43 #include "modules/filesystem/ErrorCallback.h" | 44 #include "modules/filesystem/ErrorCallback.h" |
| 44 #include "modules/filesystem/FileEntry.h" | 45 #include "modules/filesystem/FileEntry.h" |
| 45 #include "modules/filesystem/FileSystemCallback.h" | 46 #include "modules/filesystem/FileSystemCallback.h" |
| 46 #include "modules/filesystem/MetadataCallback.h" | 47 #include "modules/filesystem/MetadataCallback.h" |
| 47 #include "wtf/PassRefPtr.h" | 48 #include "wtf/PassRefPtr.h" |
| 48 #include "wtf/RefCounted.h" | 49 #include "wtf/RefCounted.h" |
| 49 | 50 |
| 50 namespace WebCore { | 51 namespace WebCore { |
| 51 | 52 |
| 52 template <typename ResultType, typename CallbackArg> | 53 template <typename ResultType, typename CallbackArg> |
| 53 struct HelperResultType { | 54 struct HelperResultType { |
| 54 typedef PassRefPtr<ResultType> ReturnType; | 55 typedef PassRefPtrWillBeRawPtr<ResultType> ReturnType; |
|
haraken
2014/03/07 08:24:35
This is used by only one place. Shall we avoid usi
sof
2014/03/07 09:37:36
It is used later by derived classes to gain access
| |
| 55 typedef RefPtr<ResultType> StorageType; | 56 typedef RefPtrWillBeRawPtr<ResultType> StorageType; |
|
haraken
2014/03/07 08:24:35
This is unused. Shall we remove?
sof
2014/03/07 09:37:36
Same, elsewhere used.
| |
| 56 | 57 |
| 57 static ReturnType createFromCallbackArg(CallbackArg argument) | 58 static ReturnType createFromCallbackArg(CallbackArg argument) |
| 58 { | 59 { |
| 59 return ResultType::create(argument); | 60 return ResultType::create(argument); |
| 60 } | 61 } |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 template <> | 64 template <> |
| 64 struct HelperResultType<EntrySyncVector, const EntryVector&> { | 65 struct HelperResultType<EntrySyncVector, const EntryVector&> { |
| 65 typedef EntrySyncVector ReturnType; | 66 typedef EntrySyncVector ReturnType; |
| 66 typedef EntrySyncVector StorageType; | 67 typedef EntrySyncVector StorageType; |
|
haraken
2014/03/07 08:24:35
Looks like these two typedefs are unused. Shall we
sof
2014/03/07 09:37:36
Ditto, elsewhere used.
| |
| 67 | 68 |
| 68 static EntrySyncVector createFromCallbackArg(const EntryVector& entries) | 69 static EntrySyncVector createFromCallbackArg(const EntryVector& entries) |
| 69 { | 70 { |
| 70 EntrySyncVector result; | 71 EntrySyncVector result; |
| 71 size_t entryCount = entries.size(); | 72 size_t entryCount = entries.size(); |
| 72 result.reserveInitialCapacity(entryCount); | 73 result.reserveInitialCapacity(entryCount); |
| 73 for (size_t i = 0; i < entryCount; ++i) | 74 for (size_t i = 0; i < entryCount; ++i) |
| 74 result.uncheckedAppend(EntrySync::create(entries[i].get())); | 75 result.uncheckedAppend(EntrySync::create(entries[i].get())); |
| 75 return result; | 76 return result; |
| 76 } | 77 } |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 // A helper template for FileSystemSync implementation. | 80 // A helper template for FileSystemSync implementation. |
| 80 template <typename SuccessCallback, typename CallbackArg, typename ResultType> | 81 template <typename SuccessCallback, typename CallbackArg, typename ResultType> |
| 81 class SyncCallbackHelper { | 82 class SyncCallbackHelper { |
| 82 WTF_MAKE_NONCOPYABLE(SyncCallbackHelper); | 83 WTF_MAKE_NONCOPYABLE(SyncCallbackHelper); |
| 84 STACK_ALLOCATED(); | |
| 83 public: | 85 public: |
| 84 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT ype; | 86 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT ype; |
| 85 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; | 87 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; |
| 86 typedef typename ResultTypeTrait::StorageType ResultStorageType; | 88 typedef typename ResultTypeTrait::StorageType ResultStorageType; |
| 87 typedef typename ResultTypeTrait::ReturnType ResultReturnType; | 89 typedef typename ResultTypeTrait::ReturnType ResultReturnType; |
| 88 | 90 |
| 89 SyncCallbackHelper() | 91 SyncCallbackHelper() |
| 90 : m_errorCode(FileError::OK) | 92 : m_errorCode(FileError::OK) |
| 91 , m_completed(false) | 93 , m_completed(false) |
| 92 { | 94 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 m_result = ResultTypeTrait::createFromCallbackArg(result); | 163 m_result = ResultTypeTrait::createFromCallbackArg(result); |
| 162 m_completed = true; | 164 m_completed = true; |
| 163 } | 165 } |
| 164 | 166 |
| 165 ResultStorageType m_result; | 167 ResultStorageType m_result; |
| 166 FileError::ErrorCode m_errorCode; | 168 FileError::ErrorCode m_errorCode; |
| 167 bool m_completed; | 169 bool m_completed; |
| 168 }; | 170 }; |
| 169 | 171 |
| 170 struct EmptyType : public RefCounted<EmptyType> { | 172 struct EmptyType : public RefCounted<EmptyType> { |
| 171 static PassRefPtr<EmptyType> create(EmptyType*) | 173 static PassRefPtrWillBeRawPtr<EmptyType> create(EmptyType*) |
| 172 { | 174 { |
| 173 return nullptr; | 175 return nullptr; |
| 174 } | 176 } |
| 175 }; | 177 }; |
| 176 | 178 |
| 177 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe lper; | 179 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe lper; |
| 178 typedef SyncCallbackHelper<EntriesCallback, const EntryVector&, EntrySyncVector> EntriesSyncCallbackHelper; | 180 typedef SyncCallbackHelper<EntriesCallback, const EntryVector&, EntrySyncVector> EntriesSyncCallbackHelper; |
| 179 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa llbackHelper; | 181 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa llbackHelper; |
| 180 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback Helper; | 182 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback Helper; |
| 181 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync > FileSystemSyncCallbackHelper; | 183 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync > FileSystemSyncCallbackHelper; |
| 182 | 184 |
| 183 } // namespace WebCore | 185 } // namespace WebCore |
| 184 | 186 |
| 185 #endif // SyncCallbackHelper_h | 187 #endif // SyncCallbackHelper_h |
| OLD | NEW |