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

Side by Side Diff: third_party/WebKit/Source/platform/loader/testing/MockFetchContext.h

Issue 2714383003: Reduce FetchContext::getCachePolicy() callers (Closed)
Patch Set: rebase Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MockFetchContext_h 5 #ifndef MockFetchContext_h
6 #define MockFetchContext_h 6 #define MockFetchContext_h
7 7
8 #include "platform/loader/fetch/FetchContext.h" 8 #include "platform/loader/fetch/FetchContext.h"
9 #include "platform/loader/fetch/FetchRequest.h" 9 #include "platform/loader/fetch/FetchRequest.h"
10 #include "platform/network/ResourceTimingInfo.h" 10 #include "platform/network/ResourceTimingInfo.h"
(...skipping 20 matching lines...) Expand all
31 // FetchTestingPlatformSupport's WebTaskRunner. Probably, MockFetchContext 31 // FetchTestingPlatformSupport's WebTaskRunner. Probably, MockFetchContext
32 // would be available only through the FetchTestingPlatformSupport in the 32 // would be available only through the FetchTestingPlatformSupport in the
33 // future. 33 // future.
34 static MockFetchContext* create(LoadPolicy loadPolicy, 34 static MockFetchContext* create(LoadPolicy loadPolicy,
35 RefPtr<WebTaskRunner> taskRunner = nullptr) { 35 RefPtr<WebTaskRunner> taskRunner = nullptr) {
36 return new MockFetchContext(loadPolicy, std::move(taskRunner)); 36 return new MockFetchContext(loadPolicy, std::move(taskRunner));
37 } 37 }
38 38
39 ~MockFetchContext() override {} 39 ~MockFetchContext() override {}
40 40
41 void setCachePolicy(CachePolicy policy) { m_policy = policy; }
42 void setLoadComplete(bool complete) { m_complete = complete; } 41 void setLoadComplete(bool complete) { m_complete = complete; }
43 long long getTransferSize() const { return m_transferSize; } 42 long long getTransferSize() const { return m_transferSize; }
44 43
45 // FetchContext: 44 // FetchContext:
46 bool allowImage(bool imagesEnabled, const KURL&) const override { 45 bool allowImage(bool imagesEnabled, const KURL&) const override {
47 return true; 46 return true;
48 } 47 }
49 ResourceRequestBlockedReason canRequest( 48 ResourceRequestBlockedReason canRequest(
50 Resource::Type, 49 Resource::Type,
51 const ResourceRequest&, 50 const ResourceRequest&,
52 const KURL&, 51 const KURL&,
53 const ResourceLoaderOptions&, 52 const ResourceLoaderOptions&,
54 SecurityViolationReportingPolicy, 53 SecurityViolationReportingPolicy,
55 FetchRequest::OriginRestriction) const override { 54 FetchRequest::OriginRestriction) const override {
56 return ResourceRequestBlockedReason::None; 55 return ResourceRequestBlockedReason::None;
57 } 56 }
58 bool shouldLoadNewResource(Resource::Type) const override { 57 bool shouldLoadNewResource(Resource::Type) const override {
59 return m_loadPolicy == kShouldLoadNewResource; 58 return m_loadPolicy == kShouldLoadNewResource;
60 } 59 }
61 RefPtr<WebTaskRunner> loadingTaskRunner() const override { return m_runner; } 60 RefPtr<WebTaskRunner> loadingTaskRunner() const override { return m_runner; }
62 CachePolicy getCachePolicy() const override { return m_policy; }
63 bool isLoadComplete() const override { return m_complete; } 61 bool isLoadComplete() const override { return m_complete; }
64 void addResourceTiming( 62 void addResourceTiming(
65 const ResourceTimingInfo& resourceTimingInfo) override { 63 const ResourceTimingInfo& resourceTimingInfo) override {
66 m_transferSize = resourceTimingInfo.transferSize(); 64 m_transferSize = resourceTimingInfo.transferSize();
67 } 65 }
68 66
69 private: 67 private:
70 MockFetchContext(LoadPolicy loadPolicy, RefPtr<WebTaskRunner> taskRunner) 68 MockFetchContext(LoadPolicy loadPolicy, RefPtr<WebTaskRunner> taskRunner)
71 : m_loadPolicy(loadPolicy), 69 : m_loadPolicy(loadPolicy),
72 m_policy(CachePolicyVerify),
73 m_runner(taskRunner ? std::move(taskRunner) 70 m_runner(taskRunner ? std::move(taskRunner)
74 : adoptRef(new scheduler::FakeWebTaskRunner)), 71 : adoptRef(new scheduler::FakeWebTaskRunner)),
75 m_complete(false), 72 m_complete(false),
76 m_transferSize(-1) {} 73 m_transferSize(-1) {}
77 74
78 enum LoadPolicy m_loadPolicy; 75 enum LoadPolicy m_loadPolicy;
79 CachePolicy m_policy;
80 RefPtr<WebTaskRunner> m_runner; 76 RefPtr<WebTaskRunner> m_runner;
81 bool m_complete; 77 bool m_complete;
82 long long m_transferSize; 78 long long m_transferSize;
83 }; 79 };
84 80
85 } // namespace blink 81 } // namespace blink
86 82
87 #endif 83 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698