| 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/resource/FontResource.h" | 5 #include "core/loader/resource/FontResource.h" |
| 6 | 6 |
| 7 #include "core/fetch/FetchInitiatorInfo.h" | 7 #include "core/fetch/FetchInitiatorInfo.h" |
| 8 #include "core/fetch/FetchRequest.h" | 8 #include "core/fetch/FetchRequest.h" |
| 9 #include "core/fetch/MemoryCache.h" | 9 #include "core/fetch/MemoryCache.h" |
| 10 #include "core/fetch/MockFetchContext.h" | 10 #include "core/fetch/MockFetchContext.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 new MockFontResourceClient(resource); | 105 new MockFontResourceClient(resource); |
| 106 fetcher->startLoad(resource); | 106 fetcher->startLoad(resource); |
| 107 EXPECT_TRUE(resource->loader()->isCacheAwareLoadingActivated()); | 107 EXPECT_TRUE(resource->loader()->isCacheAwareLoadingActivated()); |
| 108 resource->m_loadLimitState = FontResource::UnderLimit; | 108 resource->m_loadLimitState = FontResource::UnderLimit; |
| 109 | 109 |
| 110 // FontResource callbacks should be blocked during cache-aware loading. | 110 // FontResource callbacks should be blocked during cache-aware loading. |
| 111 resource->fontLoadShortLimitCallback(nullptr); | 111 resource->fontLoadShortLimitCallback(nullptr); |
| 112 EXPECT_FALSE(client->fontLoadShortLimitExceededCalled()); | 112 EXPECT_FALSE(client->fontLoadShortLimitExceededCalled()); |
| 113 | 113 |
| 114 // Fail first request as disk cache miss. | 114 // Fail first request as disk cache miss. |
| 115 resource->loader()->didFail(ResourceError::cacheMissError(url)); | 115 resource->loader()->handleError(ResourceError::cacheMissError(url)); |
| 116 | 116 |
| 117 // Once cache miss error returns, previously blocked callbacks should be | 117 // Once cache miss error returns, previously blocked callbacks should be |
| 118 // called immediately. | 118 // called immediately. |
| 119 EXPECT_FALSE(resource->loader()->isCacheAwareLoadingActivated()); | 119 EXPECT_FALSE(resource->loader()->isCacheAwareLoadingActivated()); |
| 120 EXPECT_TRUE(client->fontLoadShortLimitExceededCalled()); | 120 EXPECT_TRUE(client->fontLoadShortLimitExceededCalled()); |
| 121 EXPECT_FALSE(client->fontLoadLongLimitExceededCalled()); | 121 EXPECT_FALSE(client->fontLoadLongLimitExceededCalled()); |
| 122 | 122 |
| 123 // Add client now, fontLoadShortLimitExceeded() should be called. | 123 // Add client now, fontLoadShortLimitExceeded() should be called. |
| 124 Persistent<MockFontResourceClient> client2 = | 124 Persistent<MockFontResourceClient> client2 = |
| 125 new MockFontResourceClient(resource); | 125 new MockFontResourceClient(resource); |
| 126 EXPECT_TRUE(client2->fontLoadShortLimitExceededCalled()); | 126 EXPECT_TRUE(client2->fontLoadShortLimitExceededCalled()); |
| 127 EXPECT_FALSE(client2->fontLoadLongLimitExceededCalled()); | 127 EXPECT_FALSE(client2->fontLoadLongLimitExceededCalled()); |
| 128 | 128 |
| 129 // FontResource callbacks are not blocked now. | 129 // FontResource callbacks are not blocked now. |
| 130 resource->fontLoadLongLimitCallback(nullptr); | 130 resource->fontLoadLongLimitCallback(nullptr); |
| 131 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled()); | 131 EXPECT_TRUE(client->fontLoadLongLimitExceededCalled()); |
| 132 | 132 |
| 133 // Add client now, both callbacks should be called. | 133 // Add client now, both callbacks should be called. |
| 134 Persistent<MockFontResourceClient> client3 = | 134 Persistent<MockFontResourceClient> client3 = |
| 135 new MockFontResourceClient(resource); | 135 new MockFontResourceClient(resource); |
| 136 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled()); | 136 EXPECT_TRUE(client3->fontLoadShortLimitExceededCalled()); |
| 137 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled()); | 137 EXPECT_TRUE(client3->fontLoadLongLimitExceededCalled()); |
| 138 | 138 |
| 139 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); | 139 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequests(); |
| 140 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); | 140 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); |
| 141 memoryCache()->remove(resource); | 141 memoryCache()->remove(resource); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace blink | 144 } // namespace blink |
| OLD | NEW |