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

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

Issue 2807533003: [WIP2] off-main-thread loading
Patch Set: call set_is_secure_context in EmbeddedSharedWorkerStub::CreateWorkerFetchContext() 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
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 <memory>
8 #include "platform/loader/fetch/FetchContext.h" 9 #include "platform/loader/fetch/FetchContext.h"
9 #include "platform/loader/fetch/FetchParameters.h" 10 #include "platform/loader/fetch/FetchParameters.h"
10 #include "platform/loader/fetch/ResourceTimingInfo.h" 11 #include "platform/loader/fetch/ResourceTimingInfo.h"
11 #include "platform/scheduler/test/fake_web_task_runner.h" 12 #include "platform/scheduler/test/fake_web_task_runner.h"
12 #include "platform/wtf/PtrUtil.h" 13 #include "platform/wtf/PtrUtil.h"
13 14 #include "public/platform/Platform.h"
14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class KURL; 18 class KURL;
19 class ResourceRequest; 19 class ResourceRequest;
20 class WebTaskRunner; 20 class WebTaskRunner;
21 struct ResourceLoaderOptions; 21 struct ResourceLoaderOptions;
22 22
23 // Mocked FetchContext for testing. 23 // Mocked FetchContext for testing.
24 class MockFetchContext : public FetchContext { 24 class MockFetchContext : public FetchContext {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 bool ShouldLoadNewResource(Resource::Type) const override { 67 bool ShouldLoadNewResource(Resource::Type) const override {
68 return load_policy_ == kShouldLoadNewResource; 68 return load_policy_ == kShouldLoadNewResource;
69 } 69 }
70 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; } 70 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; }
71 bool IsLoadComplete() const override { return complete_; } 71 bool IsLoadComplete() const override { return complete_; }
72 void AddResourceTiming( 72 void AddResourceTiming(
73 const ResourceTimingInfo& resource_timing_info) override { 73 const ResourceTimingInfo& resource_timing_info) override {
74 transfer_size_ = resource_timing_info.TransferSize(); 74 transfer_size_ = resource_timing_info.TransferSize();
75 } 75 }
76 std::unique_ptr<WebURLLoader> CreateURLLoader() override {
77 return Platform::Current()->CreateURLLoader();
78 }
76 79
77 private: 80 private:
78 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner) 81 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner)
79 : load_policy_(load_policy), 82 : load_policy_(load_policy),
80 runner_(task_runner ? std::move(task_runner) 83 runner_(task_runner ? std::move(task_runner)
81 : AdoptRef(new scheduler::FakeWebTaskRunner)), 84 : AdoptRef(new scheduler::FakeWebTaskRunner)),
82 complete_(false), 85 complete_(false),
83 transfer_size_(-1) {} 86 transfer_size_(-1) {}
84 87
85 enum LoadPolicy load_policy_; 88 enum LoadPolicy load_policy_;
86 RefPtr<WebTaskRunner> runner_; 89 RefPtr<WebTaskRunner> runner_;
87 bool complete_; 90 bool complete_;
88 long long transfer_size_; 91 long long transfer_size_;
89 }; 92 };
90 93
91 } // namespace blink 94 } // namespace blink
92 95
93 #endif 96 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698