| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMFileSystem); | 53 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMFileSystem); |
| 54 public: | 54 public: |
| 55 static DOMFileSystem* create(ExecutionContext*, const String& name, FileSyst
emType, const KURL& rootURL); | 55 static DOMFileSystem* create(ExecutionContext*, const String& name, FileSyst
emType, const KURL& rootURL); |
| 56 | 56 |
| 57 // Creates a new isolated file system for the given filesystemId. | 57 // Creates a new isolated file system for the given filesystemId. |
| 58 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); | 58 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); |
| 59 | 59 |
| 60 DirectoryEntry* root() const; | 60 DirectoryEntry* root() const; |
| 61 | 61 |
| 62 // DOMFileSystemBase overrides. | 62 // DOMFileSystemBase overrides. |
| 63 virtual void addPendingCallbacks() override; | 63 void addPendingCallbacks() override; |
| 64 virtual void removePendingCallbacks() override; | 64 void removePendingCallbacks() override; |
| 65 virtual void reportError(ErrorCallback*, FileError*) override; | 65 void reportError(ErrorCallback*, FileError*) override; |
| 66 | 66 |
| 67 // ActiveDOMObject overrides. | 67 // ActiveDOMObject overrides. |
| 68 virtual bool hasPendingActivity() const override; | 68 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*, CBArg*); | 76 static void scheduleCallback(ExecutionContext*, CB*, CBArg*); |
| 77 | 77 |
| 78 template <typename CB, typename CBArg> | 78 template <typename CB, typename CBArg> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 99 scheduleCallback(executionContext(), callback, callbackArg); | 99 scheduleCallback(executionContext(), callback, callbackArg); |
| 100 } | 100 } |
| 101 | 101 |
| 102 DECLARE_VIRTUAL_TRACE(); | 102 DECLARE_VIRTUAL_TRACE(); |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 105 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
| 106 | 106 |
| 107 class DispatchCallbackTaskBase : public ExecutionContextTask { | 107 class DispatchCallbackTaskBase : public ExecutionContextTask { |
| 108 public: | 108 public: |
| 109 virtual String taskNameForInstrumentation() const override | 109 String taskNameForInstrumentation() const override |
| 110 { | 110 { |
| 111 return "FileSystem"; | 111 return "FileSystem"; |
| 112 } | 112 } |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 template <typename CB, typename CBArg> | 115 template <typename CB, typename CBArg> |
| 116 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { | 116 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { |
| 117 public: | 117 public: |
| 118 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) | 118 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) |
| 119 : m_callback(callback) | 119 : m_callback(callback) |
| 120 , m_callbackArg(arg) | 120 , m_callbackArg(arg) |
| 121 { | 121 { |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void performTask(ExecutionContext*) override | 124 void performTask(ExecutionContext*) override |
| 125 { | 125 { |
| 126 m_callback->handleEvent(m_callbackArg.get()); | 126 m_callback->handleEvent(m_callbackArg.get()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 Persistent<CB> m_callback; | 130 Persistent<CB> m_callback; |
| 131 Persistent<CBArg> m_callbackArg; | 131 Persistent<CBArg> m_callbackArg; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 template <typename CB, typename CBArg> | 134 template <typename CB, typename CBArg> |
| 135 class DispatchCallbackNonPtrArgTask final : public DispatchCallbackTaskBase
{ | 135 class DispatchCallbackNonPtrArgTask final : public DispatchCallbackTaskBase
{ |
| 136 public: | 136 public: |
| 137 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) | 137 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) |
| 138 : m_callback(callback) | 138 : m_callback(callback) |
| 139 , m_callbackArg(arg) | 139 , m_callbackArg(arg) |
| 140 { | 140 { |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual void performTask(ExecutionContext*) override | 143 void performTask(ExecutionContext*) override |
| 144 { | 144 { |
| 145 m_callback->handleEvent(m_callbackArg); | 145 m_callback->handleEvent(m_callbackArg); |
| 146 } | 146 } |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 Persistent<CB> m_callback; | 149 Persistent<CB> m_callback; |
| 150 CBArg m_callbackArg; | 150 CBArg m_callbackArg; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 template <typename CB> | 153 template <typename CB> |
| 154 class DispatchCallbackNoArgTask final : public DispatchCallbackTaskBase { | 154 class DispatchCallbackNoArgTask final : public DispatchCallbackTaskBase { |
| 155 public: | 155 public: |
| 156 DispatchCallbackNoArgTask(CB* callback) | 156 DispatchCallbackNoArgTask(CB* callback) |
| 157 : m_callback(callback) | 157 : m_callback(callback) |
| 158 { | 158 { |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual void performTask(ExecutionContext*) override | 161 void performTask(ExecutionContext*) override |
| 162 { | 162 { |
| 163 m_callback->handleEvent(); | 163 m_callback->handleEvent(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 Persistent<CB> m_callback; | 167 Persistent<CB> m_callback; |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 int m_numberOfPendingCallbacks; | 170 int m_numberOfPendingCallbacks; |
| 171 Member<DirectoryEntry> m_rootEntry; | 171 Member<DirectoryEntry> m_rootEntry; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) | 207 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) |
| 208 { | 208 { |
| 209 ASSERT(executionContext->isContextThread()); | 209 ASSERT(executionContext->isContextThread()); |
| 210 if (callback) | 210 if (callback) |
| 211 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackNoArg
Task<CB>(callback))); | 211 executionContext->postTask(FROM_HERE, adoptPtr(new DispatchCallbackNoArg
Task<CB>(callback))); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace blink | 214 } // namespace blink |
| 215 | 215 |
| 216 #endif // DOMFileSystem_h | 216 #endif // DOMFileSystem_h |
| OLD | NEW |