Chromium Code Reviews| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 | 98 |
| 99 template <typename CB, typename CBArg> | 99 template <typename CB, typename CBArg> |
| 100 void scheduleCallback(PassOwnPtr<CB> callback, const CBArg& callbackArg) | 100 void scheduleCallback(PassOwnPtr<CB> callback, const CBArg& callbackArg) |
| 101 { | 101 { |
| 102 scheduleCallback(executionContext(), callback, callbackArg); | 102 scheduleCallback(executionContext(), callback, callbackArg); |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K URL& rootURL); | 106 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K URL& rootURL); |
| 107 | 107 |
| 108 class DispatchCallbackTaskBase : public ExecutionContextTask { | |
| 109 public: | |
| 110 DispatchCallbackTaskBase() | |
| 111 : m_taskName("FileSystem") | |
| 112 { | |
| 113 } | |
| 114 | |
| 115 virtual const String& taskNameForInstrumentation() const OVERRIDE | |
|
yurys
2014/07/14 14:55:54
Why do we return constr String& rather than String
| |
| 116 { | |
| 117 return m_taskName; | |
| 118 } | |
| 119 | |
| 120 private: | |
| 121 const String m_taskName; | |
| 122 }; | |
| 123 | |
| 108 // A helper template to schedule a callback task. | 124 // A helper template to schedule a callback task. |
| 109 template <typename CB, typename CBArg> | 125 template <typename CB, typename CBArg> |
| 110 class DispatchCallbackRefPtrArgTask FINAL : public ExecutionContextTask { | 126 class DispatchCallbackRefPtrArgTask FINAL : public DispatchCallbackTaskBase { |
| 111 public: | 127 public: |
| 112 DispatchCallbackRefPtrArgTask(PassOwnPtr<CB> callback, PassRefPtrWillBeR awPtr<CBArg> arg) | 128 DispatchCallbackRefPtrArgTask(PassOwnPtr<CB> callback, PassRefPtrWillBeR awPtr<CBArg> arg) |
| 113 : m_callback(callback) | 129 : m_callback(callback) |
| 114 , m_callbackArg(arg) | 130 , m_callbackArg(arg) |
| 115 { | 131 { |
| 116 } | 132 } |
| 117 | 133 |
| 118 virtual void performTask(ExecutionContext*) OVERRIDE | 134 virtual void performTask(ExecutionContext*) OVERRIDE |
| 119 { | 135 { |
| 120 m_callback->handleEvent(m_callbackArg.get()); | 136 m_callback->handleEvent(m_callbackArg.get()); |
| 121 } | 137 } |
| 122 | 138 |
| 123 private: | 139 private: |
| 124 OwnPtr<CB> m_callback; | 140 OwnPtr<CB> m_callback; |
| 125 RefPtrWillBePersistent<CBArg> m_callbackArg; | 141 RefPtrWillBePersistent<CBArg> m_callbackArg; |
| 126 }; | 142 }; |
| 127 | 143 |
| 128 template <typename CB, typename CBArg> | 144 template <typename CB, typename CBArg> |
| 129 class DispatchCallbackPtrArgTask FINAL : public ExecutionContextTask { | 145 class DispatchCallbackPtrArgTask FINAL : public DispatchCallbackTaskBase { |
| 130 public: | 146 public: |
| 131 DispatchCallbackPtrArgTask(PassOwnPtr<CB> callback, CBArg* arg) | 147 DispatchCallbackPtrArgTask(PassOwnPtr<CB> callback, CBArg* arg) |
| 132 : m_callback(callback) | 148 : m_callback(callback) |
| 133 , m_callbackArg(arg) | 149 , m_callbackArg(arg) |
| 134 { | 150 { |
| 135 } | 151 } |
| 136 | 152 |
| 137 virtual void performTask(ExecutionContext*) OVERRIDE | 153 virtual void performTask(ExecutionContext*) OVERRIDE |
| 138 { | 154 { |
| 139 m_callback->handleEvent(m_callbackArg.get()); | 155 m_callback->handleEvent(m_callbackArg.get()); |
| 140 } | 156 } |
| 141 | 157 |
| 142 private: | 158 private: |
| 143 OwnPtr<CB> m_callback; | 159 OwnPtr<CB> m_callback; |
| 144 Persistent<CBArg> m_callbackArg; | 160 Persistent<CBArg> m_callbackArg; |
| 145 }; | 161 }; |
| 146 | 162 |
| 147 template <typename CB, typename CBArg> | 163 template <typename CB, typename CBArg> |
| 148 class DispatchCallbackNonPtrArgTask FINAL : public ExecutionContextTask { | 164 class DispatchCallbackNonPtrArgTask FINAL : public DispatchCallbackTaskBase { |
| 149 public: | 165 public: |
| 150 DispatchCallbackNonPtrArgTask(PassOwnPtr<CB> callback, const CBArg& arg) | 166 DispatchCallbackNonPtrArgTask(PassOwnPtr<CB> callback, const CBArg& arg) |
| 151 : m_callback(callback) | 167 : m_callback(callback) |
| 152 , m_callbackArg(arg) | 168 , m_callbackArg(arg) |
| 153 { | 169 { |
| 154 } | 170 } |
| 155 | 171 |
| 156 virtual void performTask(ExecutionContext*) OVERRIDE | 172 virtual void performTask(ExecutionContext*) OVERRIDE |
| 157 { | 173 { |
| 158 m_callback->handleEvent(m_callbackArg); | 174 m_callback->handleEvent(m_callbackArg); |
| 159 } | 175 } |
| 160 | 176 |
| 161 private: | 177 private: |
| 162 OwnPtr<CB> m_callback; | 178 OwnPtr<CB> m_callback; |
| 163 CBArg m_callbackArg; | 179 CBArg m_callbackArg; |
| 164 }; | 180 }; |
| 165 | 181 |
| 166 template <typename CB> | 182 template <typename CB> |
| 167 class DispatchCallbackNoArgTask FINAL : public ExecutionContextTask { | 183 class DispatchCallbackNoArgTask FINAL : public DispatchCallbackTaskBase { |
| 168 public: | 184 public: |
| 169 DispatchCallbackNoArgTask(PassOwnPtr<CB> callback) | 185 DispatchCallbackNoArgTask(PassOwnPtr<CB> callback) |
| 170 : m_callback(callback) | 186 : m_callback(callback) |
| 171 { | 187 { |
| 172 } | 188 } |
| 173 | 189 |
| 174 virtual void performTask(ExecutionContext*) OVERRIDE | 190 virtual void performTask(ExecutionContext*) OVERRIDE |
| 175 { | 191 { |
| 176 m_callback->handleEvent(); | 192 m_callback->handleEvent(); |
| 177 } | 193 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn Ptr<CB> callback) | 235 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn Ptr<CB> callback) |
| 220 { | 236 { |
| 221 ASSERT(executionContext->isContextThread()); | 237 ASSERT(executionContext->isContextThread()); |
| 222 if (callback) | 238 if (callback) |
| 223 executionContext->postTask(adoptPtr(new DispatchCallbackNoArgTask<CB>(ca llback))); | 239 executionContext->postTask(adoptPtr(new DispatchCallbackNoArgTask<CB>(ca llback))); |
| 224 } | 240 } |
| 225 | 241 |
| 226 } // namespace | 242 } // namespace |
| 227 | 243 |
| 228 #endif // DOMFileSystem_h | 244 #endif // DOMFileSystem_h |
| OLD | NEW |