| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ResourceLoaderOptions resourceLoaderOptions; | 119 ResourceLoaderOptions resourceLoaderOptions; |
| 120 m_loader = DocumentThreadableLoader::create(document(), client, options,
resourceLoaderOptions); | 120 m_loader = DocumentThreadableLoader::create(document(), client, options,
resourceLoaderOptions); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void startLoader(const ResourceRequest& request) override | 123 void startLoader(const ResourceRequest& request) override |
| 124 { | 124 { |
| 125 m_loader->start(request); | 125 m_loader->start(request); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void cancelLoader() override { m_loader->cancel(); } | 128 void cancelLoader() override { m_loader->cancel(); } |
| 129 void clearLoader() override { m_loader.clear(); } | 129 void clearLoader() override { m_loader.reset(); } |
| 130 Checkpoint& checkpoint() override { return m_checkpoint; } | 130 Checkpoint& checkpoint() override { return m_checkpoint; } |
| 131 void callCheckpoint(int n) override { m_checkpoint.Call(n); } | 131 void callCheckpoint(int n) override { m_checkpoint.Call(n); } |
| 132 | 132 |
| 133 void onSetUp() override | 133 void onSetUp() override |
| 134 { | 134 { |
| 135 } | 135 } |
| 136 | 136 |
| 137 void onServeRequests() override | 137 void onServeRequests() override |
| 138 { | 138 { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void onTearDown() override | 141 void onTearDown() override |
| 142 { | 142 { |
| 143 m_loader.clear(); | 143 m_loader.reset(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 Document& document() { return m_dummyPageHolder->document(); } | 147 Document& document() { return m_dummyPageHolder->document(); } |
| 148 | 148 |
| 149 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 149 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| 150 Checkpoint m_checkpoint; | 150 Checkpoint m_checkpoint; |
| 151 OwnPtr<DocumentThreadableLoader> m_loader; | 151 OwnPtr<DocumentThreadableLoader> m_loader; |
| 152 }; | 152 }; |
| 153 | 153 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 ASSERT(m_workerThread); | 187 ASSERT(m_workerThread); |
| 188 ASSERT(m_workerThread->isCurrentThread()); | 188 ASSERT(m_workerThread->isCurrentThread()); |
| 189 m_loader->cancel(); | 189 m_loader->cancel(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Must be called on the worker thread. | 192 // Must be called on the worker thread. |
| 193 void clearLoader() override | 193 void clearLoader() override |
| 194 { | 194 { |
| 195 ASSERT(m_workerThread); | 195 ASSERT(m_workerThread); |
| 196 ASSERT(m_workerThread->isCurrentThread()); | 196 ASSERT(m_workerThread->isCurrentThread()); |
| 197 m_loader.clear(); | 197 m_loader.reset(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 Checkpoint& checkpoint() override | 200 Checkpoint& checkpoint() override |
| 201 { | 201 { |
| 202 return m_checkpoint; | 202 return m_checkpoint; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void callCheckpoint(int n) override | 205 void callCheckpoint(int n) override |
| 206 { | 206 { |
| 207 testing::runPendingTasks(); | 207 testing::runPendingTasks(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 368 |
| 369 m_client = MockThreadableLoaderClient::create(); | 369 m_client = MockThreadableLoaderClient::create(); |
| 370 m_helper->onSetUp(); | 370 m_helper->onSetUp(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void TearDown() override | 373 void TearDown() override |
| 374 { | 374 { |
| 375 m_helper->onTearDown(); | 375 m_helper->onTearDown(); |
| 376 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 376 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 377 memoryCache()->evictResources(); | 377 memoryCache()->evictResources(); |
| 378 m_client.clear(); | 378 m_client.reset(); |
| 379 } | 379 } |
| 380 | 380 |
| 381 void setUpSuccessURL() | 381 void setUpSuccessURL() |
| 382 { | 382 { |
| 383 URLTestHelpers::registerMockedURLLoad(successURL(), "fox-null-terminated
.html", "text/html"); | 383 URLTestHelpers::registerMockedURLLoad(successURL(), "fox-null-terminated
.html", "text/html"); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void setUpErrorURL() | 386 void setUpErrorURL() |
| 387 { | 387 { |
| 388 URLTestHelpers::registerMockedErrorURLLoad(errorURL()); | 388 URLTestHelpers::registerMockedErrorURLLoad(errorURL()); |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); | 833 EXPECT_CALL(*client(), didFailRedirectCheck()).WillOnce(InvokeWithoutArgs(th
is, &ThreadableLoaderTest::clearLoader)); |
| 834 | 834 |
| 835 startLoader(redirectLoopURL()); | 835 startLoader(redirectLoopURL()); |
| 836 callCheckpoint(2); | 836 callCheckpoint(2); |
| 837 serveRequests(); | 837 serveRequests(); |
| 838 } | 838 } |
| 839 | 839 |
| 840 } // namespace | 840 } // namespace |
| 841 | 841 |
| 842 } // namespace blink | 842 } // namespace blink |
| OLD | NEW |