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

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

Issue 2872403003: Have ResourceLoader use FetchContext::CreateURLLoader (Closed)
Patch Set: fix Created 3 years, 7 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/ResourceLoader.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/FetchParameters.h" 9 #include "platform/loader/fetch/FetchParameters.h"
10 #include "platform/loader/fetch/ResourceTimingInfo.h" 10 #include "platform/loader/fetch/ResourceTimingInfo.h"
11 #include "platform/scheduler/test/fake_web_task_runner.h" 11 #include "platform/scheduler/test/fake_web_task_runner.h"
12 #include "platform/wtf/PtrUtil.h" 12 #include "platform/wtf/PtrUtil.h"
13 #include "public/platform/Platform.h"
13 14
14 #include <memory> 15 #include <memory>
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class KURL; 19 class KURL;
19 class ResourceRequest; 20 class ResourceRequest;
20 class WebTaskRunner; 21 class WebTaskRunner;
21 struct ResourceLoaderOptions; 22 struct ResourceLoaderOptions;
22 23
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool ShouldLoadNewResource(Resource::Type) const override { 68 bool ShouldLoadNewResource(Resource::Type) const override {
68 return load_policy_ == kShouldLoadNewResource; 69 return load_policy_ == kShouldLoadNewResource;
69 } 70 }
70 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; } 71 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; }
71 bool IsLoadComplete() const override { return complete_; } 72 bool IsLoadComplete() const override { return complete_; }
72 void AddResourceTiming( 73 void AddResourceTiming(
73 const ResourceTimingInfo& resource_timing_info) override { 74 const ResourceTimingInfo& resource_timing_info) override {
74 transfer_size_ = resource_timing_info.TransferSize(); 75 transfer_size_ = resource_timing_info.TransferSize();
75 } 76 }
76 77
78 std::unique_ptr<WebURLLoader> CreateURLLoader() override {
79 return Platform::Current()->CreateURLLoader();
80 }
81
77 private: 82 private:
78 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner) 83 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner)
79 : load_policy_(load_policy), 84 : load_policy_(load_policy),
80 runner_(task_runner ? std::move(task_runner) 85 runner_(task_runner ? std::move(task_runner)
81 : AdoptRef(new scheduler::FakeWebTaskRunner)), 86 : AdoptRef(new scheduler::FakeWebTaskRunner)),
82 complete_(false), 87 complete_(false),
83 transfer_size_(-1) {} 88 transfer_size_(-1) {}
84 89
85 enum LoadPolicy load_policy_; 90 enum LoadPolicy load_policy_;
86 RefPtr<WebTaskRunner> runner_; 91 RefPtr<WebTaskRunner> runner_;
87 bool complete_; 92 bool complete_;
88 long long transfer_size_; 93 long long transfer_size_;
89 }; 94 };
90 95
91 } // namespace blink 96 } // namespace blink
92 97
93 #endif 98 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/ResourceLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698