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

Side by Side Diff: third_party/WebKit/Source/core/loader/WorkerThreadableLoader.h

Issue 2196833002: Propagate proper FROM_HERE to postTask() in worker code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 WorkerLoaderProxy* loaderProxy() 131 WorkerLoaderProxy* loaderProxy()
132 { 132 {
133 return m_loaderProxy.get(); 133 return m_loaderProxy.get();
134 } 134 }
135 135
136 private: 136 private:
137 // The following methods are overridden by the subclasses to implement 137 // The following methods are overridden by the subclasses to implement
138 // code to forward did.* method invocations to the worker context's 138 // code to forward did.* method invocations to the worker context's
139 // thread which is specialized for sync and async case respectively. 139 // thread which is specialized for sync and async case respectively.
140 virtual void forwardTaskToWorker(std::unique_ptr<ExecutionContextTask>) = 0; 140 virtual void forwardTaskToWorker(const WebTraceLocation&, std::unique_pt r<ExecutionContextTask>) = 0;
141 virtual void forwardTaskToWorkerOnLoaderDone(std::unique_ptr<ExecutionCo ntextTask>) = 0; 141 virtual void forwardTaskToWorkerOnLoaderDone(const WebTraceLocation&, st d::unique_ptr<ExecutionContextTask>) = 0;
142 142
143 // All executed on the main thread. 143 // All executed on the main thread.
144 void mainThreadCreateLoader(ThreadableLoaderOptions, ResourceLoaderOptio ns, ExecutionContext*); 144 void mainThreadCreateLoader(ThreadableLoaderOptions, ResourceLoaderOptio ns, ExecutionContext*);
145 void mainThreadStart(std::unique_ptr<CrossThreadResourceRequestData>); 145 void mainThreadStart(std::unique_ptr<CrossThreadResourceRequestData>);
146 void mainThreadDestroy(ExecutionContext*); 146 void mainThreadDestroy(ExecutionContext*);
147 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Execut ionContext*); 147 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Execut ionContext*);
148 void mainThreadCancel(ExecutionContext*); 148 void mainThreadCancel(ExecutionContext*);
149 149
150 // Only to be used on the main thread. 150 // Only to be used on the main thread.
151 std::unique_ptr<ThreadableLoader> m_mainThreadLoader; 151 std::unique_ptr<ThreadableLoader> m_mainThreadLoader;
152 152
153 // |m_workerClientWrapper| holds an pointer created on the worker 153 // |m_workerClientWrapper| holds an pointer created on the worker
154 // thread, and |this| instance is created on the main thread. 154 // thread, and |this| instance is created on the main thread.
155 CrossThreadPersistent<ThreadableLoaderClientWrapper> m_workerClientWrapp er; 155 CrossThreadPersistent<ThreadableLoaderClientWrapper> m_workerClientWrapp er;
156 156
157 // Used on the worker context thread. 157 // Used on the worker context thread.
158 RefPtr<WorkerLoaderProxy> m_loaderProxy; 158 RefPtr<WorkerLoaderProxy> m_loaderProxy;
159 }; 159 };
160 160
161 class MainThreadAsyncBridge final : public MainThreadBridgeBase { 161 class MainThreadAsyncBridge final : public MainThreadBridgeBase {
162 public: 162 public:
163 MainThreadAsyncBridge(WorkerGlobalScope&, ThreadableLoaderClientWrapper* , const ThreadableLoaderOptions&, const ResourceLoaderOptions&); 163 MainThreadAsyncBridge(WorkerGlobalScope&, ThreadableLoaderClientWrapper* , const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
164 void start(const ResourceRequest&, const WorkerGlobalScope&) override; 164 void start(const ResourceRequest&, const WorkerGlobalScope&) override;
165 165
166 private: 166 private:
167 ~MainThreadAsyncBridge() override; 167 ~MainThreadAsyncBridge() override;
168 168
169 void forwardTaskToWorker(std::unique_ptr<ExecutionContextTask>) override ; 169 void forwardTaskToWorker(const WebTraceLocation&, std::unique_ptr<Execut ionContextTask>) override;
170 void forwardTaskToWorkerOnLoaderDone(std::unique_ptr<ExecutionContextTas k>) override; 170 void forwardTaskToWorkerOnLoaderDone(const WebTraceLocation&, std::uniqu e_ptr<ExecutionContextTask>) override;
171 }; 171 };
172 172
173 class MainThreadSyncBridge final : public MainThreadBridgeBase { 173 class MainThreadSyncBridge final : public MainThreadBridgeBase {
174 public: 174 public:
175 MainThreadSyncBridge(WorkerGlobalScope&, ThreadableLoaderClientWrapper*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); 175 MainThreadSyncBridge(WorkerGlobalScope&, ThreadableLoaderClientWrapper*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
176 void start(const ResourceRequest&, const WorkerGlobalScope&) override; 176 void start(const ResourceRequest&, const WorkerGlobalScope&) override;
177 177
178 private: 178 private:
179 struct ClientTask {
180 WebTraceLocation m_location;
181 std::unique_ptr<ExecutionContextTask> m_task;
182
183 ClientTask(const WebTraceLocation&, std::unique_ptr<ExecutionContext Task>);
184 ~ClientTask();
185
186 ClientTask(ClientTask&&);
187 };
188
179 ~MainThreadSyncBridge() override; 189 ~MainThreadSyncBridge() override;
180 190
181 void forwardTaskToWorker(std::unique_ptr<ExecutionContextTask>) override ; 191 void forwardTaskToWorker(const WebTraceLocation&, std::unique_ptr<Execut ionContextTask>) override;
182 void forwardTaskToWorkerOnLoaderDone(std::unique_ptr<ExecutionContextTas k>) override; 192 void forwardTaskToWorkerOnLoaderDone(const WebTraceLocation&, std::uniqu e_ptr<ExecutionContextTask>) override;
183 193
184 bool m_done; 194 bool m_done;
185 std::unique_ptr<WaitableEvent> m_loaderDoneEvent; 195 std::unique_ptr<WaitableEvent> m_loaderDoneEvent;
186 // Thread-safety: |m_clientTasks| can be written (i.e. Closures are adde d) 196 // Thread-safety: |m_clientTasks| can be written (i.e. Closures are adde d)
187 // on the main thread only before |m_loaderDoneEvent| is signaled and ca n be read 197 // on the main thread only before |m_loaderDoneEvent| is signaled and ca n be read
188 // on the worker context thread only after |m_loaderDoneEvent| is signal ed. 198 // on the worker context thread only after |m_loaderDoneEvent| is signal ed.
189 Vector<std::unique_ptr<ExecutionContextTask>> m_clientTasks; 199 Vector<ClientTask> m_clientTasks;
190 Mutex m_lock; 200 Mutex m_lock;
191 }; 201 };
192 202
193 WorkerThreadableLoader(WorkerGlobalScope&, ThreadableLoaderClient*, const Th readableLoaderOptions&, const ResourceLoaderOptions&, BlockingBehavior); 203 WorkerThreadableLoader(WorkerGlobalScope&, ThreadableLoaderClient*, const Th readableLoaderOptions&, const ResourceLoaderOptions&, BlockingBehavior);
194 204
195 Persistent<WorkerGlobalScope> m_workerGlobalScope; 205 Persistent<WorkerGlobalScope> m_workerGlobalScope;
196 const Persistent<ThreadableLoaderClientWrapper> m_workerClientWrapper; 206 const Persistent<ThreadableLoaderClientWrapper> m_workerClientWrapper;
197 207
198 MainThreadBridgeBase* m_bridge; 208 MainThreadBridgeBase* m_bridge;
199 }; 209 };
200 210
201 } // namespace blink 211 } // namespace blink
202 212
203 #endif // WorkerThreadableLoader_h 213 #endif // WorkerThreadableLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698