| 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/EntriesCallback.h" | 40 #include "modules/filesystem/EntriesCallback.h" |
| 40 #include "modules/filesystem/EntryCallback.h" | 41 #include "modules/filesystem/EntryCallback.h" |
| 41 #include "modules/filesystem/EntrySync.h" | 42 #include "modules/filesystem/EntrySync.h" |
| 42 #include "modules/filesystem/ErrorCallback.h" | 43 #include "modules/filesystem/ErrorCallback.h" |
| 43 #include "modules/filesystem/FileEntry.h" | 44 #include "modules/filesystem/FileEntry.h" |
| 44 #include "modules/filesystem/FileSystemCallback.h" | 45 #include "modules/filesystem/FileSystemCallback.h" |
| 45 #include "modules/filesystem/MetadataCallback.h" | 46 #include "modules/filesystem/MetadataCallback.h" |
| 46 #include "wtf/PassRefPtr.h" | 47 #include "wtf/PassRefPtr.h" |
| 47 #include "wtf/RefCounted.h" | 48 #include "wtf/RefCounted.h" |
| 48 | 49 |
| 49 namespace WebCore { | 50 namespace WebCore { |
| 50 | 51 |
| 51 template <typename ResultType, typename CallbackArg> | 52 template <typename ResultType, typename CallbackArg> |
| 52 struct HelperResultType { | 53 struct HelperResultType { |
| 53 typedef PassRefPtr<ResultType> ReturnType; | 54 DISALLOW_ALLOCATION(); |
| 54 typedef RefPtr<ResultType> StorageType; | 55 public: |
| 56 typedef PassRefPtrWillBeRawPtr<ResultType> ReturnType; |
| 57 typedef RefPtrWillBeRawPtr<ResultType> StorageType; |
| 55 | 58 |
| 56 static ReturnType createFromCallbackArg(CallbackArg argument) | 59 static ReturnType createFromCallbackArg(CallbackArg argument) |
| 57 { | 60 { |
| 58 return ResultType::create(argument); | 61 return ResultType::create(argument); |
| 59 } | 62 } |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 // A helper template for FileSystemSync implementation. | 65 // A helper template for FileSystemSync implementation. |
| 63 template <typename SuccessCallback, typename CallbackArg, typename ResultType> | 66 template <typename SuccessCallback, typename CallbackArg, typename ResultType> |
| 64 class SyncCallbackHelper { | 67 class SyncCallbackHelper { |
| 65 WTF_MAKE_NONCOPYABLE(SyncCallbackHelper); | 68 WTF_MAKE_NONCOPYABLE(SyncCallbackHelper); |
| 69 STACK_ALLOCATED(); |
| 66 public: | 70 public: |
| 67 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT
ype; | 71 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT
ype; |
| 68 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; | 72 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; |
| 69 typedef typename ResultTypeTrait::StorageType ResultStorageType; | 73 typedef typename ResultTypeTrait::StorageType ResultStorageType; |
| 70 typedef typename ResultTypeTrait::ReturnType ResultReturnType; | 74 typedef typename ResultTypeTrait::ReturnType ResultReturnType; |
| 71 | 75 |
| 72 SyncCallbackHelper() | 76 SyncCallbackHelper() |
| 73 : m_errorCode(FileError::OK) | 77 : m_errorCode(FileError::OK) |
| 74 , m_completed(false) | 78 , m_completed(false) |
| 75 { | 79 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 m_result = ResultTypeTrait::createFromCallbackArg(result); | 148 m_result = ResultTypeTrait::createFromCallbackArg(result); |
| 145 m_completed = true; | 149 m_completed = true; |
| 146 } | 150 } |
| 147 | 151 |
| 148 ResultStorageType m_result; | 152 ResultStorageType m_result; |
| 149 FileError::ErrorCode m_errorCode; | 153 FileError::ErrorCode m_errorCode; |
| 150 bool m_completed; | 154 bool m_completed; |
| 151 }; | 155 }; |
| 152 | 156 |
| 153 struct EmptyType : public RefCounted<EmptyType> { | 157 struct EmptyType : public RefCounted<EmptyType> { |
| 154 static PassRefPtr<EmptyType> create(EmptyType*) | 158 static PassRefPtrWillBeRawPtr<EmptyType> create(EmptyType*) |
| 155 { | 159 { |
| 156 return nullptr; | 160 return nullptr; |
| 157 } | 161 } |
| 158 }; | 162 }; |
| 159 | 163 |
| 160 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; | 164 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; |
| 161 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; | 165 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; |
| 162 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; | 166 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; |
| 163 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; | 167 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; |
| 164 | 168 |
| 165 } // namespace WebCore | 169 } // namespace WebCore |
| 166 | 170 |
| 167 #endif // SyncCallbackHelper_h | 171 #endif // SyncCallbackHelper_h |
| OLD | NEW |