Commit cb193cc5 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Move GetFetchClientSettingsObject() to FetchContext

As preparation for plumbing FetchClientSettingsObject via
FetchContext rather than as an argument,
this CL exposes GetFetchClientSettingsObject() in FetchContext.

NullFetchContext is added just to make
FetchContext::GetFetchClientSettingsObject() abstract and
FetchContext::NullInstance()'s GetFetchClientSettingsObject()
non-null.

This CL doesn't change the behavior.

Bug: 880027
Change-Id: I02a428d77d202ab88cffd22a3fdf3cd34eff4aca
Reviewed-on: https://chromium-review.googlesource.com/c/1200042Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606759}
parent 1cb034ac
......@@ -48,8 +48,6 @@ class CORE_EXPORT BaseFetchContext : public FetchContext {
void Trace(blink::Visitor*) override;
virtual const FetchClientSettingsObject* GetFetchClientSettingsObject()
const = 0;
virtual KURL GetSiteForCookies() const = 0;
virtual SubresourceFilter* GetSubresourceFilter() const = 0;
virtual PreviewsResourceLoadingHints* GetPreviewsResourceLoadingHints()
......
......@@ -30,14 +30,45 @@
#include "third_party/blink/renderer/platform/loader/fetch/fetch_context.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/platform_probe_sink.h"
#include "third_party/blink/renderer/platform/probe/platform_trace_events_agent.h"
namespace blink {
namespace {
class NullFetchContext final : public FetchContext {
public:
explicit NullFetchContext(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: FetchContext(std::move(task_runner)),
fetch_client_settings_object_(
MakeGarbageCollected<FetchClientSettingsObjectSnapshot>(
KURL(),
nullptr /* security_origin */,
kReferrerPolicyDefault,
String())) {}
const FetchClientSettingsObject* GetFetchClientSettingsObject()
const override {
return fetch_client_settings_object_;
}
void Trace(blink::Visitor* visitor) override {
visitor->Trace(fetch_client_settings_object_);
FetchContext::Trace(visitor);
}
private:
const Member<const FetchClientSettingsObject> fetch_client_settings_object_;
};
} // namespace
FetchContext& FetchContext::NullInstance(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
return *(new FetchContext(std::move(task_runner)));
return *(new NullFetchContext(std::move(task_runner)));
}
FetchContext::FetchContext(
......
......@@ -62,6 +62,7 @@
namespace blink {
class ClientHintsPreferences;
class FetchClientSettingsObject;
class KURL;
class MHTMLArchive;
class PlatformProbeSink;
......@@ -107,6 +108,9 @@ class PLATFORM_EXPORT FetchContext
virtual void AddAdditionalRequestHeaders(ResourceRequest&, FetchResourceType);
virtual const FetchClientSettingsObject* GetFetchClientSettingsObject()
const = 0;
// Called when the ResourceFetcher observes a data: URI load that contains an
// octothorpe ('#') character. This is a temporary method to support an Intent
// to Deprecate for spec incompliant handling of '#' characters in data URIs.
......
......@@ -10,6 +10,7 @@
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_url_loader_factory.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_context.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_timing_info.h"
......@@ -53,6 +54,12 @@ class MockFetchContext : public FetchContext {
security_origin_ = security_origin;
}
const FetchClientSettingsObject* GetFetchClientSettingsObject()
const override {
return new FetchClientSettingsObjectSnapshot(
KURL(), security_origin_, kReferrerPolicyDefault, String());
}
// The last ResourceRequest passed to DispatchWillSendRequest.
base::Optional<ResourceRequest> RequestFromWillSendRequest() const {
return will_send_request_;
......
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