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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // ActiveDOMObject overrides. | 67 // ActiveDOMObject overrides. |
68 virtual bool hasPendingActivity() const override; | 68 virtual bool hasPendingActivity() const override; |
69 | 69 |
70 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); | 70 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); |
71 void createFile(const FileEntry*, FileCallback*, ErrorCallback*); | 71 void createFile(const FileEntry*, FileCallback*, ErrorCallback*); |
72 | 72 |
73 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). | 73 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). |
74 // FIXME: move this to a more generic place. | 74 // FIXME: move this to a more generic place. |
75 template <typename CB, typename CBArg> | 75 template <typename CB, typename CBArg> |
76 static void scheduleCallback(ExecutionContext*, CB*, PassRefPtrWillBeRawPtr<
CBArg>); | |
77 | |
78 template <typename CB, typename CBArg> | |
79 static void scheduleCallback(ExecutionContext*, CB*, CBArg*); | 76 static void scheduleCallback(ExecutionContext*, CB*, CBArg*); |
80 | 77 |
81 template <typename CB, typename CBArg> | 78 template <typename CB, typename CBArg> |
82 static void scheduleCallback(ExecutionContext*, CB*, const HeapVector<CBArg>
&); | 79 static void scheduleCallback(ExecutionContext*, CB*, const HeapVector<CBArg>
&); |
83 | 80 |
84 template <typename CB, typename CBArg> | 81 template <typename CB, typename CBArg> |
85 static void scheduleCallback(ExecutionContext*, CB*, const CBArg&); | 82 static void scheduleCallback(ExecutionContext*, CB*, const CBArg&); |
86 | 83 |
87 template <typename CB, typename CBArg> | 84 template <typename CB, typename CBArg> |
88 static void scheduleCallback(ExecutionContext*, CB*, const Member<CBArg>&); | 85 static void scheduleCallback(ExecutionContext*, CB*, const Member<CBArg>&); |
89 | 86 |
90 template <typename CB> | 87 template <typename CB> |
91 static void scheduleCallback(ExecutionContext*, CB*); | 88 static void scheduleCallback(ExecutionContext*, CB*); |
92 | 89 |
93 template <typename CB, typename CBArg> | 90 template <typename CB, typename CBArg> |
94 void scheduleCallback(CB* callback, PassRefPtrWillBeRawPtr<CBArg> callbackAr
g) | |
95 { | |
96 scheduleCallback(executionContext(), callback, callbackArg); | |
97 } | |
98 | |
99 template <typename CB, typename CBArg> | |
100 void scheduleCallback(CB* callback, CBArg* callbackArg) | 91 void scheduleCallback(CB* callback, CBArg* callbackArg) |
101 { | 92 { |
102 scheduleCallback(executionContext(), callback, callbackArg); | 93 scheduleCallback(executionContext(), callback, callbackArg); |
103 } | 94 } |
104 | 95 |
105 template <typename CB, typename CBArg> | 96 template <typename CB, typename CBArg> |
106 void scheduleCallback(CB* callback, const CBArg& callbackArg) | 97 void scheduleCallback(CB* callback, const CBArg& callbackArg) |
107 { | 98 { |
108 scheduleCallback(executionContext(), callback, callbackArg); | 99 scheduleCallback(executionContext(), callback, callbackArg); |
109 } | 100 } |
110 | 101 |
111 DECLARE_VIRTUAL_TRACE(); | 102 DECLARE_VIRTUAL_TRACE(); |
112 | 103 |
113 private: | 104 private: |
114 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 105 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
115 | 106 |
116 class DispatchCallbackTaskBase : public ExecutionContextTask { | 107 class DispatchCallbackTaskBase : public ExecutionContextTask { |
117 public: | 108 public: |
118 virtual String taskNameForInstrumentation() const override | 109 virtual String taskNameForInstrumentation() const override |
119 { | 110 { |
120 return "FileSystem"; | 111 return "FileSystem"; |
121 } | 112 } |
122 }; | 113 }; |
123 | 114 |
124 // A helper template to schedule a callback task. | |
125 template <typename CB, typename CBArg> | |
126 class DispatchCallbackRefPtrArgTask final : public DispatchCallbackTaskBase
{ | |
127 public: | |
128 DispatchCallbackRefPtrArgTask(CB* callback, PassRefPtrWillBeRawPtr<CBArg
> arg) | |
129 : m_callback(callback) | |
130 , m_callbackArg(arg) | |
131 { | |
132 } | |
133 | |
134 virtual void performTask(ExecutionContext*) override | |
135 { | |
136 m_callback->handleEvent(m_callbackArg.get()); | |
137 } | |
138 | |
139 private: | |
140 Persistent<CB> m_callback; | |
141 RefPtrWillBePersistent<CBArg> m_callbackArg; | |
142 }; | |
143 | |
144 template <typename CB, typename CBArg> | 115 template <typename CB, typename CBArg> |
145 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { | 116 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { |
146 public: | 117 public: |
147 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) | 118 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) |
148 : m_callback(callback) | 119 : m_callback(callback) |
149 , m_callbackArg(arg) | 120 , m_callbackArg(arg) |
150 { | 121 { |
151 } | 122 } |
152 | 123 |
153 virtual void performTask(ExecutionContext*) override | 124 virtual void performTask(ExecutionContext*) override |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 165 |
195 private: | 166 private: |
196 Persistent<CB> m_callback; | 167 Persistent<CB> m_callback; |
197 }; | 168 }; |
198 | 169 |
199 int m_numberOfPendingCallbacks; | 170 int m_numberOfPendingCallbacks; |
200 Member<DirectoryEntry> m_rootEntry; | 171 Member<DirectoryEntry> m_rootEntry; |
201 }; | 172 }; |
202 | 173 |
203 template <typename CB, typename CBArg> | 174 template <typename CB, typename CBArg> |
204 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, PassRefPtrWillBeRawPtr<CBArg> arg) | |
205 { | |
206 ASSERT(executionContext->isContextThread()); | |
207 if (callback) | |
208 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackRefPt
rArgTask<CB, CBArg>(callback, arg))); | |
209 } | |
210 | |
211 template <typename CB, typename CBArg> | |
212 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, CBArg* arg) | 175 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, CBArg* arg) |
213 { | 176 { |
214 ASSERT(executionContext->isContextThread()); | 177 ASSERT(executionContext->isContextThread()); |
215 if (callback) | 178 if (callback) |
216 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackPtrAr
gTask<CB, CBArg>(callback, arg))); | 179 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackPtrAr
gTask<CB, CBArg>(callback, arg))); |
217 } | 180 } |
218 | 181 |
219 template <typename CB, typename CBArg> | 182 template <typename CB, typename CBArg> |
220 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const HeapVector<CBArg>& arg) | 183 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const HeapVector<CBArg>& arg) |
221 { | 184 { |
(...skipping 22 matching lines...) Expand all Loading... |
244 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) | 207 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) |
245 { | 208 { |
246 ASSERT(executionContext->isContextThread()); | 209 ASSERT(executionContext->isContextThread()); |
247 if (callback) | 210 if (callback) |
248 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackNoArg
Task<CB>(callback))); | 211 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackNoArg
Task<CB>(callback))); |
249 } | 212 } |
250 | 213 |
251 } // namespace blink | 214 } // namespace blink |
252 | 215 |
253 #endif // DOMFileSystem_h | 216 #endif // DOMFileSystem_h |
OLD | NEW |