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

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

Issue 2657583004: ResourceFetcherTest: cleanup finalization (Closed)
Patch Set: review #9 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/loader/fetch/ResourceFetcherTest.cpp » ('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"
(...skipping 29 matching lines...) Expand all
40 void setLoadingTaskRunner(base::SingleThreadTaskRunner*) override { 40 void setLoadingTaskRunner(base::SingleThreadTaskRunner*) override {
41 NOTREACHED(); 41 NOTREACHED();
42 } 42 }
43 }; 43 };
44 44
45 } // namespace 45 } // namespace
46 46
47 FetchTestingPlatformSupport::FetchTestingPlatformSupport() 47 FetchTestingPlatformSupport::FetchTestingPlatformSupport()
48 : m_urlLoaderMockFactory(new WebURLLoaderMockFactoryImpl(this)) {} 48 : m_urlLoaderMockFactory(new WebURLLoaderMockFactoryImpl(this)) {}
49 49
50 FetchTestingPlatformSupport::~FetchTestingPlatformSupport() = default; 50 FetchTestingPlatformSupport::~FetchTestingPlatformSupport() {
51 // Shutdowns WebURLLoaderMockFactory gracefully, serving all pending requests
52 // first, then flushing all registered URLs.
53 m_urlLoaderMockFactory->serveAsynchronousRequests();
54 m_urlLoaderMockFactory->unregisterAllURLs();
55 }
51 56
52 MockFetchContext* FetchTestingPlatformSupport::context() { 57 MockFetchContext* FetchTestingPlatformSupport::context() {
53 if (!m_context) { 58 if (!m_context) {
54 m_context = MockFetchContext::create( 59 m_context = MockFetchContext::create(
55 MockFetchContext::kShouldLoadNewResource, 60 MockFetchContext::kShouldLoadNewResource,
56 currentThread()->scheduler()->loadingTaskRunner()); 61 currentThread()->scheduler()->loadingTaskRunner());
57 } 62 }
58 return m_context; 63 return m_context;
59 } 64 }
60 65
61 WebURLError FetchTestingPlatformSupport::cancelledError( 66 WebURLError FetchTestingPlatformSupport::cancelledError(
62 const WebURL& url) const { 67 const WebURL& url) const {
63 return ResourceError(errorDomainBlinkInternal, -1, url.string(), 68 return ResourceError(errorDomainBlinkInternal, -1, url.string(),
64 "cancelledError for testing"); 69 "cancelledError for testing");
65 } 70 }
66 71
67 WebURLLoaderMockFactory* 72 WebURLLoaderMockFactory*
68 FetchTestingPlatformSupport::getURLLoaderMockFactory() { 73 FetchTestingPlatformSupport::getURLLoaderMockFactory() {
69 return m_urlLoaderMockFactory.get(); 74 return m_urlLoaderMockFactory.get();
70 } 75 }
71 76
72 WebURLLoader* FetchTestingPlatformSupport::createURLLoader() { 77 WebURLLoader* FetchTestingPlatformSupport::createURLLoader() {
73 return m_urlLoaderMockFactory->createURLLoader(new AssertWebURLLoader); 78 return m_urlLoaderMockFactory->createURLLoader(new AssertWebURLLoader);
74 } 79 }
75 80
76 } // namespace blink 81 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698