| 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..1bcaad9b0ce1a91534e82680aa3714cfd7e8ca29
 | 
| --- /dev/null
 | 
| +++ b/third_party/WebKit/Source/core/loader/WorkerFetchContext.h
 | 
| @@ -0,0 +1,112 @@
 | 
| +// 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 "platform/Supplementable.h"
 | 
| +#include "platform/loader/fetch/FetchContext.h"
 | 
| +#include "platform/wtf/Forward.h"
 | 
| +
 | 
| +namespace blink {
 | 
| +
 | 
| +class ResourceFetcher;
 | 
| +class WebTaskRunner;
 | 
| +class WebURLLoader;
 | 
| +class WebWorkerFetchContext;
 | 
| +class WorkerClients;
 | 
| +class WorkerGlobalScope;
 | 
| +
 | 
| +CORE_EXPORT void ProvideWorkerFetchContextToWorker(
 | 
| +    WorkerClients*,
 | 
| +    std::unique_ptr<WebWorkerFetchContext>);
 | 
| +
 | 
| +// The WorkerFetchContext is a FetchContext for workers (dedicated, shared and
 | 
| +// service workers). This class is used only when off-main-thread-fetch is
 | 
| +// enabled, and is still under development.
 | 
| +// TODO(horo): Implement all methods of FetchContext. crbug.com/443374
 | 
| +class WorkerFetchContext final : public FetchContext {
 | 
| + public:
 | 
| +  static WorkerFetchContext* Create(WorkerGlobalScope&);
 | 
| +  virtual ~WorkerFetchContext();
 | 
| +
 | 
| +  ResourceFetcher* GetResourceFetcher();
 | 
| +
 | 
| +  // FetchContext implementation:
 | 
| +  WebURLLoader* CreateURLLoader() override;
 | 
| +  void PrepareRequest(ResourceRequest&, RedirectType) override;
 | 
| +  bool IsControlledByServiceWorker() const override;
 | 
| +  int64_t ServiceWorkerID() const override;
 | 
| +  ResourceRequestBlockedReason CanRequest(
 | 
| +      Resource::Type,
 | 
| +      const ResourceRequest&,
 | 
| +      const KURL&,
 | 
| +      const ResourceLoaderOptions&,
 | 
| +      SecurityViolationReportingPolicy,
 | 
| +      FetchParameters::OriginRestriction) const override;
 | 
| +  void AddAdditionalRequestHeaders(ResourceRequest&,
 | 
| +                                   FetchResourceType) 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;
 | 
| +  RefPtr<WebTaskRunner> LoadingTaskRunner() const override;
 | 
| +  RefPtr<WebTaskRunner> TimerTaskRunner() const override;
 | 
| +  Resource::ResourceCallback* GetResourceCallback() override;
 | 
| +
 | 
| +  DECLARE_VIRTUAL_TRACE();
 | 
| +
 | 
| + private:
 | 
| +  class WorkerResourceCallback;
 | 
| +  WorkerFetchContext(WorkerGlobalScope&,
 | 
| +                     std::unique_ptr<WebWorkerFetchContext>);
 | 
| +  void InitializeOnWorkerThread(WorkerGlobalScope&);
 | 
| +
 | 
| +  ResourceRequestBlockedReason CanRequestInternal(
 | 
| +      Resource::Type,
 | 
| +      const ResourceRequest&,
 | 
| +      const KURL&,
 | 
| +      const ResourceLoaderOptions&,
 | 
| +      SecurityViolationReportingPolicy,
 | 
| +      FetchParameters::OriginRestriction,
 | 
| +      ResourceRequest::RedirectStatus) const;
 | 
| +
 | 
| +  Member<WorkerGlobalScope> worker_global_scope_;
 | 
| +  std::unique_ptr<WebWorkerFetchContext> web_context_;
 | 
| +  Member<ResourceFetcher> resource_fetcher_;
 | 
| +  RefPtr<WebTaskRunner> loading_task_runner_;
 | 
| +  RefPtr<WebTaskRunner> timer_task_runner_;
 | 
| +  Member<WorkerResourceCallback> resource_callback_;
 | 
| +};
 | 
| +
 | 
| +}  // namespace blink
 | 
| +
 | 
| +#endif  // WorkerFetchContext_h
 | 
| 
 |