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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerShadowFetchContext.h

Issue 2842123002: WorkerShadowFetchContext
Patch Set: . Created 3 years, 7 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
Index: third_party/WebKit/Source/core/workers/WorkerShadowFetchContext.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerShadowFetchContext.h b/third_party/WebKit/Source/core/workers/WorkerShadowFetchContext.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a20ae1d67ea5853fbd4a945a0f29312035a71a5
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerShadowFetchContext.h
@@ -0,0 +1,139 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WorkerShadowFetchContext_h
+#define WorkerShadowFetchContext_h
+
+#include "core/loader/BaseFetchContext.h"
+#include "public/platform/WebAddressSpace.h"
+
+namespace blink {
+
+class ApplicationCacheHost;
+class KURL;
+class ParentFrameTaskRunners;
+class Settings;
+class ThreadableLoadingContext;
+class WebServiceWorkerNetworkProvider;
+
+// A shadow fetch context for {Shared,Service} workers. This fetch context is
+// used by Workers but on the main thread.
+//
+// TODO: Needs to make DevTools work.
+class CORE_EXPORT WorkerShadowFetchContext final : public BaseFetchContext {
+ public:
+ static WorkerShadowFetchContext* Create(
+ const KURL&,
+ const String& user_agent,
+ WebAddressSpace,
+ ApplicationCacheHost*,
+ std::unique_ptr<WebServiceWorkerNetworkProvider>,
+ std::unique_ptr<Settings>,
+ ParentFrameTaskRunners*);
+ ~WorkerShadowFetchContext() override;
+
+ void Detach();
+
+ // FetchContext overrides:
+ void AddAdditionalRequestHeaders(ResourceRequest&,
+ FetchResourceType) override;
+ WebCachePolicy ResourceRequestCachePolicy(
+ const ResourceRequest&,
+ Resource::Type,
+ FetchParameters::DeferOption) const override;
+ void PrepareRequest(ResourceRequest&, RedirectType) override;
+ void DispatchWillSendRequest(
+ unsigned long identifier,
+ ResourceRequest&,
+ const ResourceResponse& redirect_response,
+ const FetchInitiatorInfo& = FetchInitiatorInfo()) override;
+ void DispatchDidReceiveResponse(unsigned long identifier,
+ const ResourceResponse&,
+ WebURLRequest::FrameType,
+ WebURLRequest::RequestContext,
+ Resource*,
+ ResourceResponseType) override;
+ void DispatchDidReceiveData(unsigned long identifier,
+ const char* data,
+ int data_length) override;
+ void DispatchDidReceiveEncodedData(unsigned long identifier,
+ int encoded_data_length) override;
+ void DispatchDidFinishLoading(unsigned long identifier,
+ double finish_time,
+ int64_t encoded_data_length,
+ int64_t decoded_body_length) override;
+ void DispatchDidFail(unsigned long identifier,
+ const ResourceError&,
+ int64_t encoded_data_length,
+ bool is_internal_request) override;
+ void AddResourceTiming(const ResourceTimingInfo&) override;
+ bool AllowImage(bool, const KURL&) const override;
+ bool IsControlledByServiceWorker() const override;
+ int64_t ServiceWorkerID() const override;
+ void PopulateResourceRequest(const KURL&,
+ Resource::Type,
+ const ClientHintsPreferences&,
+ const FetchParameters::ResourceWidth&,
+ const ResourceLoaderOptions&,
+ SecurityViolationReportingPolicy,
+ ResourceRequest&) override;
+ void SetFirstPartyCookieAndRequestorOrigin(ResourceRequest&) override;
+ RefPtr<WebTaskRunner> LoadingTaskRunner() const override;
+
+ ExecutionContext& GetExecutionContext();
+ SecurityContext& GetSecurityContext();
+ ThreadableLoadingContext& GetThreadableLoadingContext();
+
+ DECLARE_TRACE();
+
+ // BaseFetchContext overrides:
+ // TODO(kinuko): Implement these.
+ ContentSettingsClient* GetContentSettingsClient() const final {
+ return nullptr;
+ }
+ Settings* GetSettings() const final;
+ SubresourceFilter* GetSubresourceFilter() const final { return nullptr; }
+
+ protected:
+ // BaseFetchContext overrides:
+ // TODO(kinuko): Implement these.
+ SecurityContext* GetParentSecurityContext() const final;
+ bool ShouldBlockRequestByInspector(const ResourceRequest&) const final {
+ return false;
+ }
+ void DispatchDidBlockRequest(const ResourceRequest&,
+ const FetchInitiatorInfo&,
+ ResourceRequestBlockedReason) const final {}
+ void ReportLocalLoadFailed(const KURL&) const final {}
+ bool ShouldBypassMainWorldCSP() const final { return false; }
+ bool IsSVGImageChromeClient() const final { return false; }
+ void CountUsage(UseCounter::Feature) const final;
+ void CountDeprecation(UseCounter::Feature) const final;
+ bool ShouldBlockFetchByMixedContentCheck(
+ const ResourceRequest&,
+ const KURL&,
+ SecurityViolationReportingPolicy) const final {
+ return false;
+ }
+
+ private:
+ class ExecutionContextImpl; // ExecutionContext implementation.
+ class LoadingContextImpl; // ThreadableLoadingContext implementation.
+
+ WorkerShadowFetchContext(ExecutionContextImpl*,
+ ApplicationCacheHost*,
+ std::unique_ptr<WebServiceWorkerNetworkProvider>,
+ std::unique_ptr<Settings>,
+ ParentFrameTaskRunners*);
+
+ Member<ExecutionContextImpl> execution_context_;
+ Member<LoadingContextImpl> loading_context_;
+ Member<ApplicationCacheHost> app_cache_host_;
+ std::unique_ptr<WebServiceWorkerNetworkProvider> service_worker_provider_;
+ std::unique_ptr<Settings> settings_;
+};
+
+} // namespace blink
+
+#endif // WorkerShadowFetchContext_h

Powered by Google App Engine
This is Rietveld 408576698