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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/FetchTestingPlatformSupport.cpp

Issue 2657793002: Make WebURLLoaderMockFactoryImpl::createURLLoader accept nullptr (Closed)
Patch Set: cl format 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/testing/weburl_loader_mock.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "platform/loader/fetch/FetchTestingPlatformSupport.h" 5 #include "platform/loader/fetch/FetchTestingPlatformSupport.h"
6 6
7 #include "platform/loader/fetch/MockFetchContext.h" 7 #include "platform/loader/fetch/MockFetchContext.h"
8 #include "platform/network/ResourceError.h" 8 #include "platform/network/ResourceError.h"
9 #include "platform/testing/weburl_loader_mock_factory_impl.h" 9 #include "platform/testing/weburl_loader_mock_factory_impl.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
11 #include "public/platform/WebURL.h" 11 #include "public/platform/WebURL.h"
12 #include "public/platform/WebURLLoader.h" 12 #include "public/platform/WebURLLoader.h"
13 #include "public/platform/WebURLLoaderMockFactory.h" 13 #include "public/platform/WebURLLoaderMockFactory.h"
14 #include <memory> 14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 namespace {
19
20 // WebURLLoader that does nothing. This instance should be passed as a default
21 // WebURLLoader to create a WebURLLoader through WebURLLoaderMockFactory.
22 class AssertWebURLLoader : public WebURLLoader {
23 public:
24 ~AssertWebURLLoader() override {}
25
26 // WebURLLoader:
27 void loadSynchronously(const WebURLRequest&,
28 WebURLResponse&,
29 WebURLError&,
30 WebData&,
31 int64_t& encodedDataLength,
32 int64_t& encodedBodyLength) override {
33 NOTREACHED();
34 }
35 void loadAsynchronously(const WebURLRequest&, WebURLLoaderClient*) override {
36 NOTREACHED();
37 }
38 void cancel() override { NOTREACHED(); }
39 void setDefersLoading(bool defer) override { NOTREACHED(); }
40 void setLoadingTaskRunner(base::SingleThreadTaskRunner*) override {
41 NOTREACHED();
42 }
43 };
44
45 } // namespace
46
47 FetchTestingPlatformSupport::FetchTestingPlatformSupport() 18 FetchTestingPlatformSupport::FetchTestingPlatformSupport()
48 : m_urlLoaderMockFactory(new WebURLLoaderMockFactoryImpl(this)) {} 19 : m_urlLoaderMockFactory(new WebURLLoaderMockFactoryImpl(this)) {}
49 20
50 FetchTestingPlatformSupport::~FetchTestingPlatformSupport() { 21 FetchTestingPlatformSupport::~FetchTestingPlatformSupport() {
51 // Shutdowns WebURLLoaderMockFactory gracefully, serving all pending requests 22 // Shutdowns WebURLLoaderMockFactory gracefully, serving all pending requests
52 // first, then flushing all registered URLs. 23 // first, then flushing all registered URLs.
53 m_urlLoaderMockFactory->serveAsynchronousRequests(); 24 m_urlLoaderMockFactory->serveAsynchronousRequests();
54 m_urlLoaderMockFactory->unregisterAllURLs(); 25 m_urlLoaderMockFactory->unregisterAllURLs();
55 } 26 }
56 27
(...skipping 11 matching lines...) Expand all
68 return ResourceError(errorDomainBlinkInternal, -1, url.string(), 39 return ResourceError(errorDomainBlinkInternal, -1, url.string(),
69 "cancelledError for testing"); 40 "cancelledError for testing");
70 } 41 }
71 42
72 WebURLLoaderMockFactory* 43 WebURLLoaderMockFactory*
73 FetchTestingPlatformSupport::getURLLoaderMockFactory() { 44 FetchTestingPlatformSupport::getURLLoaderMockFactory() {
74 return m_urlLoaderMockFactory.get(); 45 return m_urlLoaderMockFactory.get();
75 } 46 }
76 47
77 WebURLLoader* FetchTestingPlatformSupport::createURLLoader() { 48 WebURLLoader* FetchTestingPlatformSupport::createURLLoader() {
78 return m_urlLoaderMockFactory->createURLLoader(new AssertWebURLLoader); 49 return m_urlLoaderMockFactory->createURLLoader(nullptr);
79 } 50 }
80 51
81 } // namespace blink 52 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/testing/weburl_loader_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698