| 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/CrossThreadTask.h" | 7 #include "core/dom/CrossThreadTask.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 m_loader->cancel(); | 150 m_loader->cancel(); |
| 151 m_loader = nullptr; | 151 m_loader = nullptr; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 Document& document() { return m_dummyPageHolder->document(); } | 156 Document& document() { return m_dummyPageHolder->document(); } |
| 157 | 157 |
| 158 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 158 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 159 Checkpoint m_checkpoint; | 159 Checkpoint m_checkpoint; |
| 160 std::unique_ptr<DocumentThreadableLoader> m_loader; | 160 Persistent<DocumentThreadableLoader> m_loader; |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 class WorkerThreadableLoaderTestHelper : public ThreadableLoaderTestHelper, publ
ic WorkerLoaderProxyProvider { | 163 class WorkerThreadableLoaderTestHelper : public ThreadableLoaderTestHelper, publ
ic WorkerLoaderProxyProvider { |
| 164 public: | 164 public: |
| 165 WorkerThreadableLoaderTestHelper() | 165 WorkerThreadableLoaderTestHelper() |
| 166 : m_dummyPageHolder(DummyPageHolder::create(IntSize(1, 1))) | 166 : m_dummyPageHolder(DummyPageHolder::create(IntSize(1, 1))) |
| 167 { | 167 { |
| 168 } | 168 } |
| 169 | 169 |
| 170 void createLoader(ThreadableLoaderClient* client, CrossOriginRequestPolicy c
rossOriginRequestPolicy) override | 170 void createLoader(ThreadableLoaderClient* client, CrossOriginRequestPolicy c
rossOriginRequestPolicy) override |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 DCHECK(m_workerThread->isCurrentThread()); | 204 DCHECK(m_workerThread->isCurrentThread()); |
| 205 m_loader->cancel(); | 205 m_loader->cancel(); |
| 206 m_loader = nullptr; | 206 m_loader = nullptr; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Must be called on the worker thread. | 209 // Must be called on the worker thread. |
| 210 void clearLoader() override | 210 void clearLoader() override |
| 211 { | 211 { |
| 212 ASSERT(m_workerThread); | 212 ASSERT(m_workerThread); |
| 213 ASSERT(m_workerThread->isCurrentThread()); | 213 ASSERT(m_workerThread->isCurrentThread()); |
| 214 m_loader.reset(); | 214 m_loader = nullptr; |
| 215 } | 215 } |
| 216 | 216 |
| 217 Checkpoint& checkpoint() override | 217 Checkpoint& checkpoint() override |
| 218 { | 218 { |
| 219 return m_checkpoint; | 219 return m_checkpoint; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void callCheckpoint(int n) override | 222 void callCheckpoint(int n) override |
| 223 { | 223 { |
| 224 testing::runPendingTasks(); | 224 testing::runPendingTasks(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 return true; | 326 return true; |
| 327 } | 327 } |
| 328 | 328 |
| 329 RefPtr<SecurityOrigin> m_securityOrigin; | 329 RefPtr<SecurityOrigin> m_securityOrigin; |
| 330 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; | 330 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; |
| 331 std::unique_ptr<WorkerThreadForTest> m_workerThread; | 331 std::unique_ptr<WorkerThreadForTest> m_workerThread; |
| 332 | 332 |
| 333 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 333 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
| 334 Checkpoint m_checkpoint; | 334 Checkpoint m_checkpoint; |
| 335 // |m_loader| must be touched only from the worker thread only. | 335 // |m_loader| must be touched only from the worker thread only. |
| 336 std::unique_ptr<ThreadableLoader> m_loader; | 336 CrossThreadPersistent<ThreadableLoader> m_loader; |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 class ThreadableLoaderTest : public ::testing::TestWithParam<ThreadableLoaderToT
est> { | 339 class ThreadableLoaderTest : public ::testing::TestWithParam<ThreadableLoaderToT
est> { |
| 340 public: | 340 public: |
| 341 ThreadableLoaderTest() | 341 ThreadableLoaderTest() |
| 342 { | 342 { |
| 343 switch (GetParam()) { | 343 switch (GetParam()) { |
| 344 case DocumentThreadableLoaderTest: | 344 case DocumentThreadableLoaderTest: |
| 345 m_helper = wrapUnique(new DocumentThreadableLoaderTestHelper); | 345 m_helper = wrapUnique(new DocumentThreadableLoaderTestHelper); |
| 346 break; | 346 break; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 846 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
| 847 | 847 |
| 848 startLoader(redirectLoopURL()); | 848 startLoader(redirectLoopURL()); |
| 849 callCheckpoint(2); | 849 callCheckpoint(2); |
| 850 serveRequests(); | 850 serveRequests(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 } // namespace | 853 } // namespace |
| 854 | 854 |
| 855 } // namespace blink | 855 } // namespace blink |
| OLD | NEW |