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

Side by Side Diff: Source/WebKit/chromium/src/WorkerFileWriterCallbacksBridge.h

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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 WorkerFileWriterCallbacksBridge_h 31 #ifndef WorkerFileWriterCallbacksBridge_h
32 #define WorkerFileWriterCallbacksBridge_h 32 #define WorkerFileWriterCallbacksBridge_h
33 33
34 #include "WebFileWriterClient.h" 34 #include "WebFileWriterClient.h"
35 #include "core/workers/WorkerContext.h" 35 #include "core/workers/WorkerGlobalScope.h"
36 #include "public/platform/WebFileError.h" 36 #include "public/platform/WebFileError.h"
37 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 #include "wtf/ThreadSafeRefCounted.h" 39 #include "wtf/ThreadSafeRefCounted.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 class AsyncFileWriterClient; 42 class AsyncFileWriterClient;
43 class KURL; 43 class KURL;
44 class WorkerLoaderProxy; 44 class WorkerLoaderProxy;
45 } 45 }
(...skipping 25 matching lines...) Expand all
71 // --> Bridge::didWriteOnWorkerThread is called on WorkerThread 71 // --> Bridge::didWriteOnWorkerThread is called on WorkerThread
72 // This calls the original client (m_clientOnWorkerThread). 72 // This calls the original client (m_clientOnWorkerThread).
73 // 73 //
74 // The bridge object is refcounted, so that it doesn't get deleted while there 74 // The bridge object is refcounted, so that it doesn't get deleted while there
75 // are cross-thread calls in flight. Each CrossThreadTask carries a reference 75 // are cross-thread calls in flight. Each CrossThreadTask carries a reference
76 // to the bridge, which guarantees that the bridge will still be valid when the 76 // to the bridge, which guarantees that the bridge will still be valid when the
77 // task is executed. In order to shut down the bridge, the WebFileWriterClient 77 // task is executed. In order to shut down the bridge, the WebFileWriterClient
78 // should call postShutdownToMainThread before dropping its reference to the 78 // should call postShutdownToMainThread before dropping its reference to the
79 // bridge. This ensures that the WebFileWriter will be cleared on the main 79 // bridge. This ensures that the WebFileWriter will be cleared on the main
80 // thread and that no further calls to the WebFileWriterClient will be made. 80 // thread and that no further calls to the WebFileWriterClient will be made.
81 class WorkerFileWriterCallbacksBridge : public ThreadSafeRefCounted<WorkerFileWr iterCallbacksBridge>, public WebCore::WorkerContext::Observer, public WebFileWri terClient { 81 class WorkerFileWriterCallbacksBridge : public ThreadSafeRefCounted<WorkerFileWr iterCallbacksBridge>, public WebCore::WorkerGlobalScope::Observer, public WebFil eWriterClient {
82 public: 82 public:
83 ~WorkerFileWriterCallbacksBridge(); 83 ~WorkerFileWriterCallbacksBridge();
84 84
85 // WorkerContext::Observer method. 85 // WorkerGlobalScope::Observer method.
86 virtual void notifyStop(); 86 virtual void notifyStop();
87 87
88 static PassRefPtr<WorkerFileWriterCallbacksBridge> create(const WebCore::KUR L& path, WebCore::WorkerLoaderProxy* proxy, WebCore::ScriptExecutionContext* wor kerContext, WebCore::AsyncFileWriterClient* client) 88 static PassRefPtr<WorkerFileWriterCallbacksBridge> create(const WebCore::KUR L& path, WebCore::WorkerLoaderProxy* proxy, WebCore::ScriptExecutionContext* wor kerGlobalScope, WebCore::AsyncFileWriterClient* client)
89 { 89 {
90 return adoptRef(new WorkerFileWriterCallbacksBridge(path, proxy, workerC ontext, client)); 90 return adoptRef(new WorkerFileWriterCallbacksBridge(path, proxy, workerG lobalScope, client));
91 } 91 }
92 92
93 // Methods that create an instance and post an initial request task to the m ain thread. They must be called on the worker thread. 93 // Methods that create an instance and post an initial request task to the m ain thread. They must be called on the worker thread.
94 void postWriteToMainThread(long long position, const WebCore::KURL& data); 94 void postWriteToMainThread(long long position, const WebCore::KURL& data);
95 void postTruncateToMainThread(long long length); 95 void postTruncateToMainThread(long long length);
96 void postAbortToMainThread(); 96 void postAbortToMainThread();
97 97
98 // The owning WorkerAsyncFileWriterChromium should call this method before d ropping its last reference to the bridge, on the context thread. 98 // The owning WorkerAsyncFileWriterChromium should call this method before d ropping its last reference to the bridge, on the context thread.
99 // The actual deletion of the WorkerFileWriterCallbacksBridge may happen on either the main or context thread, depending on where the last reference goes aw ay; that's safe as long as this is called first. 99 // The actual deletion of the WorkerFileWriterCallbacksBridge may happen on either the main or context thread, depending on where the last reference goes aw ay; that's safe as long as this is called first.
100 void postShutdownToMainThread(PassRefPtr<WorkerFileWriterCallbacksBridge>); 100 void postShutdownToMainThread(PassRefPtr<WorkerFileWriterCallbacksBridge>);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // Called on the main thread to dispatch to the worker thread. 135 // Called on the main thread to dispatch to the worker thread.
136 void dispatchTaskToWorkerThread(PassOwnPtr<WebCore::ScriptExecutionContext:: Task>); 136 void dispatchTaskToWorkerThread(PassOwnPtr<WebCore::ScriptExecutionContext:: Task>);
137 137
138 // Used from the main thread to post tasks to the context thread. 138 // Used from the main thread to post tasks to the context thread.
139 WebCore::WorkerLoaderProxy* m_proxy; 139 WebCore::WorkerLoaderProxy* m_proxy;
140 140
141 // Mutex for proxy. 141 // Mutex for proxy.
142 Mutex m_loaderProxyMutex; 142 Mutex m_loaderProxyMutex;
143 143
144 // Used on the context thread, only to check that we're running on the conte xt thread. 144 // Used on the context thread, only to check that we're running on the conte xt thread.
145 WebCore::ScriptExecutionContext* m_workerContext; 145 WebCore::ScriptExecutionContext* m_workerGlobalScope;
146 146
147 // Created and destroyed from the main thread. 147 // Created and destroyed from the main thread.
148 OwnPtr<WebKit::WebFileWriter> m_writer; 148 OwnPtr<WebKit::WebFileWriter> m_writer;
149 149
150 // Used on the context thread to call back into the client. 150 // Used on the context thread to call back into the client.
151 WebCore::AsyncFileWriterClient* m_clientOnWorkerThread; 151 WebCore::AsyncFileWriterClient* m_clientOnWorkerThread;
152 152
153 // Used to indicate that shutdown has started on the main thread, and hence the writer has been deleted. 153 // Used to indicate that shutdown has started on the main thread, and hence the writer has been deleted.
154 bool m_writerDeleted; 154 bool m_writerDeleted;
155 155
156 // Used by waitForOperationToComplete. 156 // Used by waitForOperationToComplete.
157 bool m_operationInProgress; 157 bool m_operationInProgress;
158 158
159 // Used by postTaskForModeToWorkerContext and runInMode. 159 // Used by postTaskForModeToWorkerGlobalScope and runInMode.
160 String m_mode; 160 String m_mode;
161 }; 161 };
162 162
163 } // namespace WebCore 163 } // namespace WebCore
164 164
165 #endif // WorkerFileWriterCallbacksBridge_h 165 #endif // WorkerFileWriterCallbacksBridge_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698