Commit 5f02ead4 authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Removing callers of blink::Platform::CreateDefaultURLLoaderFactory.

This CL removes callers of
blink::Platform::CreateDefaultURLLoaderFactory to help with eventual
removal of this virtual method from blink::Platform.  In particular,
unit tests shouldn't need to go through a virtual method of
Platform::Current, but should be able to instead directly interact with
blink::TestingPlatformSupport or a similar class.

This CL fixes PingLocalFrameClient.

Before this CL, PingLocalFrameClient::CreateURLLoaderFactory would end
up calling
content::TestBlinkWebUnitTestSupport::CreateDefaultURLLoaderFactory.
After this CL, a TestingPlatformSupport::CreateDefaultURLLoaderFactory
is used instead.

TestingPlatformSupport is provided by a newly introduced field in
PingLoaderTest.  blink::PageTestBase::platform() and EnablePlatform are
not used, as they provide TestingPlatformSupportWithMockScheduler which
doesn't work as a drop-in replacement for PingLoaderTest.

Bug: 891872
Change-Id: Id69415930d6c4f7cce956a087662061965c96839
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250554Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779646}
parent c35dcfcc
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/loader/frame_loader.h" #include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/network/encoded_form_data.h" #include "third_party/blink/renderer/platform/network/encoded_form_data.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h"
...@@ -42,8 +43,11 @@ class PartialResourceRequest { ...@@ -42,8 +43,11 @@ class PartialResourceRequest {
class PingLocalFrameClient : public EmptyLocalFrameClient { class PingLocalFrameClient : public EmptyLocalFrameClient {
public: public:
explicit PingLocalFrameClient(TestingPlatformSupport* platform)
: platform_(platform) {}
std::unique_ptr<WebURLLoaderFactory> CreateURLLoaderFactory() override { std::unique_ptr<WebURLLoaderFactory> CreateURLLoaderFactory() override {
return Platform::Current()->CreateDefaultURLLoaderFactory(); return platform_->CreateDefaultURLLoaderFactory();
} }
void DispatchWillSendRequest(ResourceRequest& request) override { void DispatchWillSendRequest(ResourceRequest& request) override {
...@@ -55,12 +59,14 @@ class PingLocalFrameClient : public EmptyLocalFrameClient { ...@@ -55,12 +59,14 @@ class PingLocalFrameClient : public EmptyLocalFrameClient {
private: private:
PartialResourceRequest ping_request_; PartialResourceRequest ping_request_;
TestingPlatformSupport* platform_;
}; };
class PingLoaderTest : public PageTestBase { class PingLoaderTest : public PageTestBase {
public: public:
void SetUp() override { void SetUp() override {
client_ = MakeGarbageCollected<PingLocalFrameClient>(); client_ = MakeGarbageCollected<PingLocalFrameClient>(
platform_.GetTestingPlatformSupport());
PageTestBase::SetupPageWithClients(nullptr, client_); PageTestBase::SetupPageWithClients(nullptr, client_);
} }
...@@ -95,6 +101,7 @@ class PingLoaderTest : public PageTestBase { ...@@ -95,6 +101,7 @@ class PingLoaderTest : public PageTestBase {
} }
protected: protected:
ScopedTestingPlatformSupport<TestingPlatformSupport> platform_;
Persistent<PingLocalFrameClient> client_; Persistent<PingLocalFrameClient> client_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment