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 #include "platform/heap/Handle.h" | 40 #include "platform/heap/Handle.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class DirectoryEntry; | 44 class DirectoryEntry; |
45 class File; | 45 class File; |
46 class FileCallback; | 46 class FileCallback; |
47 class FileEntry; | 47 class FileEntry; |
48 class FileWriterCallback; | 48 class FileWriterCallback; |
49 | 49 |
50 class DOMFileSystem FINAL : public DOMFileSystemBase, public ScriptWrappable, pu
blic ActiveDOMObject { | 50 class DOMFileSystem final : public DOMFileSystemBase, public ScriptWrappable, pu
blic ActiveDOMObject { |
51 DEFINE_WRAPPERTYPEINFO(); | 51 DEFINE_WRAPPERTYPEINFO(); |
52 public: | 52 public: |
53 static DOMFileSystem* create(ExecutionContext*, const String& name, FileSyst
emType, const KURL& rootURL); | 53 static DOMFileSystem* create(ExecutionContext*, const String& name, FileSyst
emType, const KURL& rootURL); |
54 | 54 |
55 // Creates a new isolated file system for the given filesystemId. | 55 // Creates a new isolated file system for the given filesystemId. |
56 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); | 56 static DOMFileSystem* createIsolatedFileSystem(ExecutionContext*, const Stri
ng& filesystemId); |
57 | 57 |
58 DirectoryEntry* root(); | 58 DirectoryEntry* root(); |
59 | 59 |
60 // DOMFileSystemBase overrides. | 60 // DOMFileSystemBase overrides. |
61 virtual void addPendingCallbacks() OVERRIDE; | 61 virtual void addPendingCallbacks() override; |
62 virtual void removePendingCallbacks() OVERRIDE; | 62 virtual void removePendingCallbacks() override; |
63 virtual void reportError(ErrorCallback*, FileError*) OVERRIDE; | 63 virtual void reportError(ErrorCallback*, FileError*) override; |
64 | 64 |
65 // ActiveDOMObject overrides. | 65 // ActiveDOMObject overrides. |
66 virtual bool hasPendingActivity() const OVERRIDE; | 66 virtual bool hasPendingActivity() const override; |
67 | 67 |
68 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); | 68 void createWriter(const FileEntry*, FileWriterCallback*, ErrorCallback*); |
69 void createFile(const FileEntry*, FileCallback*, ErrorCallback*); | 69 void createFile(const FileEntry*, FileCallback*, ErrorCallback*); |
70 | 70 |
71 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). | 71 // Schedule a callback. This should not cross threads (should be called on t
he same context thread). |
72 // FIXME: move this to a more generic place. | 72 // FIXME: move this to a more generic place. |
73 template <typename CB, typename CBArg> | 73 template <typename CB, typename CBArg> |
74 static void scheduleCallback(ExecutionContext*, CB*, PassRefPtrWillBeRawPtr<
CBArg>); | 74 static void scheduleCallback(ExecutionContext*, CB*, PassRefPtrWillBeRawPtr<
CBArg>); |
75 | 75 |
76 template <typename CB, typename CBArg> | 76 template <typename CB, typename CBArg> |
(...skipping 27 matching lines...) Expand all Loading... |
104 void scheduleCallback(CB* callback, const CBArg& callbackArg) | 104 void scheduleCallback(CB* callback, const CBArg& callbackArg) |
105 { | 105 { |
106 scheduleCallback(executionContext(), callback, callbackArg); | 106 scheduleCallback(executionContext(), callback, callbackArg); |
107 } | 107 } |
108 | 108 |
109 private: | 109 private: |
110 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); | 110 DOMFileSystem(ExecutionContext*, const String& name, FileSystemType, const K
URL& rootURL); |
111 | 111 |
112 class DispatchCallbackTaskBase : public ExecutionContextTask { | 112 class DispatchCallbackTaskBase : public ExecutionContextTask { |
113 public: | 113 public: |
114 virtual String taskNameForInstrumentation() const OVERRIDE | 114 virtual String taskNameForInstrumentation() const override |
115 { | 115 { |
116 return "FileSystem"; | 116 return "FileSystem"; |
117 } | 117 } |
118 }; | 118 }; |
119 | 119 |
120 // A helper template to schedule a callback task. | 120 // A helper template to schedule a callback task. |
121 template <typename CB, typename CBArg> | 121 template <typename CB, typename CBArg> |
122 class DispatchCallbackRefPtrArgTask FINAL : public DispatchCallbackTaskBase
{ | 122 class DispatchCallbackRefPtrArgTask final : public DispatchCallbackTaskBase
{ |
123 public: | 123 public: |
124 DispatchCallbackRefPtrArgTask(CB* callback, PassRefPtrWillBeRawPtr<CBArg
> arg) | 124 DispatchCallbackRefPtrArgTask(CB* callback, PassRefPtrWillBeRawPtr<CBArg
> arg) |
125 : m_callback(callback) | 125 : m_callback(callback) |
126 , m_callbackArg(arg) | 126 , m_callbackArg(arg) |
127 { | 127 { |
128 } | 128 } |
129 | 129 |
130 virtual void performTask(ExecutionContext*) OVERRIDE | 130 virtual void performTask(ExecutionContext*) override |
131 { | 131 { |
132 m_callback->handleEvent(m_callbackArg.get()); | 132 m_callback->handleEvent(m_callbackArg.get()); |
133 } | 133 } |
134 | 134 |
135 private: | 135 private: |
136 Persistent<CB> m_callback; | 136 Persistent<CB> m_callback; |
137 RefPtrWillBePersistent<CBArg> m_callbackArg; | 137 RefPtrWillBePersistent<CBArg> m_callbackArg; |
138 }; | 138 }; |
139 | 139 |
140 template <typename CB, typename CBArg> | 140 template <typename CB, typename CBArg> |
141 class DispatchCallbackPtrArgTask FINAL : public DispatchCallbackTaskBase { | 141 class DispatchCallbackPtrArgTask final : public DispatchCallbackTaskBase { |
142 public: | 142 public: |
143 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) | 143 DispatchCallbackPtrArgTask(CB* callback, CBArg* arg) |
144 : m_callback(callback) | 144 : m_callback(callback) |
145 , m_callbackArg(arg) | 145 , m_callbackArg(arg) |
146 { | 146 { |
147 } | 147 } |
148 | 148 |
149 virtual void performTask(ExecutionContext*) OVERRIDE | 149 virtual void performTask(ExecutionContext*) override |
150 { | 150 { |
151 m_callback->handleEvent(m_callbackArg.get()); | 151 m_callback->handleEvent(m_callbackArg.get()); |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 Persistent<CB> m_callback; | 155 Persistent<CB> m_callback; |
156 Persistent<CBArg> m_callbackArg; | 156 Persistent<CBArg> m_callbackArg; |
157 }; | 157 }; |
158 | 158 |
159 template <typename CB, typename CBArg> | 159 template <typename CB, typename CBArg> |
160 class DispatchCallbackNonPtrArgTask FINAL : public DispatchCallbackTaskBase
{ | 160 class DispatchCallbackNonPtrArgTask final : public DispatchCallbackTaskBase
{ |
161 public: | 161 public: |
162 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) | 162 DispatchCallbackNonPtrArgTask(CB* callback, const CBArg& arg) |
163 : m_callback(callback) | 163 : m_callback(callback) |
164 , m_callbackArg(arg) | 164 , m_callbackArg(arg) |
165 { | 165 { |
166 } | 166 } |
167 | 167 |
168 virtual void performTask(ExecutionContext*) OVERRIDE | 168 virtual void performTask(ExecutionContext*) override |
169 { | 169 { |
170 m_callback->handleEvent(m_callbackArg); | 170 m_callback->handleEvent(m_callbackArg); |
171 } | 171 } |
172 | 172 |
173 private: | 173 private: |
174 Persistent<CB> m_callback; | 174 Persistent<CB> m_callback; |
175 CBArg m_callbackArg; | 175 CBArg m_callbackArg; |
176 }; | 176 }; |
177 | 177 |
178 template <typename CB> | 178 template <typename CB> |
179 class DispatchCallbackNoArgTask FINAL : public DispatchCallbackTaskBase { | 179 class DispatchCallbackNoArgTask final : public DispatchCallbackTaskBase { |
180 public: | 180 public: |
181 DispatchCallbackNoArgTask(CB* callback) | 181 DispatchCallbackNoArgTask(CB* callback) |
182 : m_callback(callback) | 182 : m_callback(callback) |
183 { | 183 { |
184 } | 184 } |
185 | 185 |
186 virtual void performTask(ExecutionContext*) OVERRIDE | 186 virtual void performTask(ExecutionContext*) override |
187 { | 187 { |
188 m_callback->handleEvent(); | 188 m_callback->handleEvent(); |
189 } | 189 } |
190 | 190 |
191 private: | 191 private: |
192 Persistent<CB> m_callback; | 192 Persistent<CB> m_callback; |
193 }; | 193 }; |
194 | 194 |
195 int m_numberOfPendingCallbacks; | 195 int m_numberOfPendingCallbacks; |
196 }; | 196 }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) | 239 void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, CB* cal
lback) |
240 { | 240 { |
241 ASSERT(executionContext->isContextThread()); | 241 ASSERT(executionContext->isContextThread()); |
242 if (callback) | 242 if (callback) |
243 executionContext->postTask(adoptPtr(new DispatchCallbackNoArgTask<CB>(ca
llback))); | 243 executionContext->postTask(adoptPtr(new DispatchCallbackNoArgTask<CB>(ca
llback))); |
244 } | 244 } |
245 | 245 |
246 } // namespace blink | 246 } // namespace blink |
247 | 247 |
248 #endif // DOMFileSystem_h | 248 #endif // DOMFileSystem_h |
OLD | NEW |