RESOLVED FIXED 43135
Decouple FileThread from FileStream to support generic file-related async tasks
https://bugs.webkit.org/show_bug.cgi?id=43135
Summary Decouple FileThread from FileStream to support generic file-related async tasks
Kinuko Yasuda
Reported 2010-07-28 12:19:42 PDT
Decouple FileThread from FileStream to support generic file-related async tasks. This is needed for FileSystem API implementation.
Attachments
Patch (23.09 KB, patch)
2010-07-28 12:23 PDT, Kinuko Yasuda
no flags
Patch (13.20 KB, patch)
2010-07-28 18:03 PDT, Kinuko Yasuda
jianli: review+
Kinuko Yasuda
Comment 1 2010-07-28 12:23:24 PDT
Jian Li
Comment 2 2010-07-28 15:01:16 PDT
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); }
Kinuko Yasuda
Comment 3 2010-07-28 18:03:53 PDT
Kinuko Yasuda
Comment 4 2010-07-28 18:07:22 PDT
(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.
Jian Li
Comment 5 2010-07-30 14:44:26 PDT
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.
Kinuko Yasuda
Comment 6 2010-07-30 22:04:29 PDT
Note You need to log in before you can comment on or make changes to this bug.