| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/loader/ThreadableLoader.h" | 5 #include "core/loader/ThreadableLoader.h" |
| 6 | 6 |
| 7 #include "core/dom/ExecutionContextTask.h" | |
| 8 #include "core/loader/DocumentThreadableLoader.h" | 7 #include "core/loader/DocumentThreadableLoader.h" |
| 9 #include "core/loader/ThreadableLoaderClient.h" | 8 #include "core/loader/ThreadableLoaderClient.h" |
| 10 #include "core/loader/WorkerThreadableLoader.h" | 9 #include "core/loader/WorkerThreadableLoader.h" |
| 11 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 12 #include "core/workers/WorkerLoaderProxy.h" | 11 #include "core/workers/WorkerLoaderProxy.h" |
| 13 #include "core/workers/WorkerThreadTestHelper.h" | 12 #include "core/workers/WorkerThreadTestHelper.h" |
| 14 #include "platform/WaitableEvent.h" | 13 #include "platform/WaitableEvent.h" |
| 15 #include "platform/geometry/IntSize.h" | 14 #include "platform/geometry/IntSize.h" |
| 16 #include "platform/loader/fetch/MemoryCache.h" | 15 #include "platform/loader/fetch/MemoryCache.h" |
| 17 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 16 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 317 } |
| 319 | 318 |
| 320 void workerCallCheckpoint(WaitableEvent* event, int n) { | 319 void workerCallCheckpoint(WaitableEvent* event, int n) { |
| 321 DCHECK(m_workerThread); | 320 DCHECK(m_workerThread); |
| 322 DCHECK(m_workerThread->isCurrentThread()); | 321 DCHECK(m_workerThread->isCurrentThread()); |
| 323 m_checkpoint.Call(n); | 322 m_checkpoint.Call(n); |
| 324 event->signal(); | 323 event->signal(); |
| 325 } | 324 } |
| 326 | 325 |
| 327 // WorkerLoaderProxyProvider methods. | 326 // WorkerLoaderProxyProvider methods. |
| 328 void postTaskToLoader(const WebTraceLocation& location, | 327 void postTaskToLoader( |
| 329 std::unique_ptr<ExecutionContextTask> task) override { | 328 const WebTraceLocation& location, |
| 329 std::unique_ptr<WTF::CrossThreadClosure> task) override { |
| 330 DCHECK(m_workerThread); | 330 DCHECK(m_workerThread); |
| 331 DCHECK(m_workerThread->isCurrentThread()); | 331 DCHECK(m_workerThread->isCurrentThread()); |
| 332 m_parentFrameTaskRunners->get(TaskType::Networking) | 332 m_parentFrameTaskRunners->get(TaskType::Networking) |
| 333 ->postTask( | 333 ->postTask(BLINK_FROM_HERE, std::move(task)); |
| 334 BLINK_FROM_HERE, | |
| 335 crossThreadBind(&ExecutionContextTask::performTaskIfContextIsValid, | |
| 336 WTF::passed(std::move(task)), | |
| 337 wrapCrossThreadWeakPersistent(&document()))); | |
| 338 } | 334 } |
| 339 | 335 |
| 340 void postTaskToWorkerGlobalScope( | 336 void postTaskToWorkerGlobalScope( |
| 341 const WebTraceLocation& location, | 337 const WebTraceLocation& location, |
| 342 std::unique_ptr<WTF::CrossThreadClosure> task) override { | 338 std::unique_ptr<WTF::CrossThreadClosure> task) override { |
| 343 DCHECK(m_workerThread); | 339 DCHECK(m_workerThread); |
| 344 m_workerThread->postTask(location, std::move(task)); | 340 m_workerThread->postTask(location, std::move(task)); |
| 345 } | 341 } |
| 346 | 342 |
| 343 ExecutionContext* getLoaderExecutionContext() override { return &document(); } |
| 344 |
| 347 RefPtr<SecurityOrigin> m_securityOrigin; | 345 RefPtr<SecurityOrigin> m_securityOrigin; |
| 348 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; | 346 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; |
| 349 std::unique_ptr<WorkerThreadForTest> m_workerThread; | 347 std::unique_ptr<WorkerThreadForTest> m_workerThread; |
| 350 | 348 |
| 351 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 349 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 352 // Accessed cross-thread when worker thread posts tasks to the parent. | 350 // Accessed cross-thread when worker thread posts tasks to the parent. |
| 353 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; | 351 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; |
| 354 Checkpoint m_checkpoint; | 352 Checkpoint m_checkpoint; |
| 355 // |m_loader| must be touched only from the worker thread only. | 353 // |m_loader| must be touched only from the worker thread only. |
| 356 CrossThreadPersistent<ThreadableLoader> m_loader; | 354 CrossThreadPersistent<ThreadableLoader> m_loader; |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 // test is not saying that didFailAccessControlCheck should be dispatched | 882 // test is not saying that didFailAccessControlCheck should be dispatched |
| 885 // synchronously, but is saying that even when a response is served | 883 // synchronously, but is saying that even when a response is served |
| 886 // synchronously it should not lead to a crash. | 884 // synchronously it should not lead to a crash. |
| 887 startLoader(KURL(KURL(), "about:blank")); | 885 startLoader(KURL(KURL(), "about:blank")); |
| 888 callCheckpoint(2); | 886 callCheckpoint(2); |
| 889 } | 887 } |
| 890 | 888 |
| 891 } // namespace | 889 } // namespace |
| 892 | 890 |
| 893 } // namespace blink | 891 } // namespace blink |
| OLD | NEW |