Chromium Code Reviews| 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" | 7 #include "core/dom/ExecutionContextTask.h" |
| 8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
| 9 #include "core/fetch/ResourceLoaderOptions.h" | 9 #include "core/fetch/ResourceLoaderOptions.h" |
| 10 #include "core/loader/DocumentThreadableLoader.h" | 10 #include "core/loader/DocumentThreadableLoader.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 } | 249 } |
| 250 | 250 |
| 251 void onServeRequests() override | 251 void onServeRequests() override |
| 252 { | 252 { |
| 253 testing::runPendingTasks(); | 253 testing::runPendingTasks(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void onTearDown() override | 256 void onTearDown() override |
| 257 { | 257 { |
| 258 postTaskToWorkerGlobalScope(BLINK_FROM_HERE, createCrossThreadTask(&Work erThreadableLoaderTestHelper::clearLoader, crossThreadUnretained(this))); | 258 postTaskToWorkerGlobalScope(BLINK_FROM_HERE, createCrossThreadTask(&Work erThreadableLoaderTestHelper::clearLoader, crossThreadUnretained(this))); |
| 259 WaitableEvent event; | |
| 260 postTaskToWorkerGlobalScope(BLINK_FROM_HERE, createCrossThreadTask(&sign al, crossThreadUnretained(&event))); | |
| 261 event.wait(); | |
| 259 m_workerThread->terminateAndWait(); | 262 m_workerThread->terminateAndWait(); |
| 260 | 263 |
| 261 // Needed to clean up the things on the main thread side and | 264 // Needed to clean up the things on the main thread side and |
| 262 // avoid Resource leaks. | 265 // avoid Resource leaks. |
| 263 testing::runPendingTasks(); | 266 testing::runPendingTasks(); |
| 264 | 267 |
| 265 m_workerThread->workerLoaderProxy()->detachProvider(this); | 268 m_workerThread->workerLoaderProxy()->detachProvider(this); |
| 266 } | 269 } |
| 267 | 270 |
| 268 private: | 271 private: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 ASSERT(m_workerThread->isCurrentThread()); | 324 ASSERT(m_workerThread->isCurrentThread()); |
| 322 document().postTask(location, std::move(task)); | 325 document().postTask(location, std::move(task)); |
| 323 } | 326 } |
| 324 | 327 |
| 325 void postTaskToWorkerGlobalScope(const WebTraceLocation& location, std::uniq ue_ptr<ExecutionContextTask> task) override | 328 void postTaskToWorkerGlobalScope(const WebTraceLocation& location, std::uniq ue_ptr<ExecutionContextTask> task) override |
| 326 { | 329 { |
| 327 ASSERT(m_workerThread); | 330 ASSERT(m_workerThread); |
| 328 m_workerThread->postTask(location, std::move(task)); | 331 m_workerThread->postTask(location, std::move(task)); |
| 329 } | 332 } |
| 330 | 333 |
| 334 static void signal(WaitableEvent* event) | |
|
nhiroki
2016/09/06 05:06:40
We could remove this as follows?
postTaskToWorker
yhirano
2016/09/06 05:38:03
It's a good idea, thank you!
| |
| 335 { | |
| 336 event->signal(); | |
| 337 } | |
| 338 | |
| 331 RefPtr<SecurityOrigin> m_securityOrigin; | 339 RefPtr<SecurityOrigin> m_securityOrigin; |
| 332 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; | 340 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; |
| 333 std::unique_ptr<WorkerThreadForTest> m_workerThread; | 341 std::unique_ptr<WorkerThreadForTest> m_workerThread; |
| 334 | 342 |
| 335 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 343 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 336 Checkpoint m_checkpoint; | 344 Checkpoint m_checkpoint; |
| 337 // |m_loader| must be touched only from the worker thread only. | 345 // |m_loader| must be touched only from the worker thread only. |
| 338 CrossThreadPersistent<ThreadableLoader> m_loader; | 346 CrossThreadPersistent<ThreadableLoader> m_loader; |
| 339 }; | 347 }; |
| 340 | 348 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 // test is not saying that didFailAccessControlCheck should be dispatched | 876 // test is not saying that didFailAccessControlCheck should be dispatched |
| 869 // synchronously, but is saying that even when a response is served | 877 // synchronously, but is saying that even when a response is served |
| 870 // synchronously it should not lead to a crash. | 878 // synchronously it should not lead to a crash. |
| 871 startLoader(KURL(KURL(), "about:blank")); | 879 startLoader(KURL(KURL(), "about:blank")); |
| 872 callCheckpoint(2); | 880 callCheckpoint(2); |
| 873 } | 881 } |
| 874 | 882 |
| 875 } // namespace | 883 } // namespace |
| 876 | 884 |
| 877 } // namespace blink | 885 } // namespace blink |
| OLD | NEW |