Decouple FileThread from FileStream to support generic file-related async tasks. This is needed for FileSystem API implementation.
Created attachment 62860 [details] Patch
Comment on attachment 62860 [details] Patch It is a good idea to support generic file related async tasks. However, I am thinking if it is possible to make current FileThreadTask support calling any class methods asynchronously. How about something like the following: // FileThread.h ... class Task : public Noncopyable { public: virtual ~Task() { } virtual void performTask() = 0; void* instance() const { return m_instance; } protected: Task(void* instance) : m_instance(instance) { } void* m_instance; }; void postTask(PassOwnPtr<Task> task); void unscheduleTasks(const void* instance); // FileThreadTask.h ... template<typename R, typename T> class FileThreadTask0 : public FileThread::Task { public: typedef R (T::*Method)(); typedef FileThreadTask0<R, T> FileThreadTask; static PassOwnPtr<FileThreadTask> create(T* instance, Method method) { return new FileThreadTask(instance, method); } private: FileThreadTask0(T* instance, Method method) : FileThread::Task(instance) , m_method(method) { } virtual void performTask() { (*reinterpret_cast<T*>(instance()).*m_method)(); } private: Method m_method; }; ... template<typename R, typename T> PassOwnPtr<FileThread::Task> createFileThreadTask( T* const callee, R (T::*method)()) { return FileThreadTask0<R, T>::create( callee, method); }
Created attachment 62903 [details] Patch
(In reply to comment #2) > (From update of attachment 62860 [details]) > It is a good idea to support generic file related async tasks. However, I am thinking if it is possible to make current FileThreadTask support calling any class methods asynchronously. How about something like the following: > > // FileThread.h > ... Sounds good, and it would require less changes. Updated the patch.
Comment on attachment 62903 [details] Patch Looks good. Please address the following issue before you land. WebCore/html/FileThreadTask.h: + R (FileStream::*method)()); Why removing this? I think this forward declaration is needed to get rid of the warning treater as error in snow leopard. See http://trac.webkit.org/changeset/59166 for detail.
Committed r64406: <http://trac.webkit.org/changeset/64406>