OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Creates a new isolated file system for the given filesystemId. | 59 // Creates a new isolated file system for the given filesystemId. |
60 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); | 60 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); |
61 | 61 |
62 DirectoryEntry* root() const; | 62 DirectoryEntry* root() const; |
63 | 63 |
64 // DOMFileSystemBase overrides. | 64 // DOMFileSystemBase overrides. |
65 void addPendingCallbacks() override; | 65 void addPendingCallbacks() override; |
66 void removePendingCallbacks() override; | 66 void removePendingCallbacks() override; |
67 void reportError(ErrorCallback*, FileError*) override; | 67 void reportError(ErrorCallback*, FileError*) override; |
68 | 68 |
| 69 static void reportError(ExecutionContext*, ErrorCallback*, FileError*); |
| 70 |
69 // ActiveScriptWrappable overrides. | 71 // ActiveScriptWrappable overrides. |
70 bool hasPendingActivity() const final; | 72 bool hasPendingActivity() const final; |
71 | 73 |
72 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); | 74 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); |
73 void createFile(const FileEntry*, BlobCallback*, ErrorCallback*); | 75 void createFile(const FileEntry*, BlobCallback*, ErrorCallback*); |
74 | 76 |
75 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). | 77 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). |
76 // FIXME: move this to a more generic place. | 78 static void scheduleCallback(ExecutionContext* executionContext, std::unique
_ptr<ExecutionContextTask> task) |
77 template <typename CB, typename CBArg> | |
78 static void scheduleCallback(ExecutionContext*, CB*, CBArg*); | |
79 | |
80 template <typename CB, typename CBArg> | |
81 static void scheduleCallback(ExecutionContext*, CB*, const HeapVector<CBArg>
&); | |
82 | |
83 template <typename CB, typename CBArg> | |
84 static void scheduleCallback(ExecutionContext*, CB*, const CBArg&); | |
85 | |
86 template <typename CB, typename CBArg> | |
87 static void scheduleCallback(ExecutionContext*, CB*, const Member<CBArg>&); | |
88 | |
89 template <typename CB> | |
90 static void scheduleCallback(ExecutionContext*, CB*); | |
91 | |
92 template <typename CB, typename CBArg> | |
93 void scheduleCallback(CB* callback, CBArg* callbackArg) | |
94 { | 79 { |
95 scheduleCallback(getExecutionContext(), callback, callbackArg); | 80 DCHECK(executionContext->isContextThread()); |
96 } | 81 executionContext->postTask(BLINK_FROM_HERE, std::move(task), taskNameFor
Instrumentation()); |
97 | |
98 template <typename CB, typename CBArg> | |
99 void scheduleCallback(CB* callback, const CBArg& callbackArg) | |
100 { | |
101 scheduleCallback(getExecutionContext(), callback, callbackArg); | |
102 } | 82 } |
103 | 83 |
104 DECLARE_VIRTUAL_TRACE(); | 84 DECLARE_VIRTUAL_TRACE(); |
105 | 85 |
106 private: | 86 private: |
107 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 87 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
108 | 88 |
109 static String taskNameForInstrumentation() | 89 static String taskNameForInstrumentation() |
110 { | 90 { |
111 return "FileSystem"; | 91 return "FileSystem"; |
112 } | 92 } |
113 | 93 |
114 template <typename CB, typename CBArg> | |
115 class DispatchCallbackPtrArgTask final : public ExecutionContextTask { | |
116 public: | |
117 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) | |
118 : m_callback(callback) | |
119 , m_callbackArg(arg) | |
120 { | |
121 } | |
122 | |
123 void performTask(ExecutionContext*) override | |
124 { | |
125 m_callback->handleEvent(m_callbackArg.get()); | |
126 } | |
127 | |
128 private: | |
129 Persistent<CB> m_callback; | |
130 Persistent<CBArg> m_callbackArg; | |
131 }; | |
132 | |
133 template <typename CB, typename CBArg> | |
134 class DispatchCallbackNonPtrArgTask final : public ExecutionContextTask { | |
135 public: | |
136 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) | |
137 : m_callback(callback) | |
138 , m_callbackArg(arg) | |
139 { | |
140 } | |
141 | |
142 void performTask(ExecutionContext*) override | |
143 { | |
144 m_callback->handleEvent(m_callbackArg); | |
145 } | |
146 | |
147 private: | |
148 Persistent<CB> m_callback; | |
149 CBArg m_callbackArg; | |
150 }; | |
151 | |
152 template <typename CB> | |
153 class DispatchCallbackNoArgTask final : public ExecutionContextTask { | |
154 public: | |
155 DispatchCallbackNoArgTask(CB* callback) | |
156 : m_callback(callback) | |
157 { | |
158 } | |
159 | |
160 void performTask(ExecutionContext*) override | |
161 { | |
162 m_callback->handleEvent(); | |
163 } | |
164 | |
165 private: | |
166 Persistent<CB> m_callback; | |
167 }; | |
168 | |
169 int m_numberOfPendingCallbacks; | 94 int m_numberOfPendingCallbacks; |
170 Member<DirectoryEntry> m_rootEntry; | 95 Member<DirectoryEntry> m_rootEntry; |
171 }; | 96 }; |
172 | 97 |
173 template <typename CB, typename CBArg> | |
174 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, CBArg* arg) | |
175 { | |
176 ASSERT(executionContext->isContextThread()); | |
177 if (callback) | |
178 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackPtrArgTask<CB, CBArg>(callback, arg)), taskNameForInstrumentation()); | |
179 } | |
180 | |
181 template <typename CB, typename CBArg> | |
182 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const HeapVector<CBArg>& arg) | |
183 { | |
184 ASSERT(executionContext->isContextThread()); | |
185 if (callback) | |
186 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, PersistentHeapVector<CBArg>>(callback, arg)), taskNameForIn
strumentation()); | |
187 } | |
188 | |
189 template <typename CB, typename CBArg> | |
190 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const CBArg& arg) | |
191 { | |
192 ASSERT(executionContext->isContextThread()); | |
193 if (callback) | |
194 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, CBArg>(callback, arg)), taskNameForInstrumentation()); | |
195 } | |
196 | |
197 template <typename CB, typename CBArg> | |
198 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const Member<CBArg>& arg) | |
199 { | |
200 ASSERT(executionContext->isContextThread()); | |
201 if (callback) | |
202 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, Persistent<CBArg>>(callback, arg)), taskNameForInstrumentat
ion()); | |
203 } | |
204 | |
205 template <typename CB> | |
206 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) | |
207 { | |
208 ASSERT(executionContext->isContextThread()); | |
209 if (callback) | |
210 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNoArgTask<CB>(callback)), taskNameForInstrumentation()); | |
211 } | |
212 | |
213 } // namespace blink | 98 } // namespace blink |
214 | 99 |
215 #endif // DOMFileSystem_h | 100 #endif // DOMFileSystem_h |
OLD | NEW |