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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 typedef Member<ResultType> StorageType; | 56 typedef Member<ResultType> StorageType; |
57 | 57 |
58 static ReturnType createFromCallbackArg(CallbackArg argument) | 58 static ReturnType createFromCallbackArg(CallbackArg argument) |
59 { | 59 { |
60 return ResultType::create(argument); | 60 return ResultType::create(argument); |
61 } | 61 } |
62 }; | 62 }; |
63 | 63 |
64 // A helper template for FileSystemSync implementation. | 64 // A helper template for FileSystemSync implementation. |
65 template <typename SuccessCallback, typename CallbackArg, typename ResultType> | 65 template <typename SuccessCallback, typename CallbackArg, typename ResultType> |
66 class SyncCallbackHelper FINAL : public GarbageCollected<SyncCallbackHelper<Succ
essCallback, CallbackArg, ResultType> > { | 66 class SyncCallbackHelper final : public GarbageCollected<SyncCallbackHelper<Succ
essCallback, CallbackArg, ResultType> > { |
67 public: | 67 public: |
68 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT
ype; | 68 typedef SyncCallbackHelper<SuccessCallback, CallbackArg, ResultType> HelperT
ype; |
69 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; | 69 typedef HelperResultType<ResultType, CallbackArg> ResultTypeTrait; |
70 typedef typename ResultTypeTrait::StorageType ResultStorageType; | 70 typedef typename ResultTypeTrait::StorageType ResultStorageType; |
71 typedef typename ResultTypeTrait::ReturnType ResultReturnType; | 71 typedef typename ResultTypeTrait::ReturnType ResultReturnType; |
72 | 72 |
73 static HelperType* create() | 73 static HelperType* create() |
74 { | 74 { |
75 return new SyncCallbackHelper(); | 75 return new SyncCallbackHelper(); |
76 } | 76 } |
(...skipping 14 matching lines...) Expand all Loading... |
91 visitor->trace(m_result); | 91 visitor->trace(m_result); |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 SyncCallbackHelper() | 95 SyncCallbackHelper() |
96 : m_errorCode(FileError::OK) | 96 : m_errorCode(FileError::OK) |
97 , m_completed(false) | 97 , m_completed(false) |
98 { | 98 { |
99 } | 99 } |
100 | 100 |
101 class SuccessCallbackImpl FINAL : public SuccessCallback { | 101 class SuccessCallbackImpl final : public SuccessCallback { |
102 public: | 102 public: |
103 static SuccessCallbackImpl* create(HelperType* helper) | 103 static SuccessCallbackImpl* create(HelperType* helper) |
104 { | 104 { |
105 return new SuccessCallbackImpl(helper); | 105 return new SuccessCallbackImpl(helper); |
106 } | 106 } |
107 | 107 |
108 virtual void handleEvent() | 108 virtual void handleEvent() |
109 { | 109 { |
110 m_helper->setError(FileError::OK); | 110 m_helper->setError(FileError::OK); |
111 } | 111 } |
112 | 112 |
113 virtual void handleEvent(CallbackArg arg) | 113 virtual void handleEvent(CallbackArg arg) |
114 { | 114 { |
115 m_helper->setResult(arg); | 115 m_helper->setResult(arg); |
116 } | 116 } |
117 | 117 |
118 private: | 118 private: |
119 explicit SuccessCallbackImpl(HelperType* helper) | 119 explicit SuccessCallbackImpl(HelperType* helper) |
120 : m_helper(helper) | 120 : m_helper(helper) |
121 { | 121 { |
122 } | 122 } |
123 Persistent<HelperType> m_helper; | 123 Persistent<HelperType> m_helper; |
124 }; | 124 }; |
125 | 125 |
126 class ErrorCallbackImpl FINAL : public ErrorCallback { | 126 class ErrorCallbackImpl final : public ErrorCallback { |
127 public: | 127 public: |
128 static ErrorCallbackImpl* create(HelperType* helper) | 128 static ErrorCallbackImpl* create(HelperType* helper) |
129 { | 129 { |
130 return new ErrorCallbackImpl(helper); | 130 return new ErrorCallbackImpl(helper); |
131 } | 131 } |
132 | 132 |
133 virtual void handleEvent(FileError* error) OVERRIDE | 133 virtual void handleEvent(FileError* error) override |
134 { | 134 { |
135 ASSERT(error); | 135 ASSERT(error); |
136 m_helper->setError(error->code()); | 136 m_helper->setError(error->code()); |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 explicit ErrorCallbackImpl(HelperType* helper) | 140 explicit ErrorCallbackImpl(HelperType* helper) |
141 : m_helper(helper) | 141 : m_helper(helper) |
142 { | 142 { |
143 } | 143 } |
(...skipping 27 matching lines...) Expand all Loading... |
171 }; | 171 }; |
172 | 172 |
173 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; | 173 typedef SyncCallbackHelper<EntryCallback, Entry*, EntrySync> EntrySyncCallbackHe
lper; |
174 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; | 174 typedef SyncCallbackHelper<MetadataCallback, Metadata*, Metadata> MetadataSyncCa
llbackHelper; |
175 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; | 175 typedef SyncCallbackHelper<VoidCallback, EmptyType*, EmptyType> VoidSyncCallback
Helper; |
176 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; | 176 typedef SyncCallbackHelper<FileSystemCallback, DOMFileSystem*, DOMFileSystemSync
> FileSystemSyncCallbackHelper; |
177 | 177 |
178 } // namespace blink | 178 } // namespace blink |
179 | 179 |
180 #endif // SyncCallbackHelper_h | 180 #endif // SyncCallbackHelper_h |
OLD | NEW |