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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DOMFileSystem_h | 31 #ifndef DOMFileSystem_h |
32 #define DOMFileSystem_h | 32 #define DOMFileSystem_h |
33 | 33 |
34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptWrappable.h" |
35 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/dom/ExecutionContextTask.h" | 37 #include "core/dom/ExecutionContextTask.h" |
| 38 #include "heap/Handle.h" |
38 #include "modules/filesystem/DOMFileSystemBase.h" | 39 #include "modules/filesystem/DOMFileSystemBase.h" |
39 #include "modules/filesystem/EntriesCallback.h" | 40 #include "modules/filesystem/EntriesCallback.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 class DirectoryEntry; | 44 class DirectoryEntry; |
44 class File; | 45 class File; |
45 class FileCallback; | 46 class FileCallback; |
46 class FileEntry; | 47 class FileEntry; |
47 class FileWriterCallback; | 48 class FileWriterCallback; |
48 | 49 |
49 class DOMFileSystem FINAL : public DOMFileSystemBase, public ScriptWrappable, pu
blic ActiveDOMObject { | 50 class DOMFileSystem FINAL : public DOMFileSystemBase, public ScriptWrappable, pu
blic ActiveDOMObject { |
50 public: | 51 public: |
51 static PassRefPtr<DOMFileSystem> create(ExecutionContext*, const String& nam
e, FileSystemType, const KURL& rootURL); | 52 static PassRefPtr<DOMFileSystem> create(ExecutionContext*, const String& nam
e, FileSystemType, const KURL& rootURL); |
52 | 53 |
53 // Creates a new isolated file system for the given filesystemId. | 54 // Creates a new isolated file system for the given filesystemId. |
54 static PassRefPtr<DOMFileSystem> createIsolatedFileSystem(ExecutionContext*,
const String& filesystemId); | 55 static PassRefPtr<DOMFileSystem> createIsolatedFileSystem(ExecutionContext*,
const String& filesystemId); |
55 | 56 |
56 PassRefPtr<DirectoryEntry> root(); | 57 PassRefPtr<DirectoryEntry> root(); |
57 | 58 |
58 // DOMFileSystemBase overrides. | 59 // DOMFileSystemBase overrides. |
59 virtual void addPendingCallbacks() OVERRIDE; | 60 virtual void addPendingCallbacks() OVERRIDE; |
60 virtual void removePendingCallbacks() OVERRIDE; | 61 virtual void removePendingCallbacks() OVERRIDE; |
61 virtual void reportError(PassOwnPtr<ErrorCallback>, PassRefPtr<FileError>) O
VERRIDE; | 62 virtual void reportError(PassOwnPtr<ErrorCallback>, PassRefPtrWillBeRawPtr<F
ileError>) OVERRIDE; |
62 | 63 |
63 void createWriter(const FileEntry*, PassOwnPtr<FileWriterCallback>, PassOwnP
tr<ErrorCallback>); | 64 void createWriter(const FileEntry*, PassOwnPtr<FileWriterCallback>, PassOwnP
tr<ErrorCallback>); |
64 void createFile(const FileEntry*, PassOwnPtr<FileCallback>, PassOwnPtr<Error
Callback>); | 65 void createFile(const FileEntry*, PassOwnPtr<FileCallback>, PassOwnPtr<Error
Callback>); |
65 | 66 |
66 // 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). |
67 // FIXME: move this to a more generic place. | 68 // FIXME: move this to a more generic place. |
68 template <typename CB, typename CBArg> | 69 template <typename CB, typename CBArg> |
69 static void scheduleCallback(ExecutionContext*, PassOwnPtr<CB>, PassRefPtr<C
BArg>); | 70 static void scheduleCallback(ExecutionContext*, PassOwnPtr<CB>, PassRefPtrWi
llBeRawPtr<CBArg>); |
70 | 71 |
71 template <typename CB, typename CBArg> | 72 template <typename CB, typename CBArg> |
72 static void scheduleCallback(ExecutionContext*, PassOwnPtr<CB>, const CBArg&
); | 73 static void scheduleCallback(ExecutionContext*, PassOwnPtr<CB>, const CBArg&
); |
73 | 74 |
74 template <typename CB, typename CBArg> | 75 template <typename CB, typename CBArg> |
75 void scheduleCallback(PassOwnPtr<CB> callback, PassRefPtr<CBArg> callbackArg
) | 76 void scheduleCallback(PassOwnPtr<CB> callback, PassRefPtrWillBeRawPtr<CBArg>
callbackArg) |
76 { | 77 { |
77 scheduleCallback(executionContext(), callback, callbackArg); | 78 scheduleCallback(executionContext(), callback, callbackArg); |
78 } | 79 } |
79 | 80 |
80 template <typename CB, typename CBArg> | 81 template <typename CB, typename CBArg> |
81 void scheduleCallback(PassOwnPtr<CB> callback, const CBArg& callbackArg) | 82 void scheduleCallback(PassOwnPtr<CB> callback, const CBArg& callbackArg) |
82 { | 83 { |
83 scheduleCallback(executionContext(), callback, callbackArg); | 84 scheduleCallback(executionContext(), callback, callbackArg); |
84 } | 85 } |
85 | 86 |
86 private: | 87 private: |
87 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 88 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
88 | 89 |
89 // A helper template to schedule a callback task. | 90 // A helper template to schedule a callback task. |
90 template <typename CB, typename CBArg> | 91 template <typename CB, typename CBArg> |
91 class DispatchCallbacRefPtrArgTask FINAL : public ExecutionContextTask { | 92 class DispatchCallbacRefPtrArgTask FINAL : public ExecutionContextTask { |
92 public: | 93 public: |
93 DispatchCallbacRefPtrArgTask(PassOwnPtr<CB> callback, PassRefPtr<CBArg>
arg) | 94 DispatchCallbacRefPtrArgTask(PassOwnPtr<CB> callback, PassRefPtrWillBeRa
wPtr<CBArg> arg) |
94 : m_callback(callback) | 95 : m_callback(callback) |
95 , m_callbackArg(arg) | 96 , m_callbackArg(arg) |
96 { | 97 { |
97 } | 98 } |
98 | 99 |
99 virtual void performTask(ExecutionContext*) OVERRIDE | 100 virtual void performTask(ExecutionContext*) OVERRIDE |
100 { | 101 { |
101 m_callback->handleEvent(m_callbackArg.get()); | 102 m_callback->handleEvent(m_callbackArg.get()); |
102 } | 103 } |
103 | 104 |
104 private: | 105 private: |
105 OwnPtr<CB> m_callback; | 106 OwnPtr<CB> m_callback; |
106 RefPtr<CBArg> m_callbackArg; | 107 RefPtrWillBePersistent<CBArg> m_callbackArg; |
107 }; | 108 }; |
108 | 109 |
109 template <typename CB, typename CBArg> | 110 template <typename CB, typename CBArg> |
110 class DispatchCallbackNonPtrArgTask FINAL : public ExecutionContextTask { | 111 class DispatchCallbackNonPtrArgTask FINAL : public ExecutionContextTask { |
111 public: | 112 public: |
112 DispatchCallbackNonPtrArgTask(PassOwnPtr<CB> callback, const CBArg& arg) | 113 DispatchCallbackNonPtrArgTask(PassOwnPtr<CB> callback, const CBArg& arg) |
113 : m_callback(callback) | 114 : m_callback(callback) |
114 , m_callbackArg(arg) | 115 , m_callbackArg(arg) |
115 { | 116 { |
116 } | 117 } |
117 | 118 |
118 virtual void performTask(ExecutionContext*) OVERRIDE | 119 virtual void performTask(ExecutionContext*) OVERRIDE |
119 { | 120 { |
120 m_callback->handleEvent(m_callbackArg); | 121 m_callback->handleEvent(m_callbackArg); |
121 } | 122 } |
122 | 123 |
123 private: | 124 private: |
124 OwnPtr<CB> m_callback; | 125 OwnPtr<CB> m_callback; |
125 CBArg m_callbackArg; | 126 CBArg m_callbackArg; |
126 }; | 127 }; |
127 }; | 128 }; |
128 | 129 |
129 template <typename CB, typename CBArg> | 130 template <typename CB, typename CBArg> |
130 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn
Ptr<CB> callback, PassRefPtr<CBArg> arg) | 131 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn
Ptr<CB> callback, PassRefPtrWillBeRawPtr<CBArg> arg) |
131 { | 132 { |
132 ASSERT(executionContext->isContextThread()); | 133 ASSERT(executionContext->isContextThread()); |
133 if (callback) | 134 if (callback) |
134 executionContext->postTask(adoptPtr(new DispatchCallbacRefPtrArgTask<CB,
CBArg>(callback, arg))); | 135 executionContext->postTask(adoptPtr(new DispatchCallbacRefPtrArgTask<CB,
CBArg>(callback, arg))); |
135 } | 136 } |
136 | 137 |
137 template <typename CB, typename CBArg> | 138 template <typename CB, typename CBArg> |
138 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn
Ptr<CB> callback, const CBArg& arg) | 139 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, PassOwn
Ptr<CB> callback, const CBArg& arg) |
139 { | 140 { |
140 ASSERT(executionContext->isContextThread()); | 141 ASSERT(executionContext->isContextThread()); |
141 if (callback) | 142 if (callback) |
142 executionContext->postTask(adoptPtr(new DispatchCallbackNonPtrArgTask<CB
, CBArg>(callback, arg))); | 143 executionContext->postTask(adoptPtr(new DispatchCallbackNonPtrArgTask<CB
, CBArg>(callback, arg))); |
143 } | 144 } |
144 | 145 |
145 } // namespace | 146 } // namespace |
146 | 147 |
147 #endif // DOMFileSystem_h | 148 #endif // DOMFileSystem_h |
OLD | NEW |