| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 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 30 matching lines...) Expand all Loading... |
| 41 #include "platform/WaitableEvent.h" | 41 #include "platform/WaitableEvent.h" |
| 42 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
| 43 #include "platform/network/ResourceError.h" | 43 #include "platform/network/ResourceError.h" |
| 44 #include "platform/network/ResourceRequest.h" | 44 #include "platform/network/ResourceRequest.h" |
| 45 #include "platform/network/ResourceResponse.h" | 45 #include "platform/network/ResourceResponse.h" |
| 46 #include "platform/network/ResourceTimingInfo.h" | 46 #include "platform/network/ResourceTimingInfo.h" |
| 47 #include "platform/weborigin/SecurityPolicy.h" | 47 #include "platform/weborigin/SecurityPolicy.h" |
| 48 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
| 49 #include "wtf/PtrUtil.h" | 49 #include "wtf/PtrUtil.h" |
| 50 #include "wtf/Vector.h" | 50 #include "wtf/Vector.h" |
| 51 #include "wtf/debug/Alias.h" |
| 51 #include <memory> | 52 #include <memory> |
| 52 | 53 |
| 53 namespace blink { | 54 namespace blink { |
| 54 | 55 |
| 55 static std::unique_ptr<Vector<char>> createVectorFromMemoryRegion(const char* da
ta, unsigned dataLength) | 56 static std::unique_ptr<Vector<char>> createVectorFromMemoryRegion(const char* da
ta, unsigned dataLength) |
| 56 { | 57 { |
| 57 std::unique_ptr<Vector<char>> buffer = wrapUnique(new Vector<char>(dataLengt
h)); | 58 std::unique_ptr<Vector<char>> buffer = wrapUnique(new Vector<char>(dataLengt
h)); |
| 58 memcpy(buffer->data(), data, dataLength); | 59 memcpy(buffer->data(), data, dataLength); |
| 59 return buffer; | 60 return buffer; |
| 60 } | 61 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadStart(std::unique_p
tr<CrossThreadResourceRequestData> requestData) | 131 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadStart(std::unique_p
tr<CrossThreadResourceRequestData> requestData) |
| 131 { | 132 { |
| 132 ASSERT(isMainThread()); | 133 ASSERT(isMainThread()); |
| 133 ASSERT(m_mainThreadLoader); | 134 ASSERT(m_mainThreadLoader); |
| 134 m_mainThreadLoader->start(ResourceRequest(requestData.get())); | 135 m_mainThreadLoader->start(ResourceRequest(requestData.get())); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void WorkerThreadableLoader::MainThreadBridgeBase::createLoaderInMainThread(cons
t ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderO
ptions) | 138 void WorkerThreadableLoader::MainThreadBridgeBase::createLoaderInMainThread(cons
t ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderO
ptions) |
| 138 { | 139 { |
| 139 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCreateLoader, crossThreadUnretained(this), options, resourceLoaderOpt
ions)); | 140 m_loaderProxy->postTaskToLoader(BLINK_FROM_HERE, createCrossThreadTask(&Main
ThreadBridgeBase::mainThreadCreateLoader, crossThreadUnretained(this), options,
resourceLoaderOptions)); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void WorkerThreadableLoader::MainThreadBridgeBase::startInMainThread(const Resou
rceRequest& request, const WorkerGlobalScope& workerGlobalScope) | 143 void WorkerThreadableLoader::MainThreadBridgeBase::startInMainThread(const Resou
rceRequest& request, const WorkerGlobalScope& workerGlobalScope) |
| 143 { | 144 { |
| 144 loaderProxy()->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadStart, crossThreadUnretained(this), request)); | 145 loaderProxy()->postTaskToLoader(BLINK_FROM_HERE, createCrossThreadTask(&Main
ThreadBridgeBase::mainThreadStart, crossThreadUnretained(this), request)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadDestroy(ExecutionCo
ntext* context) | 148 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadDestroy(ExecutionCo
ntext* context) |
| 148 { | 149 { |
| 149 ASSERT(isMainThread()); | 150 ASSERT(isMainThread()); |
| 150 ASSERT_UNUSED(context, context->isDocument()); | 151 ASSERT_UNUSED(context, context->isDocument()); |
| 151 delete this; | 152 delete this; |
| 152 } | 153 } |
| 153 | 154 |
| 154 void WorkerThreadableLoader::MainThreadBridgeBase::destroy() | 155 void WorkerThreadableLoader::MainThreadBridgeBase::destroy() |
| 155 { | 156 { |
| 156 // Ensure that no more client callbacks are done in the worker context's | 157 // Ensure that no more client callbacks are done in the worker context's |
| 157 // thread. | 158 // thread. |
| 158 // ThreadableLoaderClientWrapper is an on-heap class and this function can | 159 // ThreadableLoaderClientWrapper is an on-heap class and this function can |
| 159 // be called in the finalization step but it is safe because | 160 // be called in the finalization step but it is safe because |
| 160 // m_workerClientWrapper is a CrossThreadPersistent. | 161 // m_workerClientWrapper is a CrossThreadPersistent. |
| 161 m_workerClientWrapper->clearClient(); | 162 m_workerClientWrapper->clearClient(); |
| 162 | 163 |
| 163 // "delete this" and m_mainThreadLoader::deref() on the worker object's | 164 // "delete this" and m_mainThreadLoader::deref() on the worker object's |
| 164 // thread. | 165 // thread. |
| 165 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadDestroy, crossThreadUnretained(this))); | 166 m_loaderProxy->postTaskToLoader(BLINK_FROM_HERE, createCrossThreadTask(&Main
ThreadBridgeBase::mainThreadDestroy, crossThreadUnretained(this))); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadOverrideTimeout(uns
igned long timeoutMilliseconds, ExecutionContext* context) | 169 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadOverrideTimeout(uns
igned long timeoutMilliseconds, ExecutionContext* context) |
| 169 { | 170 { |
| 170 ASSERT(isMainThread()); | 171 ASSERT(isMainThread()); |
| 171 ASSERT_UNUSED(context, context->isDocument()); | 172 ASSERT_UNUSED(context, context->isDocument()); |
| 172 | 173 |
| 173 if (!m_mainThreadLoader) | 174 if (!m_mainThreadLoader) |
| 174 return; | 175 return; |
| 175 m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); | 176 m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void WorkerThreadableLoader::MainThreadBridgeBase::overrideTimeout(unsigned long
timeoutMilliseconds) | 179 void WorkerThreadableLoader::MainThreadBridgeBase::overrideTimeout(unsigned long
timeoutMilliseconds) |
| 179 { | 180 { |
| 180 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadOverrideTimeout, crossThreadUnretained(this), timeoutMilliseconds)); | 181 m_loaderProxy->postTaskToLoader(BLINK_FROM_HERE, createCrossThreadTask(&Main
ThreadBridgeBase::mainThreadOverrideTimeout, crossThreadUnretained(this), timeou
tMilliseconds)); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadCancel(ExecutionCon
text* context) | 184 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadCancel(ExecutionCon
text* context) |
| 184 { | 185 { |
| 185 ASSERT(isMainThread()); | 186 ASSERT(isMainThread()); |
| 186 ASSERT_UNUSED(context, context->isDocument()); | 187 ASSERT_UNUSED(context, context->isDocument()); |
| 187 | 188 |
| 188 if (!m_mainThreadLoader) | 189 if (!m_mainThreadLoader) |
| 189 return; | 190 return; |
| 190 m_mainThreadLoader->cancel(); | 191 m_mainThreadLoader->cancel(); |
| 191 m_mainThreadLoader = nullptr; | 192 m_mainThreadLoader = nullptr; |
| 192 } | 193 } |
| 193 | 194 |
| 194 void WorkerThreadableLoader::MainThreadBridgeBase::cancel() | 195 void WorkerThreadableLoader::MainThreadBridgeBase::cancel() |
| 195 { | 196 { |
| 196 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCancel, crossThreadUnretained(this))); | 197 m_loaderProxy->postTaskToLoader(BLINK_FROM_HERE, createCrossThreadTask(&Main
ThreadBridgeBase::mainThreadCancel, crossThreadUnretained(this))); |
| 197 ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper; | 198 ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper; |
| 198 if (!clientWrapper->done()) { | 199 if (!clientWrapper->done()) { |
| 199 // If the client hasn't reached a termination state, then transition it | 200 // If the client hasn't reached a termination state, then transition it |
| 200 // by sending a cancellation error. | 201 // by sending a cancellation error. |
| 201 // Note: no more client callbacks will be done after this method -- the | 202 // Note: no more client callbacks will be done after this method -- the |
| 202 // m_workerClientWrapper->clearClient() call ensures that. | 203 // m_workerClientWrapper->clearClient() call ensures that. |
| 203 ResourceError error(String(), 0, String(), String()); | 204 ResourceError error(String(), 0, String(), String()); |
| 204 error.setIsCancellation(true); | 205 error.setIsCancellation(true); |
| 205 clientWrapper->didFail(error); | 206 clientWrapper->didFail(error); |
| 206 } | 207 } |
| 207 // |this| might be already destructed here because didFail() might | 208 // |this| might be already destructed here because didFail() might |
| 208 // clear a reference to ThreadableLoader, which might destruct | 209 // clear a reference to ThreadableLoader, which might destruct |
| 209 // WorkerThreadableLoader and then MainThreadBridge. | 210 // WorkerThreadableLoader and then MainThreadBridge. |
| 210 // Therefore we call clearClient() directly, rather than calling | 211 // Therefore we call clearClient() directly, rather than calling |
| 211 // this->m_workerClientWrapper->clearClient(). | 212 // this->m_workerClientWrapper->clearClient(). |
| 212 clientWrapper->clearClient(); | 213 clientWrapper->clearClient(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void WorkerThreadableLoader::MainThreadBridgeBase::didSendData(unsigned long lon
g bytesSent, unsigned long long totalBytesToBeSent) | 216 void WorkerThreadableLoader::MainThreadBridgeBase::didSendData(unsigned long lon
g bytesSent, unsigned long long totalBytesToBeSent) |
| 216 { | 217 { |
| 217 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dSendData, m_workerClientWrapper, bytesSent, totalBytesToBeSent)); | 218 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didSendData, m_workerClientWrapper, bytesSent, totalBytesToBeSent
)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveResponse(unsigned l
ong identifier, const ResourceResponse& response, std::unique_ptr<WebDataConsume
rHandle> handle) | 221 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveResponse(unsigned l
ong identifier, const ResourceResponse& response, std::unique_ptr<WebDataConsume
rHandle> handle) |
| 221 { | 222 { |
| 222 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dReceiveResponse, m_workerClientWrapper, identifier, response, passed(std::move(
handle)))); | 223 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didReceiveResponse, m_workerClientWrapper, identifier, response,
passed(std::move(handle)))); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveData(const char* da
ta, unsigned dataLength) | 226 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveData(const char* da
ta, unsigned dataLength) |
| 226 { | 227 { |
| 227 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dReceiveData, m_workerClientWrapper, passed(createVectorFromMemoryRegion(data, d
ataLength)))); | 228 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didReceiveData, m_workerClientWrapper, passed(createVectorFromMem
oryRegion(data, dataLength)))); |
| 228 } | 229 } |
| 229 | 230 |
| 230 void WorkerThreadableLoader::MainThreadBridgeBase::didDownloadData(int dataLengt
h) | 231 void WorkerThreadableLoader::MainThreadBridgeBase::didDownloadData(int dataLengt
h) |
| 231 { | 232 { |
| 232 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dDownloadData, m_workerClientWrapper, dataLength)); | 233 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didDownloadData, m_workerClientWrapper, dataLength)); |
| 233 } | 234 } |
| 234 | 235 |
| 235 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveCachedMetadata(cons
t char* data, int dataLength) | 236 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveCachedMetadata(cons
t char* data, int dataLength) |
| 236 { | 237 { |
| 237 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dReceiveCachedMetadata, m_workerClientWrapper, passed(createVectorFromMemoryRegi
on(data, dataLength)))); | 238 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didReceiveCachedMetadata, m_workerClientWrapper, passed(createVec
torFromMemoryRegion(data, dataLength)))); |
| 238 } | 239 } |
| 239 | 240 |
| 240 void WorkerThreadableLoader::MainThreadBridgeBase::didFinishLoading(unsigned lon
g identifier, double finishTime) | 241 void WorkerThreadableLoader::MainThreadBridgeBase::didFinishLoading(unsigned lon
g identifier, double finishTime) |
| 241 { | 242 { |
| 242 forwardTaskToWorkerOnLoaderDone(createCrossThreadTask(&ThreadableLoaderClien
tWrapper::didFinishLoading, m_workerClientWrapper, identifier, finishTime)); | 243 forwardTaskToWorkerOnLoaderDone(BLINK_FROM_HERE, createCrossThreadTask(&Thre
adableLoaderClientWrapper::didFinishLoading, m_workerClientWrapper, identifier,
finishTime)); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void WorkerThreadableLoader::MainThreadBridgeBase::didFail(const ResourceError&
error) | 246 void WorkerThreadableLoader::MainThreadBridgeBase::didFail(const ResourceError&
error) |
| 246 { | 247 { |
| 247 forwardTaskToWorkerOnLoaderDone(createCrossThreadTask(&ThreadableLoaderClien
tWrapper::didFail, m_workerClientWrapper, error)); | 248 forwardTaskToWorkerOnLoaderDone(BLINK_FROM_HERE, createCrossThreadTask(&Thre
adableLoaderClientWrapper::didFail, m_workerClientWrapper, error)); |
| 248 } | 249 } |
| 249 | 250 |
| 250 void WorkerThreadableLoader::MainThreadBridgeBase::didFailAccessControlCheck(con
st ResourceError& error) | 251 void WorkerThreadableLoader::MainThreadBridgeBase::didFailAccessControlCheck(con
st ResourceError& error) |
| 251 { | 252 { |
| 252 forwardTaskToWorkerOnLoaderDone(createCrossThreadTask(&ThreadableLoaderClien
tWrapper::didFailAccessControlCheck, m_workerClientWrapper, error)); | 253 forwardTaskToWorkerOnLoaderDone(BLINK_FROM_HERE, createCrossThreadTask(&Thre
adableLoaderClientWrapper::didFailAccessControlCheck, m_workerClientWrapper, err
or)); |
| 253 } | 254 } |
| 254 | 255 |
| 255 void WorkerThreadableLoader::MainThreadBridgeBase::didFailRedirectCheck() | 256 void WorkerThreadableLoader::MainThreadBridgeBase::didFailRedirectCheck() |
| 256 { | 257 { |
| 257 forwardTaskToWorkerOnLoaderDone(createCrossThreadTask(&ThreadableLoaderClien
tWrapper::didFailRedirectCheck, m_workerClientWrapper)); | 258 forwardTaskToWorkerOnLoaderDone(BLINK_FROM_HERE, createCrossThreadTask(&Thre
adableLoaderClientWrapper::didFailRedirectCheck, m_workerClientWrapper)); |
| 258 } | 259 } |
| 259 | 260 |
| 260 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveResourceTiming(cons
t ResourceTimingInfo& info) | 261 void WorkerThreadableLoader::MainThreadBridgeBase::didReceiveResourceTiming(cons
t ResourceTimingInfo& info) |
| 261 { | 262 { |
| 262 forwardTaskToWorker(createCrossThreadTask(&ThreadableLoaderClientWrapper::di
dReceiveResourceTiming, m_workerClientWrapper, info)); | 263 forwardTaskToWorker(BLINK_FROM_HERE, createCrossThreadTask(&ThreadableLoader
ClientWrapper::didReceiveResourceTiming, m_workerClientWrapper, info)); |
| 263 } | 264 } |
| 264 | 265 |
| 265 WorkerThreadableLoader::MainThreadAsyncBridge::MainThreadAsyncBridge( | 266 WorkerThreadableLoader::MainThreadAsyncBridge::MainThreadAsyncBridge( |
| 266 WorkerGlobalScope& workerGlobalScope, | 267 WorkerGlobalScope& workerGlobalScope, |
| 267 ThreadableLoaderClientWrapper* workerClientWrapper, | 268 ThreadableLoaderClientWrapper* workerClientWrapper, |
| 268 const ThreadableLoaderOptions& options, | 269 const ThreadableLoaderOptions& options, |
| 269 const ResourceLoaderOptions& resourceLoaderOptions) | 270 const ResourceLoaderOptions& resourceLoaderOptions) |
| 270 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) | 271 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) |
| 271 { | 272 { |
| 272 createLoaderInMainThread(options, resourceLoaderOptions); | 273 createLoaderInMainThread(options, resourceLoaderOptions); |
| 273 } | 274 } |
| 274 | 275 |
| 275 void WorkerThreadableLoader::MainThreadAsyncBridge::start(const ResourceRequest&
request, const WorkerGlobalScope& workerGlobalScope) | 276 void WorkerThreadableLoader::MainThreadAsyncBridge::start(const ResourceRequest&
request, const WorkerGlobalScope& workerGlobalScope) |
| 276 { | 277 { |
| 277 startInMainThread(request, workerGlobalScope); | 278 startInMainThread(request, workerGlobalScope); |
| 278 } | 279 } |
| 279 | 280 |
| 280 WorkerThreadableLoader::MainThreadAsyncBridge::~MainThreadAsyncBridge() | 281 WorkerThreadableLoader::MainThreadAsyncBridge::~MainThreadAsyncBridge() |
| 281 { | 282 { |
| 282 } | 283 } |
| 283 | 284 |
| 284 void WorkerThreadableLoader::MainThreadAsyncBridge::forwardTaskToWorker(std::uni
que_ptr<ExecutionContextTask> task) | 285 void WorkerThreadableLoader::MainThreadAsyncBridge::forwardTaskToWorker(const We
bTraceLocation& location, std::unique_ptr<ExecutionContextTask> task) |
| 285 { | 286 { |
| 286 loaderProxy()->postTaskToWorkerGlobalScope(std::move(task)); | 287 loaderProxy()->postTaskToWorkerGlobalScope(location, std::move(task)); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void WorkerThreadableLoader::MainThreadAsyncBridge::forwardTaskToWorkerOnLoaderD
one(std::unique_ptr<ExecutionContextTask> task) | 290 void WorkerThreadableLoader::MainThreadAsyncBridge::forwardTaskToWorkerOnLoaderD
one(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task
) |
| 290 { | 291 { |
| 291 loaderProxy()->postTaskToWorkerGlobalScope(std::move(task)); | 292 loaderProxy()->postTaskToWorkerGlobalScope(location, std::move(task)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 WorkerThreadableLoader::MainThreadSyncBridge::MainThreadSyncBridge( | 295 WorkerThreadableLoader::MainThreadSyncBridge::MainThreadSyncBridge( |
| 295 WorkerGlobalScope& workerGlobalScope, | 296 WorkerGlobalScope& workerGlobalScope, |
| 296 ThreadableLoaderClientWrapper* workerClientWrapper, | 297 ThreadableLoaderClientWrapper* workerClientWrapper, |
| 297 const ThreadableLoaderOptions& options, | 298 const ThreadableLoaderOptions& options, |
| 298 const ResourceLoaderOptions& resourceLoaderOptions) | 299 const ResourceLoaderOptions& resourceLoaderOptions) |
| 299 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) | 300 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) |
| 300 , m_done(false) | 301 , m_done(false) |
| 301 { | 302 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 321 } | 322 } |
| 322 // |signaledIndex| is 0; which is terminationEvent. | 323 // |signaledIndex| is 0; which is terminationEvent. |
| 323 if (signaledIndex == 0) { | 324 if (signaledIndex == 0) { |
| 324 cancel(); | 325 cancel(); |
| 325 return; | 326 return; |
| 326 } | 327 } |
| 327 | 328 |
| 328 // The following code must be run only after |m_loaderDoneEvent| is | 329 // The following code must be run only after |m_loaderDoneEvent| is |
| 329 // signalled. | 330 // signalled. |
| 330 | 331 |
| 331 Vector<std::unique_ptr<ExecutionContextTask>> tasks; | 332 Vector<ClientTask> tasks; |
| 332 { | 333 { |
| 333 MutexLocker lock(m_lock); | 334 MutexLocker lock(m_lock); |
| 334 ASSERT(m_done); | 335 ASSERT(m_done); |
| 335 m_clientTasks.swap(tasks); | 336 m_clientTasks.swap(tasks); |
| 336 } | 337 } |
| 337 for (const auto& task : tasks) { | 338 for (const auto& task : tasks) { |
| 339 // Store the program counter where the task is posted from, and alias |
| 340 // it to ensure it is stored in the crash dump. |
| 341 const void* programCounter = task.m_location.program_counter(); |
| 342 WTF::debug::alias(&programCounter); |
| 343 |
| 338 // m_clientTask contains only CallClosureTasks. So, it's ok to pass | 344 // m_clientTask contains only CallClosureTasks. So, it's ok to pass |
| 339 // the nullptr. | 345 // the nullptr. |
| 340 task->performTask(nullptr); | 346 task.m_task->performTask(nullptr); |
| 341 } | 347 } |
| 342 } | 348 } |
| 343 | 349 |
| 350 WorkerThreadableLoader::MainThreadSyncBridge::ClientTask::ClientTask(const WebTr
aceLocation& location, std::unique_ptr<ExecutionContextTask> task) |
| 351 : m_location(location) |
| 352 , m_task(std::move(task)) {} |
| 353 |
| 354 WorkerThreadableLoader::MainThreadSyncBridge::ClientTask::~ClientTask() = defaul
t; |
| 355 WorkerThreadableLoader::MainThreadSyncBridge::ClientTask::ClientTask(ClientTask&
&) = default; |
| 356 |
| 344 WorkerThreadableLoader::MainThreadSyncBridge::~MainThreadSyncBridge() | 357 WorkerThreadableLoader::MainThreadSyncBridge::~MainThreadSyncBridge() |
| 345 { | 358 { |
| 346 ASSERT(isMainThread()); | 359 ASSERT(isMainThread()); |
| 347 } | 360 } |
| 348 | 361 |
| 349 void WorkerThreadableLoader::MainThreadSyncBridge::forwardTaskToWorker(std::uniq
ue_ptr<ExecutionContextTask> task) | 362 void WorkerThreadableLoader::MainThreadSyncBridge::forwardTaskToWorker(const Web
TraceLocation& location, std::unique_ptr<ExecutionContextTask> task) |
| 350 { | 363 { |
| 351 ASSERT(isMainThread()); | 364 ASSERT(isMainThread()); |
| 352 | 365 |
| 353 MutexLocker lock(m_lock); | 366 MutexLocker lock(m_lock); |
| 354 RELEASE_ASSERT(!m_done); | 367 RELEASE_ASSERT(!m_done); |
| 355 | 368 |
| 356 m_clientTasks.append(std::move(task)); | 369 m_clientTasks.append(ClientTask(location, std::move(task))); |
| 357 } | 370 } |
| 358 | 371 |
| 359 void WorkerThreadableLoader::MainThreadSyncBridge::forwardTaskToWorkerOnLoaderDo
ne(std::unique_ptr<ExecutionContextTask> task) | 372 void WorkerThreadableLoader::MainThreadSyncBridge::forwardTaskToWorkerOnLoaderDo
ne(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task) |
| 360 { | 373 { |
| 361 ASSERT(isMainThread()); | 374 ASSERT(isMainThread()); |
| 362 | 375 |
| 363 MutexLocker lock(m_lock); | 376 MutexLocker lock(m_lock); |
| 364 RELEASE_ASSERT(!m_done); | 377 RELEASE_ASSERT(!m_done); |
| 365 | 378 |
| 366 m_clientTasks.append(std::move(task)); | 379 m_clientTasks.append(ClientTask(location, std::move(task))); |
| 367 m_done = true; | 380 m_done = true; |
| 368 m_loaderDoneEvent->signal(); | 381 m_loaderDoneEvent->signal(); |
| 369 } | 382 } |
| 370 | 383 |
| 371 } // namespace blink | 384 } // namespace blink |
| OLD | NEW |