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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 DCHECK(m_workerThread->isCurrentThread()); | 206 DCHECK(m_workerThread->isCurrentThread()); |
207 m_loader->cancel(); | 207 m_loader->cancel(); |
208 m_loader = nullptr; | 208 m_loader = nullptr; |
209 } | 209 } |
210 | 210 |
211 // Must be called on the worker thread. | 211 // Must be called on the worker thread. |
212 void clearLoader() override | 212 void clearLoader() override |
213 { | 213 { |
214 ASSERT(m_workerThread); | 214 ASSERT(m_workerThread); |
215 ASSERT(m_workerThread->isCurrentThread()); | 215 ASSERT(m_workerThread->isCurrentThread()); |
216 m_loader.reset(); | 216 m_loader = nullptr; |
217 } | 217 } |
218 | 218 |
219 Checkpoint& checkpoint() override | 219 Checkpoint& checkpoint() override |
220 { | 220 { |
221 return m_checkpoint; | 221 return m_checkpoint; |
222 } | 222 } |
223 | 223 |
224 void callCheckpoint(int n) override | 224 void callCheckpoint(int n) override |
225 { | 225 { |
226 testing::runPendingTasks(); | 226 testing::runPendingTasks(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return true; | 329 return true; |
330 } | 330 } |
331 | 331 |
332 RefPtr<SecurityOrigin> m_securityOrigin; | 332 RefPtr<SecurityOrigin> m_securityOrigin; |
333 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; | 333 std::unique_ptr<MockWorkerReportingProxy> m_mockWorkerReportingProxy; |
334 std::unique_ptr<WorkerThreadForTest> m_workerThread; | 334 std::unique_ptr<WorkerThreadForTest> m_workerThread; |
335 | 335 |
336 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 336 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
337 Checkpoint m_checkpoint; | 337 Checkpoint m_checkpoint; |
338 // |m_loader| must be touched only from the worker thread only. | 338 // |m_loader| must be touched only from the worker thread only. |
339 std::unique_ptr<ThreadableLoader> m_loader; | 339 CrossThreadPersistent<ThreadableLoader> m_loader; |
340 }; | 340 }; |
341 | 341 |
342 class ThreadableLoaderTest : public ::testing::TestWithParam<ThreadableLoaderToT
est> { | 342 class ThreadableLoaderTest : public ::testing::TestWithParam<ThreadableLoaderToT
est> { |
343 public: | 343 public: |
344 ThreadableLoaderTest() | 344 ThreadableLoaderTest() |
345 { | 345 { |
346 switch (GetParam()) { | 346 switch (GetParam()) { |
347 case DocumentThreadableLoaderTest: | 347 case DocumentThreadableLoaderTest: |
348 m_helper = wrapUnique(new DocumentThreadableLoaderTestHelper); | 348 m_helper = wrapUnique(new DocumentThreadableLoaderTestHelper); |
349 break; | 349 break; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 849 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
850 | 850 |
851 startLoader(redirectLoopURL()); | 851 startLoader(redirectLoopURL()); |
852 callCheckpoint(2); | 852 callCheckpoint(2); |
853 serveRequests(); | 853 serveRequests(); |
854 } | 854 } |
855 | 855 |
856 } // namespace | 856 } // namespace |
857 | 857 |
858 } // namespace blink | 858 } // namespace blink |
OLD | NEW |