| 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 29 matching lines...) Expand all Loading... |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 class DirectoryEntry; | 42 class DirectoryEntry; |
| 43 class File; | 43 class File; |
| 44 class FileCallback; | 44 class FileCallback; |
| 45 class FileEntry; | 45 class FileEntry; |
| 46 class FileWriterCallback; | 46 class FileWriterCallback; |
| 47 | 47 |
| 48 class DOMFileSystem : public DOMFileSystemBase, public ScriptWrappable, public A
ctiveDOMObject { | 48 class DOMFileSystem : public DOMFileSystemBase, public ScriptWrappable, public A
ctiveDOMObject { |
| 49 public: | 49 public: |
| 50 static PassRefPtr<DOMFileSystem> create(ScriptExecutionContext*, const Strin
g& name, FileSystemType, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>); | 50 static PassRefPtr<DOMFileSystem> create(ScriptExecutionContext*, const Strin
g& name, FileSystemType, const KURL& rootURL); |
| 51 | 51 |
| 52 // Creates a new isolated file system for the given filesystemId. | 52 // Creates a new isolated file system for the given filesystemId. |
| 53 static PassRefPtr<DOMFileSystem> createIsolatedFileSystem(ScriptExecutionCon
text*, const String& filesystemId); | 53 static PassRefPtr<DOMFileSystem> createIsolatedFileSystem(ScriptExecutionCon
text*, const String& filesystemId); |
| 54 | 54 |
| 55 PassRefPtr<DirectoryEntry> root(); | 55 PassRefPtr<DirectoryEntry> root(); |
| 56 | 56 |
| 57 // ActiveDOMObject methods. | 57 // DOMFileSystemBase overrides. |
| 58 virtual void stop(); | 58 virtual void addPendingCallbacks() OVERRIDE; |
| 59 virtual bool hasPendingActivity() const; | 59 virtual void removePendingCallbacks() OVERRIDE; |
| 60 virtual void contextDestroyed(); | 60 |
| 61 // ActiveDOMObject overrides. |
| 62 virtual bool hasPendingActivity() const OVERRIDE; |
| 61 | 63 |
| 62 void createWriter(const FileEntry*, PassRefPtr<FileWriterCallback>, PassRefP
tr<ErrorCallback>); | 64 void createWriter(const FileEntry*, PassRefPtr<FileWriterCallback>, PassRefP
tr<ErrorCallback>); |
| 63 void createFile(const FileEntry*, PassRefPtr<FileCallback>, PassRefPtr<Error
Callback>); | 65 void createFile(const FileEntry*, PassRefPtr<FileCallback>, PassRefPtr<Error
Callback>); |
| 64 | 66 |
| 65 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). | 67 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). |
| 66 // FIXME: move this to a more generic place. | 68 // FIXME: move this to a more generic place. |
| 67 template <typename CB, typename CBArg> | 69 template <typename CB, typename CBArg> |
| 68 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRe
fPtr<CBArg>); | 70 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRe
fPtr<CBArg>); |
| 69 | 71 |
| 70 template <typename CB, typename CBArg> | 72 template <typename CB, typename CBArg> |
| 71 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, const
CBArg&); | 73 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, const
CBArg&); |
| 72 | 74 |
| 73 template <typename CB, typename CBArg> | 75 template <typename CB, typename CBArg> |
| 74 void scheduleCallback(PassRefPtr<CB> callback, PassRefPtr<CBArg> callbackArg
) | 76 void scheduleCallback(PassRefPtr<CB> callback, PassRefPtr<CBArg> callbackArg
) |
| 75 { | 77 { |
| 76 scheduleCallback(scriptExecutionContext(), callback, callbackArg); | 78 scheduleCallback(scriptExecutionContext(), callback, callbackArg); |
| 77 } | 79 } |
| 78 | 80 |
| 79 template <typename CB, typename CBArg> | 81 template <typename CB, typename CBArg> |
| 80 void scheduleCallback(PassRefPtr<CB> callback, const CBArg& callbackArg) | 82 void scheduleCallback(PassRefPtr<CB> callback, const CBArg& callbackArg) |
| 81 { | 83 { |
| 82 scheduleCallback(scriptExecutionContext(), callback, callbackArg); | 84 scheduleCallback(scriptExecutionContext(), callback, callbackArg); |
| 83 } | 85 } |
| 84 | 86 |
| 85 private: | 87 private: |
| 86 DOMFileSystem(ScriptExecutionContext*, const String& name, FileSystemType, c
onst KURL& rootURL, PassOwnPtr<AsyncFileSystem>); | 88 DOMFileSystem(ScriptExecutionContext*, const String& name, FileSystemType, c
onst KURL& rootURL); |
| 87 | 89 |
| 88 // A helper template to schedule a callback task. | 90 // A helper template to schedule a callback task. |
| 89 template <typename CB, typename CBArg> | 91 template <typename CB, typename CBArg> |
| 90 class DispatchCallbacRefPtrArgTask : public ScriptExecutionContext::Task { | 92 class DispatchCallbacRefPtrArgTask : public ScriptExecutionContext::Task { |
| 91 public: | 93 public: |
| 92 DispatchCallbacRefPtrArgTask(PassRefPtr<CB> callback, PassRefPtr<CBArg>
arg) | 94 DispatchCallbacRefPtrArgTask(PassRefPtr<CB> callback, PassRefPtr<CBArg>
arg) |
| 93 : m_callback(callback) | 95 : m_callback(callback) |
| 94 , m_callbackArg(arg) | 96 , m_callbackArg(arg) |
| 95 { | 97 { |
| 96 } | 98 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 116 | 118 |
| 117 virtual void performTask(ScriptExecutionContext*) | 119 virtual void performTask(ScriptExecutionContext*) |
| 118 { | 120 { |
| 119 m_callback->handleEvent(m_callbackArg); | 121 m_callback->handleEvent(m_callbackArg); |
| 120 } | 122 } |
| 121 | 123 |
| 122 private: | 124 private: |
| 123 RefPtr<CB> m_callback; | 125 RefPtr<CB> m_callback; |
| 124 CBArg m_callbackArg; | 126 CBArg m_callbackArg; |
| 125 }; | 127 }; |
| 128 |
| 129 int m_pendingCallbacks; |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 template <typename CB, typename CBArg> | 132 template <typename CB, typename CBArg> |
| 129 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont
ext, PassRefPtr<CB> callback, PassRefPtr<CBArg> arg) | 133 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont
ext, PassRefPtr<CB> callback, PassRefPtr<CBArg> arg) |
| 130 { | 134 { |
| 131 ASSERT(scriptExecutionContext->isContextThread()); | 135 ASSERT(scriptExecutionContext->isContextThread()); |
| 132 if (callback) | 136 if (callback) |
| 133 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbacRefPtrArgTa
sk<CB, CBArg>(callback, arg))); | 137 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbacRefPtrArgTa
sk<CB, CBArg>(callback, arg))); |
| 134 } | 138 } |
| 135 | 139 |
| 136 template <typename CB, typename CBArg> | 140 template <typename CB, typename CBArg> |
| 137 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont
ext, PassRefPtr<CB> callback, const CBArg& arg) | 141 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont
ext, PassRefPtr<CB> callback, const CBArg& arg) |
| 138 { | 142 { |
| 139 ASSERT(scriptExecutionContext->isContextThread()); | 143 ASSERT(scriptExecutionContext->isContextThread()); |
| 140 if (callback) | 144 if (callback) |
| 141 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbackNonPtrArgT
ask<CB, CBArg>(callback, arg))); | 145 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbackNonPtrArgT
ask<CB, CBArg>(callback, arg))); |
| 142 } | 146 } |
| 143 | 147 |
| 144 } // namespace | 148 } // namespace |
| 145 | 149 |
| 146 #endif // DOMFileSystem_h | 150 #endif // DOMFileSystem_h |
| OLD | NEW |