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

Side by Side Diff: WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h

Issue 12183004: Patch 3 in the series. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2010, 2012 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 25 matching lines...) Expand all
36 #include "ScriptExecutionContext.h" 36 #include "ScriptExecutionContext.h"
37 #include "WebFileError.h" 37 #include "WebFileError.h"
38 #include <public/WebFileSystem.h> 38 #include <public/WebFileSystem.h>
39 #include <public/WebVector.h> 39 #include <public/WebVector.h>
40 #include <wtf/PassOwnPtr.h> 40 #include <wtf/PassOwnPtr.h>
41 #include <wtf/PassRefPtr.h> 41 #include <wtf/PassRefPtr.h>
42 #include <wtf/Threading.h> 42 #include <wtf/Threading.h>
43 #include <wtf/text/WTFString.h> 43 #include <wtf/text/WTFString.h>
44 44
45 namespace WebCore { 45 namespace WebCore {
46 class BlobDataHandle;
46 class WorkerLoaderProxy; 47 class WorkerLoaderProxy;
47 } 48 }
48 49
49 namespace WebKit { 50 namespace WebKit {
50 51
51 class AsyncFileSystem; 52 class AsyncFileSystem;
52 class MainThreadFileSystemCallbacks; 53 class MainThreadFileSystemCallbacks;
53 class WebCommonWorkerClient; 54 class WebCommonWorkerClient;
54 class ThreadableCallbacksBridgeWrapper; 55 class ThreadableCallbacksBridgeWrapper;
55 class WebFileSystemCallbacks; 56 class WebFileSystemCallbacksImpl;
56 class WorkerFileSystemContextObserver; 57 class WorkerFileSystemContextObserver;
57 struct WebFileInfo; 58 struct WebFileInfo;
58 struct WebFileSystemEntry; 59 struct WebFileSystemEntry;
59 60
60 // Used to post a openFileSystem request to the main thread and get called back for the request. 61 // Used to post a openFileSystem request to the main thread and get called back for the request.
61 // 62 //
62 // Lifetime for this class is maintained by posted "tasks" which ref count it an d by MainThreadFileSystemCallbacks. 63 // Lifetime for this class is maintained by posted "tasks" which ref count it an d by MainThreadFileSystemCallbacks.
63 // Either a task finishing or the MainThreadFileSystemCallbacks being deleted ma y release the last ref on WorkerFileSystemCallbacksBridge. 64 // Either a task finishing or the MainThreadFileSystemCallbacks being deleted ma y release the last ref on WorkerFileSystemCallbacksBridge.
64 // 65 //
65 // A typical flow for openFileSystem would look like this: 66 // A typical flow for openFileSystem would look like this:
66 // Bridge::postOpenFileSystemToMainThread() on WorkerThread 67 // Bridge::postOpenFileSystemToMainThread() on WorkerThread
67 // --> Bridge::openFileSystemOnMainThread() is called on MainThread 68 // --> Bridge::openFileSystemOnMainThread() is called on MainThread
68 // This makes an IPC with a MainThreadFileSystemCallbacks instance 69 // This makes an IPC with a MainThreadFileSystemCallbacks instance
69 // [actual operation is down in the browser] 70 // [actual operation is down in the browser]
70 // --> MainThreadFileSystemCallbacks::didXxx is called on MainThread 71 // --> MainThreadFileSystemCallbacks::didXxx is called on MainThread
71 // --> Bridge::didXxxOnMainThread is called on MainThread 72 // --> Bridge::didXxxOnMainThread is called on MainThread
72 // --> Bridge::didXxxOnWorkerThread is called on WorkerThread 73 // --> Bridge::didXxxOnWorkerThread is called on WorkerThread
73 // This calls the original callbacks (m_callbacksOnWorkerThread). 74 // This calls the original callbacks (m_callbacksOnWorkerThread).
74 class WorkerFileSystemCallbacksBridge : public ThreadSafeRefCounted<WorkerFileSy stemCallbacksBridge> { 75 class WorkerFileSystemCallbacksBridge : public ThreadSafeRefCounted<WorkerFileSy stemCallbacksBridge> {
75 public: 76 public:
76 ~WorkerFileSystemCallbacksBridge(); 77 ~WorkerFileSystemCallbacksBridge();
77 78
78 void stop(); 79 void stop();
79 80
80 static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebCore::WorkerLoa derProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerContext, Web FileSystemCallbacks* callbacks) 81 static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebCore::WorkerLoa derProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerContext, Web FileSystemCallbacksImpl* callbacks)
81 { 82 {
82 return adoptRef(new WorkerFileSystemCallbacksBridge(workerLoaderProxy, w orkerContext, callbacks)); 83 return adoptRef(new WorkerFileSystemCallbacksBridge(workerLoaderProxy, w orkerContext, callbacks));
83 } 84 }
84 85
85 // Methods that create an instance and post an initial request task to the m ain thread. They must be called on the worker thread. 86 // Methods that create an instance and post an initial request task to the m ain thread. They must be called on the worker thread.
86 void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::T ype, long long size, bool create, const String& mode); 87 void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::T ype, long long size, bool create, const String& mode);
87 void postMoveToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, cons t WebCore::KURL& destPath, const String& mode); 88 void postMoveToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, cons t WebCore::KURL& destPath, const String& mode);
88 void postCopyToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, cons t WebCore::KURL& destPath, const String& mode); 89 void postCopyToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, cons t WebCore::KURL& destPath, const String& mode);
89 void postRemoveToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); 90 void postRemoveToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
90 void postRemoveRecursivelyToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); 91 void postRemoveRecursivelyToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
91 void postReadMetadataToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode); 92 void postReadMetadataToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
92 void postCreateFileToMainThread(WebFileSystem*, const WebCore::KURL& path, b ool exclusive, const String& mode); 93 void postCreateFileToMainThread(WebFileSystem*, const WebCore::KURL& path, b ool exclusive, const String& mode);
93 void postCreateDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& pa th, bool exclusive, const String& mode); 94 void postCreateDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& pa th, bool exclusive, const String& mode);
94 void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, c onst String& mode); 95 void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, c onst String& mode);
95 void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& pa th, const String& mode); 96 void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& pa th, const String& mode);
96 void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path , const String& mode); 97 void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path , const String& mode);
97 void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path, const String& mode); 98 void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
98 99
99 // Callback methods that are called on the main thread. 100 // Callback methods that are called on the main thread.
100 void didFailOnMainThread(WebFileError, const String& mode); 101 void didFailOnMainThread(WebFileError, const String& mode);
101 void didOpenFileSystemOnMainThread(const String& name, const WebCore::KURL& rootURL, const String& mode); 102 void didOpenFileSystemOnMainThread(const String& name, const WebCore::KURL& rootURL, const String& mode);
102 void didSucceedOnMainThread(const String& mode); 103 void didSucceedOnMainThread(const String& mode);
103 void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode); 104 void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode);
105 void didCreateSnapshotFileOnMainThread(const WebFileInfo&, const String& mod e, PassRefPtr<WebCore::BlobDataHandle> snapshotBlob);
104 void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode); 106 void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode);
105 107
106 private: 108 private:
107 WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::Script ExecutionContext*, WebFileSystemCallbacks*); 109 WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::Script ExecutionContext*, WebFileSystemCallbacksImpl*);
108 110
109 // Methods that are to be called on the main thread. 111 // Methods that are to be called on the main thread.
110 static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, Web CommonWorkerClient*, WebFileSystem::Type, long long size, bool create, PassRefPt r<WorkerFileSystemCallbacksBridge>, const String& mode); 112 static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, Web CommonWorkerClient*, WebFileSystem::Type, long long size, bool create, PassRefPt r<WorkerFileSystemCallbacksBridge>, const String& mode);
111 static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem *, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<Worke rFileSystemCallbacksBridge>, const String& mode); 113 static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem *, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<Worke rFileSystemCallbacksBridge>, const String& mode);
112 static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem *, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<Worke rFileSystemCallbacksBridge>, const String& mode); 114 static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem *, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, PassRefPtr<Worke rFileSystemCallbacksBridge>, const String& mode);
113 static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSyst em*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, con st String& mode); 115 static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSyst em*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, con st String& mode);
114 static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksB ridge>, const String& mode); 116 static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksB ridge>, const String& mode);
115 static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFi leSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge >, const String& mode); 117 static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFi leSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge >, const String& mode);
116 static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFile System*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemC allbacksBridge>, const String& mode); 118 static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFile System*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSystemC allbacksBridge>, const String& mode);
117 static void createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, We bFileSystem*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSy stemCallbacksBridge>, const String& mode); 119 static void createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, We bFileSystem*, const WebCore::KURL& path, bool exclusive, PassRefPtr<WorkerFileSy stemCallbacksBridge>, const String& mode);
118 static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFile System*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); 120 static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFile System*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
119 static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, We bFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBri dge>, const String& mode); 121 static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, We bFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBri dge>, const String& mode);
120 static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebF ileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridg e>, const String& mode); 122 static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebF ileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridg e>, const String& mode);
121 static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path , PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode); 123 static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacks Bridge>, const String& mode);
122 124
123 friend class MainThreadFileSystemCallbacks; 125 friend class MainThreadFileSystemCallbacks;
124 126
125 // Methods that dispatch WebFileSystemCallbacks on the worker threads. 127 // Methods that dispatch WebFileSystemCallbacks on the worker threads.
126 static void didFailOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefP tr<WorkerFileSystemCallbacksBridge>, WebFileError); 128 static void didFailOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefP tr<WorkerFileSystemCallbacksBridge>, WebFileError);
127 static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext* , PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& name, const WebCore ::KURL& rootPath); 129 static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext* , PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& name, const WebCore ::KURL& rootPath);
128 static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, PassR efPtr<WorkerFileSystemCallbacksBridge>); 130 static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, PassR efPtr<WorkerFileSystemCallbacksBridge>);
129 static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&); 131 static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&);
132 static void didCreateSnapshotFileOnWorkerThread(WebCore::ScriptExecutionCont ext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&, PassRefPt r<WebCore::BlobDataHandle> snapshotBlob);
130 static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebVector<WebFileSystemEntry >&, bool hasMore); 133 static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebVector<WebFileSystemEntry >&, bool hasMore);
131 134
132 static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr <WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::T ask>); 135 static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr <WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::T ask>);
133 static void runTaskOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefP tr<WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext: :Task>); 136 static void runTaskOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefP tr<WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext: :Task>);
134 137
135 void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Ta sk>); 138 void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Ta sk>);
136 void mayPostTaskToWorker(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode); 139 void mayPostTaskToWorker(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode);
137 140
138 void cleanUpAfterCallback(); 141 void cleanUpAfterCallback();
139 142
140 Mutex m_loaderProxyMutex; 143 Mutex m_loaderProxyMutex;
141 WebCore::WorkerLoaderProxy* m_workerLoaderProxy; 144 WebCore::WorkerLoaderProxy* m_workerLoaderProxy;
142 145
143 WebCore::ScriptExecutionContext* m_workerContext; 146 WebCore::ScriptExecutionContext* m_workerContext;
144 147
145 // Must be deleted on the WorkerContext thread. 148 // Must be deleted on the WorkerContext thread.
146 WorkerFileSystemContextObserver* m_workerContextObserver; 149 WorkerFileSystemContextObserver* m_workerContextObserver;
147 150
148 // This is self-destructed and must be fired on the worker thread. 151 // This is self-destructed and must be fired on the worker thread.
149 WebFileSystemCallbacks* m_callbacksOnWorkerThread; 152 WebFileSystemCallbacksImpl* m_callbacksOnWorkerThread;
150 }; 153 };
151 154
152 } // namespace WebCore 155 } // namespace WebCore
153 156
154 #endif 157 #endif
155 158
156 #endif // WorkerFileSystemCallbacksBridge_h 159 #endif // WorkerFileSystemCallbacksBridge_h
OLDNEW
« no previous file with comments | « WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp ('k') | WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698