| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 void scheduleCallback(CB* callback, const CBArg& callbackArg) | 99 void scheduleCallback(CB* callback, const CBArg& callbackArg) |
| 100 { | 100 { |
| 101 scheduleCallback(getExecutionContext(), callback, callbackArg); | 101 scheduleCallback(getExecutionContext(), callback, callbackArg); |
| 102 } | 102 } |
| 103 | 103 |
| 104 DECLARE_VIRTUAL_TRACE(); | 104 DECLARE_VIRTUAL_TRACE(); |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 107 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
| 108 | 108 |
| 109 class DispatchCallbackTaskBase : public ExecutionContextTask { | 109 static String taskNameForInstrumentation() |
| 110 public: | 110 { |
| 111 String taskNameForInstrumentation() const override | 111 return "FileSystem"; |
| 112 { | 112 } |
| 113 return "FileSystem"; | |
| 114 } | |
| 115 }; | |
| 116 | 113 |
| 117 template <typename CB, typename CBArg> | 114 template <typename CB, typename CBArg> |
| 118 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { | 115 class DispatchCallbackPtrArgTask final : public ExecutionContextTask { |
| 119 public: | 116 public: |
| 120 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) | 117 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) |
| 121 : m_callback(callback) | 118 : m_callback(callback) |
| 122 , m_callbackArg(arg) | 119 , m_callbackArg(arg) |
| 123 { | 120 { |
| 124 } | 121 } |
| 125 | 122 |
| 126 void performTask(ExecutionContext*) override | 123 void performTask(ExecutionContext*) override |
| 127 { | 124 { |
| 128 m_callback->handleEvent(m_callbackArg.get()); | 125 m_callback->handleEvent(m_callbackArg.get()); |
| 129 } | 126 } |
| 130 | 127 |
| 131 private: | 128 private: |
| 132 Persistent<CB> m_callback; | 129 Persistent<CB> m_callback; |
| 133 Persistent<CBArg> m_callbackArg; | 130 Persistent<CBArg> m_callbackArg; |
| 134 }; | 131 }; |
| 135 | 132 |
| 136 template <typename CB, typename CBArg> | 133 template <typename CB, typename CBArg> |
| 137 class DispatchCallbackNonPtrArgTask final : public DispatchCallbackTaskBase
{ | 134 class DispatchCallbackNonPtrArgTask final : public ExecutionContextTask { |
| 138 public: | 135 public: |
| 139 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) | 136 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) |
| 140 : m_callback(callback) | 137 : m_callback(callback) |
| 141 , m_callbackArg(arg) | 138 , m_callbackArg(arg) |
| 142 { | 139 { |
| 143 } | 140 } |
| 144 | 141 |
| 145 void performTask(ExecutionContext*) override | 142 void performTask(ExecutionContext*) override |
| 146 { | 143 { |
| 147 m_callback->handleEvent(m_callbackArg); | 144 m_callback->handleEvent(m_callbackArg); |
| 148 } | 145 } |
| 149 | 146 |
| 150 private: | 147 private: |
| 151 Persistent<CB> m_callback; | 148 Persistent<CB> m_callback; |
| 152 CBArg m_callbackArg; | 149 CBArg m_callbackArg; |
| 153 }; | 150 }; |
| 154 | 151 |
| 155 template <typename CB> | 152 template <typename CB> |
| 156 class DispatchCallbackNoArgTask final : public DispatchCallbackTaskBase { | 153 class DispatchCallbackNoArgTask final : public ExecutionContextTask { |
| 157 public: | 154 public: |
| 158 DispatchCallbackNoArgTask(CB* callback) | 155 DispatchCallbackNoArgTask(CB* callback) |
| 159 : m_callback(callback) | 156 : m_callback(callback) |
| 160 { | 157 { |
| 161 } | 158 } |
| 162 | 159 |
| 163 void performTask(ExecutionContext*) override | 160 void performTask(ExecutionContext*) override |
| 164 { | 161 { |
| 165 m_callback->handleEvent(); | 162 m_callback->handleEvent(); |
| 166 } | 163 } |
| 167 | 164 |
| 168 private: | 165 private: |
| 169 Persistent<CB> m_callback; | 166 Persistent<CB> m_callback; |
| 170 }; | 167 }; |
| 171 | 168 |
| 172 int m_numberOfPendingCallbacks; | 169 int m_numberOfPendingCallbacks; |
| 173 Member<DirectoryEntry> m_rootEntry; | 170 Member<DirectoryEntry> m_rootEntry; |
| 174 }; | 171 }; |
| 175 | 172 |
| 176 template <typename CB, typename CBArg> | 173 template <typename CB, typename CBArg> |
| 177 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, CBArg* arg) | 174 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, CBArg* arg) |
| 178 { | 175 { |
| 179 ASSERT(executionContext->isContextThread()); | 176 ASSERT(executionContext->isContextThread()); |
| 180 if (callback) | 177 if (callback) |
| 181 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackPtrArgTask<CB, CBArg>(callback, arg))); | 178 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackPtrArgTask<CB, CBArg>(callback, arg)), taskNameForInstrumentation()); |
| 182 } | 179 } |
| 183 | 180 |
| 184 template <typename CB, typename CBArg> | 181 template <typename CB, typename CBArg> |
| 185 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const HeapVector<CBArg>& arg) | 182 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const HeapVector<CBArg>& arg) |
| 186 { | 183 { |
| 187 ASSERT(executionContext->isContextThread()); | 184 ASSERT(executionContext->isContextThread()); |
| 188 if (callback) | 185 if (callback) |
| 189 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, PersistentHeapVector<CBArg>>(callback, arg))); | 186 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, PersistentHeapVector<CBArg>>(callback, arg)), taskNameForIn
strumentation()); |
| 190 } | 187 } |
| 191 | 188 |
| 192 template <typename CB, typename CBArg> | 189 template <typename CB, typename CBArg> |
| 193 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const CBArg& arg) | 190 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const CBArg& arg) |
| 194 { | 191 { |
| 195 ASSERT(executionContext->isContextThread()); | 192 ASSERT(executionContext->isContextThread()); |
| 196 if (callback) | 193 if (callback) |
| 197 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, CBArg>(callback, arg))); | 194 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, CBArg>(callback, arg)), taskNameForInstrumentation()); |
| 198 } | 195 } |
| 199 | 196 |
| 200 template <typename CB, typename CBArg> | 197 template <typename CB, typename CBArg> |
| 201 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const Member<CBArg>& arg) | 198 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback, const Member<CBArg>& arg) |
| 202 { | 199 { |
| 203 ASSERT(executionContext->isContextThread()); | 200 ASSERT(executionContext->isContextThread()); |
| 204 if (callback) | 201 if (callback) |
| 205 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, Persistent<CBArg>>(callback, arg))); | 202 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNonPtrArgTask<CB, Persistent<CBArg>>(callback, arg)), taskNameForInstrumentat
ion()); |
| 206 } | 203 } |
| 207 | 204 |
| 208 template <typename CB> | 205 template <typename CB> |
| 209 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) | 206 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) |
| 210 { | 207 { |
| 211 ASSERT(executionContext->isContextThread()); | 208 ASSERT(executionContext->isContextThread()); |
| 212 if (callback) | 209 if (callback) |
| 213 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNoArgTask<CB>(callback))); | 210 executionContext->postTask(BLINK_FROM_HERE, wrapUnique(new DispatchCallb
ackNoArgTask<CB>(callback)), taskNameForInstrumentation()); |
| 214 } | 211 } |
| 215 | 212 |
| 216 } // namespace blink | 213 } // namespace blink |
| 217 | 214 |
| 218 #endif // DOMFileSystem_h | 215 #endif // DOMFileSystem_h |
| OLD | NEW |