| Index: third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp b/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..aa5500cdad53167e9cb31a905960b874975b4719
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/testing/CacheAwareFontDisplayTest.cpp
|
| @@ -0,0 +1,56 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "core/testing/CacheAwareFontDisplayTest.h"
|
| +
|
| +#include "core/dom/Document.h"
|
| +#include "core/fetch/FetchRequest.h"
|
| +#include "core/fetch/FontResource.h"
|
| +#include "core/fetch/ResourceFetcher.h"
|
| +#include "core/fetch/ResourceLoader.h"
|
| +#include "platform/CrossOriginAttributeValue.h"
|
| +
|
| +namespace blink {
|
| +
|
| +CacheAwareFontDisplayTest::CacheAwareFontDisplayTest(Document* document,
|
| + const String& fontUrl) {
|
| + FetchRequest fetchRequest(document->completeURL(fontUrl),
|
| + FetchInitiatorInfo());
|
| + fetchRequest.setCacheAwareLoadingEnabled(IsCacheAwareLoadingEnabled);
|
| + fetchRequest.setCrossOriginAccessControl(document->getSecurityOrigin(),
|
| + CrossOriginAttributeAnonymous);
|
| + m_fontResource = FontResource::fetch(fetchRequest, document->fetcher());
|
| + if (!m_fontResource)
|
| + return;
|
| + m_fontResource->m_isCallbackDisabledForTesting = true;
|
| + document->fetcher()->startLoad(m_fontResource);
|
| + DCHECK(m_fontResource->loader()->isCacheAwareLoadingActivated());
|
| + m_fontResource->m_loadLimitState = FontResource::UnderLimit;
|
| +}
|
| +
|
| +void CacheAwareFontDisplayTest::fontLoadShortLimitCallback() {
|
| + if (!m_fontResource)
|
| + return;
|
| + m_fontResource->fontLoadShortLimitCallback(nullptr);
|
| +}
|
| +
|
| +void CacheAwareFontDisplayTest::fontLoadLongLimitCallback() {
|
| + if (!m_fontResource)
|
| + return;
|
| + m_fontResource->fontLoadLongLimitCallback(nullptr);
|
| +}
|
| +
|
| +void CacheAwareFontDisplayTest::willReloadAfterDiskCacheMiss() {
|
| + if (!m_fontResource)
|
| + return;
|
| + DCHECK(m_fontResource->m_isCallbackDisabledForTesting);
|
| + m_fontResource->m_isCallbackDisabledForTesting = false;
|
| + m_fontResource->willReloadAfterDiskCacheMiss();
|
| +}
|
| +
|
| +DEFINE_TRACE(CacheAwareFontDisplayTest) {
|
| + visitor->trace(m_fontResource);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|