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

Unified Diff: third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc

Issue 2644083003: ResourceFetcherTest: introduce FetchTestingPlatformSupport (Closed)
Patch Set: review #23 Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc
diff --git a/third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc b/third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc
index af7f93829b9eb2489e5b411f6eb8ea4f522d90fc..47a2a4a7696574059bfda2aa4ae219e16d75ab38 100644
--- a/third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc
+++ b/third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.cc
@@ -8,9 +8,11 @@
#include "base/files/file_util.h"
#include "base/run_loop.h"
+#include "platform/testing/TestingPlatformSupport.h"
#include "platform/testing/UnitTestHelpers.h"
#include "platform/testing/weburl_loader_mock.h"
#include "public/platform/FilePathConversion.h"
+#include "public/platform/Platform.h"
#include "public/platform/WebString.h"
#include "public/platform/WebURLError.h"
#include "public/platform/WebURLRequest.h"
@@ -21,10 +23,12 @@ namespace blink {
std::unique_ptr<WebURLLoaderMockFactory> WebURLLoaderMockFactory::create()
yhirano 2017/01/23 11:38:56 How about adding a (non-null) TestingPlatformSuppo
kinuko 2017/01/24 00:39:05 [1] is in content, how can we provide TestingPlatf
{
- return WTF::wrapUnique(new WebURLLoaderMockFactoryImpl);
+ return WTF::wrapUnique(new WebURLLoaderMockFactoryImpl(nullptr));
}
-WebURLLoaderMockFactoryImpl::WebURLLoaderMockFactoryImpl() {}
+WebURLLoaderMockFactoryImpl::WebURLLoaderMockFactoryImpl(
+ TestingPlatformSupport* platform)
+ : m_platform(platform) {}
WebURLLoaderMockFactoryImpl::~WebURLLoaderMockFactoryImpl() {}
@@ -91,7 +95,7 @@ void WebURLLoaderMockFactoryImpl::serveAsynchronousRequests() {
while (response.httpStatusCode() >= 300 &&
response.httpStatusCode() < 400) {
WebURLRequest newRequest = loader->ServeRedirect(request, response);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
if (!loader || loader->is_cancelled() || loader->is_deferred())
break;
LoadRequest(newRequest, &response, &error, &data);
@@ -99,10 +103,10 @@ void WebURLLoaderMockFactoryImpl::serveAsynchronousRequests() {
// Serve the request if the loader is still active.
if (loader && !loader->is_cancelled() && !loader->is_deferred()) {
loader->ServeAsynchronousRequest(delegate_, response, data, error);
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
}
}
- base::RunLoop().RunUntilIdle();
+ RunUntilIdle();
}
bool WebURLLoaderMockFactoryImpl::IsMockedURL(const blink::WebURL& url) {
@@ -130,6 +134,13 @@ void WebURLLoaderMockFactoryImpl::LoadAsynchronouly(
pending_loaders_.set(loader, request);
}
+void WebURLLoaderMockFactoryImpl::RunUntilIdle() {
+ if (m_platform)
+ m_platform->runUntilIdle();
+ else
+ base::RunLoop().RunUntilIdle();
+}
+
void WebURLLoaderMockFactoryImpl::LoadRequest(const WebURLRequest& request,
WebURLResponse* response,
WebURLError* error,
« no previous file with comments | « third_party/WebKit/Source/platform/testing/weburl_loader_mock_factory_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698