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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 ResultReturnType getResult(ExceptionState& exceptionState) | 78 ResultReturnType getResult(ExceptionState& exceptionState) |
79 { | 79 { |
80 if (m_errorCode) | 80 if (m_errorCode) |
81 FileError::throwDOMException(exceptionState, m_errorCode); | 81 FileError::throwDOMException(exceptionState, m_errorCode); |
82 | 82 |
83 return m_result; | 83 return m_result; |
84 } | 84 } |
85 | 85 |
86 PassOwnPtrWillBeRawPtr<SuccessCallback> successCallback() { return SuccessCa
llbackImpl::create(this); } | 86 SuccessCallback* successCallback() { return SuccessCallbackImpl::create(this
); } |
87 PassOwnPtrWillBeRawPtr<ErrorCallback> errorCallback() { return ErrorCallback
Impl::create(this); } | 87 ErrorCallback* errorCallback() { return ErrorCallbackImpl::create(this); } |
88 | 88 |
89 void trace(Visitor* visitor) | 89 void trace(Visitor* visitor) |
90 { | 90 { |
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 PassOwnPtrWillBeRawPtr<SuccessCallbackImpl> create(HelperType* he
lper) | 103 static SuccessCallbackImpl* create(HelperType* helper) |
104 { | 104 { |
105 return adoptPtrWillBeNoop(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 PassOwnPtrWillBeRawPtr<ErrorCallbackImpl> create(HelperType* help
er) | 128 static ErrorCallbackImpl* create(HelperType* helper) |
129 { | 129 { |
130 return adoptPtrWillBeNoop(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) |
(...skipping 30 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 |