Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: Source/modules/filesystem/SyncCallbackHelper.h

Issue 17761003: Remove FileException (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile warning Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef SyncCallbackHelper_h 31 #ifndef SyncCallbackHelper_h
32 #define SyncCallbackHelper_h 32 #define SyncCallbackHelper_h
33 33
34 #include "core/dom/ExceptionCode.h"
34 #include "core/fileapi/FileError.h" 35 #include "core/fileapi/FileError.h"
35 #include "core/fileapi/FileException.h"
36 #include "core/html/VoidCallback.h" 36 #include "core/html/VoidCallback.h"
37 #include "modules/filesystem/DirectoryEntry.h" 37 #include "modules/filesystem/DirectoryEntry.h"
38 #include "modules/filesystem/EntriesCallback.h" 38 #include "modules/filesystem/EntriesCallback.h"
39 #include "modules/filesystem/EntryArraySync.h" 39 #include "modules/filesystem/EntryArraySync.h"
40 #include "modules/filesystem/EntryCallback.h" 40 #include "modules/filesystem/EntryCallback.h"
41 #include "modules/filesystem/ErrorCallback.h" 41 #include "modules/filesystem/ErrorCallback.h"
42 #include "modules/filesystem/FileEntry.h" 42 #include "modules/filesystem/FileEntry.h"
43 #include "modules/filesystem/FileSystemCallback.h" 43 #include "modules/filesystem/FileSystemCallback.h"
44 #include "modules/filesystem/MetadataCallback.h" 44 #include "modules/filesystem/MetadataCallback.h"
45 #include "wtf/PassRefPtr.h" 45 #include "wtf/PassRefPtr.h"
(...skipping 22 matching lines...) Expand all
68 , m_exceptionCode(0) 68 , m_exceptionCode(0)
69 , m_completed(false) 69 , m_completed(false)
70 { 70 {
71 } 71 }
72 72
73 PassRefPtr<ResultType> getResult(ExceptionCode& ec) 73 PassRefPtr<ResultType> getResult(ExceptionCode& ec)
74 { 74 {
75 if (m_observer) { 75 if (m_observer) {
76 while (!m_completed) { 76 while (!m_completed) {
77 if (!m_observer->waitForOperationToComplete()) { 77 if (!m_observer->waitForOperationToComplete()) {
78 m_exceptionCode = FileException::ABORT_ERR; 78 m_exceptionCode = FSAbortError;
79 break; 79 break;
80 } 80 }
81 } 81 }
82 } 82 }
83 ec = m_exceptionCode; 83 ec = m_exceptionCode;
84 return m_result.release(); 84 return m_result.release();
85 } 85 }
86 86
87 PassRefPtr<SuccessCallback> successCallback() { return m_successCallback; } 87 PassRefPtr<SuccessCallback> successCallback() { return m_successCallback; }
88 PassRefPtr<ErrorCallback> errorCallback() { return m_errorCallback; } 88 PassRefPtr<ErrorCallback> errorCallback() { return m_errorCallback; }
89 89
90 private: 90 private:
91 class SuccessCallbackImpl : public SuccessCallback { 91 class SuccessCallbackImpl : public SuccessCallback {
92 public: 92 public:
93 static PassRefPtr<SuccessCallbackImpl> create(HelperType* helper) 93 static PassRefPtr<SuccessCallbackImpl> create(HelperType* helper)
94 { 94 {
95 return adoptRef(new SuccessCallbackImpl(helper)); 95 return adoptRef(new SuccessCallbackImpl(helper));
96 } 96 }
97 97
98 virtual bool handleEvent() 98 virtual bool handleEvent()
99 { 99 {
100 m_helper->setError(0); 100 m_helper->setError(FileError::OK);
101 return true; 101 return true;
102 } 102 }
103 103
104 virtual bool handleEvent(CallbackArg* arg) 104 virtual bool handleEvent(CallbackArg* arg)
105 { 105 {
106 m_helper->setResult(ResultType::create(arg)); 106 m_helper->setResult(ResultType::create(arg));
107 return true; 107 return true;
108 } 108 }
109 109
110 private: 110 private:
(...skipping 22 matching lines...) Expand all
133 explicit ErrorCallbackImpl(HelperType* helper) 133 explicit ErrorCallbackImpl(HelperType* helper)
134 : m_helper(helper) 134 : m_helper(helper)
135 { 135 {
136 } 136 }
137 HelperType* m_helper; 137 HelperType* m_helper;
138 }; 138 };
139 139
140 friend class SuccessCallbackImpl; 140 friend class SuccessCallbackImpl;
141 friend class ErrorCallbackImpl; 141 friend class ErrorCallbackImpl;
142 142
143 void setError(int code) 143 void setError(FileError::ErrorCode code)
144 { 144 {
145 m_exceptionCode = FileException::ErrorCodeToExceptionCode(code); 145 m_exceptionCode = FileError::ErrorCodeToExceptionCode(code);
146 m_completed = true; 146 m_completed = true;
147 } 147 }
148 148
149 void setResult(PassRefPtr<ResultType> result) 149 void setResult(PassRefPtr<ResultType> result)
150 { 150 {
151 m_result = result; 151 m_result = result;
152 m_completed = true; 152 m_completed = true;
153 } 153 }
154 154
155 ObserverType* m_observer; 155 ObserverType* m_observer;
(...skipping 20 matching lines...) Expand all
176 176
177 typedef SyncCallbackHelper<EntryCallback, AsyncFileSystem, Entry, EntrySync> Ent rySyncCallbackHelper; 177 typedef SyncCallbackHelper<EntryCallback, AsyncFileSystem, Entry, EntrySync> Ent rySyncCallbackHelper;
178 typedef SyncCallbackHelper<EntriesCallback, AsyncFileSystem, EntryArray, EntryAr raySync> EntriesSyncCallbackHelper; 178 typedef SyncCallbackHelper<EntriesCallback, AsyncFileSystem, EntryArray, EntryAr raySync> EntriesSyncCallbackHelper;
179 typedef SyncCallbackHelper<MetadataCallback, AsyncFileSystem, Metadata, Metadata > MetadataSyncCallbackHelper; 179 typedef SyncCallbackHelper<MetadataCallback, AsyncFileSystem, Metadata, Metadata > MetadataSyncCallbackHelper;
180 typedef SyncCallbackHelper<VoidCallback, AsyncFileSystem, EmptyType, EmptyType> VoidSyncCallbackHelper; 180 typedef SyncCallbackHelper<VoidCallback, AsyncFileSystem, EmptyType, EmptyType> VoidSyncCallbackHelper;
181 typedef SyncCallbackHelper<FileSystemCallback, EmptyObserverType, DOMFileSystem, DOMFileSystemSync> FileSystemSyncCallbackHelper; 181 typedef SyncCallbackHelper<FileSystemCallback, EmptyObserverType, DOMFileSystem, DOMFileSystemSync> FileSystemSyncCallbackHelper;
182 182
183 } // namespace WebCore 183 } // namespace WebCore
184 184
185 #endif // SyncCallbackHelper_h 185 #endif // SyncCallbackHelper_h
OLDNEW
« no previous file with comments | « Source/modules/filesystem/FileWriterSync.cpp ('k') | Source/modules/filesystem/WorkerGlobalScopeFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698