| Index: third_party/WebKit/Source/core/loader/WorkerFetchContext.h
|
| diff --git a/third_party/WebKit/Source/core/loader/WorkerFetchContext.h b/third_party/WebKit/Source/core/loader/WorkerFetchContext.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e031227f63167e45ba989727278a9be94dec3e9d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/loader/WorkerFetchContext.h
|
| @@ -0,0 +1,152 @@
|
| +// 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 WorkerFetchContext_h
|
| +#define WorkerFetchContext_h
|
| +
|
| +#include <memory>
|
| +#include "core/CoreExport.h"
|
| +#include "core/dom/ExecutionContext.h"
|
| +#include "core/workers/WorkerClients.h"
|
| +#include "core/workers/WorkerGlobalScope.h"
|
| +#include "platform/Supplementable.h"
|
| +#include "platform/loader/fetch/FetchContext.h"
|
| +#include "wtf/Forward.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class ExecutionContext;
|
| +class ResourceFetcher;
|
| +class WebTaskRunner;
|
| +class WebURLLoader;
|
| +class WebWorkerFetchContext;
|
| +class WebWorkerFetchContextInfo;
|
| +
|
| +class CORE_EXPORT WorkerFetchContextInfo final
|
| + : public GarbageCollectedFinalized<WorkerFetchContextInfo>,
|
| + public Supplement<WorkerClients> {
|
| + USING_GARBAGE_COLLECTED_MIXIN(WorkerFetchContextInfo);
|
| +
|
| + public:
|
| + static WorkerFetchContextInfo* create(
|
| + std::unique_ptr<WebWorkerFetchContextInfo>);
|
| + static WorkerFetchContextInfo* from(WorkerClients&);
|
| + static const char* supplementName();
|
| + virtual ~WorkerFetchContextInfo();
|
| +
|
| + bool isDataSaverEnabled() const { return m_DataSaverEnabled; }
|
| + void setDataSaverEnabled(bool enabled) { m_DataSaverEnabled = enabled; }
|
| + bool isStrictMixedContentCheckingEnabled() const {
|
| + return m_strictMixedContentCheckingEnabled;
|
| + }
|
| + void setStrictMixedContentCheckingEnabled(bool enabled) {
|
| + m_strictMixedContentCheckingEnabled = enabled;
|
| + }
|
| +
|
| + std::unique_ptr<WebWorkerFetchContext> CreateContext();
|
| +
|
| + DEFINE_INLINE_VIRTUAL_TRACE() { Supplement<WorkerClients>::trace(visitor); }
|
| +
|
| + private:
|
| + explicit WorkerFetchContextInfo(std::unique_ptr<WebWorkerFetchContextInfo>);
|
| +
|
| + std::unique_ptr<WebWorkerFetchContextInfo> m_info;
|
| + bool m_DataSaverEnabled = false;
|
| + bool m_strictMixedContentCheckingEnabled = false;
|
| +};
|
| +
|
| +CORE_EXPORT void provideWorkerFetchContextInfoToWorker(
|
| + WorkerClients*,
|
| + std::unique_ptr<WebWorkerFetchContextInfo>);
|
| +
|
| +class WorkerFetchContext final : public FetchContext {
|
| + public:
|
| + static WorkerFetchContext* create(WorkerGlobalScope&,
|
| + WorkerFetchContextInfo*);
|
| + static WorkerFetchContext* from(ExecutionContext&);
|
| +
|
| + virtual ~WorkerFetchContext();
|
| +
|
| + DECLARE_TRACE();
|
| + bool isControlledByServiceWorker() const override;
|
| + int64_t serviceWorkerID() const override;
|
| + ResourceRequestBlockedReason canRequest(
|
| + Resource::Type,
|
| + const ResourceRequest&,
|
| + const KURL&,
|
| + const ResourceLoaderOptions&,
|
| + SecurityViolationReportingPolicy,
|
| + FetchRequest::OriginRestriction) const override;
|
| +
|
| + void addAdditionalRequestHeaders(ResourceRequest&,
|
| + FetchResourceType) override;
|
| +
|
| + void prepareRequest(ResourceRequest&, RedirectType) override;
|
| + void dispatchWillSendRequest(unsigned long,
|
| + ResourceRequest&,
|
| + const ResourceResponse&,
|
| + const 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 dataLength) override;
|
| + void dispatchDidReceiveEncodedData(unsigned long identifier,
|
| + int encodedDataLength) override;
|
| + void dispatchDidFinishLoading(unsigned long identifier,
|
| + double finishTime,
|
| + int64_t encodedDataLength,
|
| + int64_t decodedBodyLength) override;
|
| + void dispatchDidFail(unsigned long identifier,
|
| + const ResourceError&,
|
| + int64_t encodedDataLength,
|
| + bool isInternalRequest) override;
|
| +
|
| + ResourceRequestBlockedReason allowResponse(
|
| + Resource::Type,
|
| + const ResourceRequest&,
|
| + const KURL&,
|
| + const ResourceLoaderOptions&) const override;
|
| + void addResourceTiming(const ResourceTimingInfo&) override;
|
| +
|
| + WebURLLoader* createURLLoader() override;
|
| + RefPtr<WebTaskRunner> loadingTaskRunner() const override;
|
| + RefPtr<WebTaskRunner> timerTaskRunner() const override;
|
| + Resource::ResourceCallback* resourceCallback() override;
|
| + ResourceFetcher* getResourceFetcher();
|
| +
|
| + private:
|
| + class WorkerResourceCallback;
|
| + explicit WorkerFetchContext(WorkerGlobalScope&,
|
| + std::unique_ptr<WebWorkerFetchContext>,
|
| + bool dataSaverEnabled,
|
| + bool strictMixedContentCheckingEnabled);
|
| + void initializeOnWorkerThread();
|
| +
|
| + ResourceRequestBlockedReason canRequestInternal(
|
| + Resource::Type,
|
| + const ResourceRequest&,
|
| + const KURL&,
|
| + const ResourceLoaderOptions&,
|
| + SecurityViolationReportingPolicy,
|
| + FetchRequest::OriginRestriction,
|
| + ResourceRequest::RedirectStatus) const;
|
| +
|
| + Member<WorkerGlobalScope> m_workerGlobalScope;
|
| + Member<ResourceFetcher> m_resourceFetcher;
|
| + std::unique_ptr<WebWorkerFetchContext> m_context;
|
| + RefPtr<WebTaskRunner> m_loadingTaskRunner;
|
| + RefPtr<WebTaskRunner> m_timerTaskRunner;
|
| + const bool m_dataSaverEnabled;
|
| + const bool m_strictMixedContentCheckingEnabled;
|
| + Member<WorkerResourceCallback> m_resourceCallback;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // WorkerFetchContext_h
|
|
|