Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: Source/modules/filesystem/DOMFileSystem.h

Issue 22436002: Replace EntryArray type by an Entry[] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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/ScriptExecutionContext.h" 36 #include "core/dom/ScriptExecutionContext.h"
37 #include "modules/filesystem/DOMFileSystemBase.h" 37 #include "modules/filesystem/DOMFileSystemBase.h"
38 #include "modules/filesystem/EntriesCallback.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class DirectoryEntry; 42 class DirectoryEntry;
42 class File; 43 class File;
43 class FileCallback; 44 class FileCallback;
44 class FileEntry; 45 class FileEntry;
45 class FileWriterCallback; 46 class FileWriterCallback;
46 47
47 class DOMFileSystem : public DOMFileSystemBase, public ScriptWrappable, public A ctiveDOMObject { 48 class DOMFileSystem : public DOMFileSystemBase, public ScriptWrappable, public A ctiveDOMObject {
(...skipping 12 matching lines...) Expand all
60 61
61 void createWriter(const FileEntry*, PassRefPtr<FileWriterCallback>, PassRefP tr<ErrorCallback>); 62 void createWriter(const FileEntry*, PassRefPtr<FileWriterCallback>, PassRefP tr<ErrorCallback>);
62 void createFile(const FileEntry*, PassRefPtr<FileCallback>, PassRefPtr<Error Callback>); 63 void createFile(const FileEntry*, PassRefPtr<FileCallback>, PassRefPtr<Error Callback>);
63 64
64 // Schedule a callback. This should not cross threads (should be called on t he same context thread). 65 // Schedule a callback. This should not cross threads (should be called on t he same context thread).
65 // FIXME: move this to a more generic place. 66 // FIXME: move this to a more generic place.
66 template <typename CB, typename CBArg> 67 template <typename CB, typename CBArg>
67 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRe fPtr<CBArg>); 68 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRe fPtr<CBArg>);
68 69
69 template <typename CB, typename CBArg> 70 template <typename CB, typename CBArg>
71 static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, const CBArg&);
72
73 template <typename CB, typename CBArg>
70 void scheduleCallback(PassRefPtr<CB> callback, PassRefPtr<CBArg> callbackArg ) 74 void scheduleCallback(PassRefPtr<CB> callback, PassRefPtr<CBArg> callbackArg )
71 { 75 {
72 scheduleCallback(scriptExecutionContext(), callback, callbackArg); 76 scheduleCallback(scriptExecutionContext(), callback, callbackArg);
73 } 77 }
74 78
79 template <typename CB, typename CBArg>
80 void scheduleCallback(PassRefPtr<CB> callback, const CBArg& callbackArg)
81 {
82 scheduleCallback(scriptExecutionContext(), callback, callbackArg);
83 }
84
75 private: 85 private:
76 DOMFileSystem(ScriptExecutionContext*, const String& name, FileSystemType, c onst KURL& rootURL, PassOwnPtr<AsyncFileSystem>); 86 DOMFileSystem(ScriptExecutionContext*, const String& name, FileSystemType, c onst KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
77 87
78 // A helper template to schedule a callback task. 88 // A helper template to schedule a callback task.
79 template <typename CB, typename CBArg> 89 template <typename CB, typename CBArg>
80 class DispatchCallbackTask : public ScriptExecutionContext::Task { 90 class DispatchCallbacRefPtrArgTask : public ScriptExecutionContext::Task {
81 public: 91 public:
82 DispatchCallbackTask(PassRefPtr<CB> callback, PassRefPtr<CBArg> arg) 92 DispatchCallbacRefPtrArgTask(PassRefPtr<CB> callback, PassRefPtr<CBArg> arg)
83 : m_callback(callback) 93 : m_callback(callback)
84 , m_callbackArg(arg) 94 , m_callbackArg(arg)
85 { 95 {
86 } 96 }
87 97
88 virtual void performTask(ScriptExecutionContext*) 98 virtual void performTask(ScriptExecutionContext*)
89 { 99 {
90 m_callback->handleEvent(m_callbackArg.get()); 100 m_callback->handleEvent(m_callbackArg.get());
91 } 101 }
92 102
93 private: 103 private:
94 RefPtr<CB> m_callback; 104 RefPtr<CB> m_callback;
95 RefPtr<CBArg> m_callbackArg; 105 RefPtr<CBArg> m_callbackArg;
96 }; 106 };
107
108 template <typename CB, typename CBArg>
109 class DispatchCallbackNonPtrArgTask : public ScriptExecutionContext::Task {
110 public:
111 DispatchCallbackNonPtrArgTask(PassRefPtr<CB> callback, const CBArg& arg)
112 : m_callback(callback)
113 , m_callbackArg(arg)
114 {
115 }
116
117 virtual void performTask(ScriptExecutionContext*)
118 {
119 m_callback->handleEvent(m_callbackArg);
120 }
121
122 private:
123 RefPtr<CB> m_callback;
124 CBArg m_callbackArg;
125 };
97 }; 126 };
98 127
99 template <typename CB, typename CBArg> 128 template <typename CB, typename CBArg>
100 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont ext, PassRefPtr<CB> callback, PassRefPtr<CBArg> arg) 129 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont ext, PassRefPtr<CB> callback, PassRefPtr<CBArg> arg)
101 { 130 {
102 ASSERT(scriptExecutionContext->isContextThread()); 131 ASSERT(scriptExecutionContext->isContextThread());
103 if (callback) 132 if (callback)
104 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbackTask<CB, C BArg>(callback, arg))); 133 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbacRefPtrArgTa sk<CB, CBArg>(callback, arg)));
134 }
135
136 template <typename CB, typename CBArg>
137 void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionCont ext, PassRefPtr<CB> callback, const CBArg& arg)
138 {
139 ASSERT(scriptExecutionContext->isContextThread());
140 if (callback)
141 scriptExecutionContext->postTask(adoptPtr(new DispatchCallbackNonPtrArgT ask<CB, CBArg>(callback, arg)));
105 } 142 }
106 143
107 } // namespace 144 } // namespace
108 145
109 #endif // DOMFileSystem_h 146 #endif // DOMFileSystem_h
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorFileSystemAgent.cpp ('k') | Source/modules/filesystem/DOMFileSystemBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698