Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: third_party/WebKit/Source/platform/loader/fetch/MockFetchContext.h

Issue 2718943003: mv FetchTestingPlatformSupport to platform/loader/testing (Closed)
Patch Set: MCTest fix Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/loader/fetch/MockFetchContext.h
diff --git a/third_party/WebKit/Source/platform/loader/fetch/MockFetchContext.h b/third_party/WebKit/Source/platform/loader/fetch/MockFetchContext.h
deleted file mode 100644
index b3b6b326ee58de8c3e3ca5a612b18e3a092c3038..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/platform/loader/fetch/MockFetchContext.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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.
-
-#ifndef MockFetchContext_h
-#define MockFetchContext_h
-
-#include "platform/loader/fetch/FetchContext.h"
-#include "platform/loader/fetch/FetchRequest.h"
-#include "platform/network/ResourceTimingInfo.h"
-#include "platform/scheduler/test/fake_web_task_runner.h"
-#include "wtf/PtrUtil.h"
-
-#include <memory>
-
-namespace blink {
-
-class KURL;
-class ResourceRequest;
-class WebTaskRunner;
-struct ResourceLoaderOptions;
-
-// Mocked FetchContext for testing.
-class MockFetchContext : public FetchContext {
- public:
- enum LoadPolicy {
- kShouldLoadNewResource,
- kShouldNotLoadNewResource,
- };
- // TODO(toyoshim): Disallow to pass nullptr for |taskRunner|, and force to use
- // FetchTestingPlatformSupport's WebTaskRunner. Probably, MockFetchContext
- // would be available only through the FetchTestingPlatformSupport in the
- // future.
- static MockFetchContext* create(LoadPolicy loadPolicy,
- RefPtr<WebTaskRunner> taskRunner = nullptr) {
- return new MockFetchContext(loadPolicy, std::move(taskRunner));
- }
-
- ~MockFetchContext() override {}
-
- void setCachePolicy(CachePolicy policy) { m_policy = policy; }
- void setLoadComplete(bool complete) { m_complete = complete; }
- long long getTransferSize() const { return m_transferSize; }
-
- // FetchContext:
- bool allowImage(bool imagesEnabled, const KURL&) const override {
- return true;
- }
- ResourceRequestBlockedReason canRequest(
- Resource::Type,
- const ResourceRequest&,
- const KURL&,
- const ResourceLoaderOptions&,
- SecurityViolationReportingPolicy,
- FetchRequest::OriginRestriction) const override {
- return ResourceRequestBlockedReason::None;
- }
- bool shouldLoadNewResource(Resource::Type) const override {
- return m_loadPolicy == kShouldLoadNewResource;
- }
- RefPtr<WebTaskRunner> loadingTaskRunner() const override { return m_runner; }
- CachePolicy getCachePolicy() const override { return m_policy; }
- bool isLoadComplete() const override { return m_complete; }
- void addResourceTiming(
- const ResourceTimingInfo& resourceTimingInfo) override {
- m_transferSize = resourceTimingInfo.transferSize();
- }
-
- private:
- MockFetchContext(LoadPolicy loadPolicy, RefPtr<WebTaskRunner> taskRunner)
- : m_loadPolicy(loadPolicy),
- m_policy(CachePolicyVerify),
- m_runner(taskRunner ? std::move(taskRunner)
- : adoptRef(new scheduler::FakeWebTaskRunner)),
- m_complete(false),
- m_transferSize(-1) {}
-
- enum LoadPolicy m_loadPolicy;
- CachePolicy m_policy;
- RefPtr<WebTaskRunner> m_runner;
- bool m_complete;
- long long m_transferSize;
-};
-
-} // namespace blink
-
-#endif

Powered by Google App Engine
This is Rietveld 408576698