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

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

Issue 2816403002: test all
Patch Set: fix sharedworker Created 3 years, 8 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 bool ShouldLoadNewResource(Resource::Type) const override { 57 bool ShouldLoadNewResource(Resource::Type) const override {
58 return load_policy_ == kShouldLoadNewResource; 58 return load_policy_ == kShouldLoadNewResource;
59 } 59 }
60 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; } 60 RefPtr<WebTaskRunner> LoadingTaskRunner() const override { return runner_; }
61 bool IsLoadComplete() const override { return complete_; } 61 bool IsLoadComplete() const override { return complete_; }
62 void AddResourceTiming( 62 void AddResourceTiming(
63 const ResourceTimingInfo& resource_timing_info) override { 63 const ResourceTimingInfo& resource_timing_info) override {
64 transfer_size_ = resource_timing_info.TransferSize(); 64 transfer_size_ = resource_timing_info.TransferSize();
65 } 65 }
66 WebURLLoader* CreateURLLoader() override {
67 return Platform::Current()->CreateURLLoader();
68 }
66 69
67 private: 70 private:
68 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner) 71 MockFetchContext(LoadPolicy load_policy, RefPtr<WebTaskRunner> task_runner)
69 : load_policy_(load_policy), 72 : load_policy_(load_policy),
70 runner_(task_runner ? std::move(task_runner) 73 runner_(task_runner ? std::move(task_runner)
71 : AdoptRef(new scheduler::FakeWebTaskRunner)), 74 : AdoptRef(new scheduler::FakeWebTaskRunner)),
72 complete_(false), 75 complete_(false),
73 transfer_size_(-1) {} 76 transfer_size_(-1) {}
74 77
75 enum LoadPolicy load_policy_; 78 enum LoadPolicy load_policy_;
76 RefPtr<WebTaskRunner> runner_; 79 RefPtr<WebTaskRunner> runner_;
77 bool complete_; 80 bool complete_;
78 long long transfer_size_; 81 long long transfer_size_;
79 }; 82 };
80 83
81 } // namespace blink 84 } // namespace blink
82 85
83 #endif 86 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698