| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "platform/heap/Handle.h" | 46 #include "platform/heap/Handle.h" |
| 47 #include "wtf/PassRefPtr.h" | 47 #include "wtf/PassRefPtr.h" |
| 48 #include "wtf/RefCounted.h" | 48 #include "wtf/RefCounted.h" |
| 49 | 49 |
| 50 namespace WebCore { | 50 namespace WebCore { |
| 51 | 51 |
| 52 template <typename ResultType, typename CallbackArg> | 52 template <typename ResultType, typename CallbackArg> |
| 53 struct HelperResultType { | 53 struct HelperResultType { |
| 54 DISALLOW_ALLOCATION(); | 54 DISALLOW_ALLOCATION(); |
| 55 public: | 55 public: |
| 56 typedef PassRefPtrWillBeRawPtr<ResultType> ReturnType; | 56 typedef ResultType* ReturnType; |
| 57 typedef RefPtrWillBePersistent<ResultType> StorageType; | 57 typedef Persistent<ResultType> StorageType; |
| 58 | 58 |
| 59 static ReturnType createFromCallbackArg(CallbackArg argument) | 59 static ReturnType createFromCallbackArg(CallbackArg argument) |
| 60 { | 60 { |
| 61 return ResultType::create(argument); | 61 return ResultType::create(argument); |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // A helper template for FileSystemSync implementation. | 65 // A helper template for FileSystemSync implementation. |
| 66 template <typename SuccessCallback, typename CallbackArg, typename ResultType> | 66 template <typename SuccessCallback, typename CallbackArg, typename ResultType> |
| 67 class SyncCallbackHelper FINAL : public RefCounted<SyncCallbackHelper<SuccessCal
lback, CallbackArg, ResultType> > { | 67 class SyncCallbackHelper FINAL : public RefCounted<SyncCallbackHelper<SuccessCal
lback, CallbackArg, ResultType> > { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 { | 150 { |
| 151 m_result = ResultTypeTrait::createFromCallbackArg(result); | 151 m_result = ResultTypeTrait::createFromCallbackArg(result); |
| 152 m_completed = true; | 152 m_completed = true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 ResultStorageType m_result; | 155 ResultStorageType m_result; |
| 156 FileError::ErrorCode m_errorCode; | 156 FileError::ErrorCode m_errorCode; |
| 157 bool m_completed; | 157 bool m_completed; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 struct EmptyType : public RefCountedWillBeGarbageCollected<EmptyType> { | 160 struct EmptyType : public GarbageCollected<EmptyType> { |
| 161 static PassRefPtrWillBeRawPtr<EmptyType> create(EmptyType*) | 161 static EmptyType* create(EmptyType*) |
| 162 { | 162 { |
| 163 return nullptr; | 163 return 0; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void trace(Visitor*) { } | 166 void trace(Visitor*) { } |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; | 169 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; |
| 170 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; | 170 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; |
| 171 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; | 171 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; |
| 172 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; | 172 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; |
| 173 | 173 |
| 174 } // namespace WebCore | 174 } // namespace WebCore |
| 175 | 175 |
| 176 #endif // SyncCallbackHelper_h | 176 #endif // SyncCallbackHelper_h |
| OLD | NEW |