OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WorkerShadowFetchContext_h |
| 6 #define WorkerShadowFetchContext_h |
| 7 |
| 8 #include "core/loader/BaseFetchContext.h" |
| 9 #include "public/platform/WebAddressSpace.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class ApplicationCacheHost; |
| 14 class KURL; |
| 15 class ParentFrameTaskRunners; |
| 16 class Settings; |
| 17 class ThreadableLoadingContext; |
| 18 class WebServiceWorkerNetworkProvider; |
| 19 |
| 20 // A shadow fetch context for {Shared,Service} workers. This fetch context is |
| 21 // used by Workers but on the main thread. |
| 22 // |
| 23 // TODO: Needs to make DevTools work. |
| 24 class CORE_EXPORT WorkerShadowFetchContext final : public BaseFetchContext { |
| 25 public: |
| 26 static WorkerShadowFetchContext* Create( |
| 27 const KURL&, |
| 28 const String& user_agent, |
| 29 WebAddressSpace, |
| 30 ApplicationCacheHost*, |
| 31 std::unique_ptr<WebServiceWorkerNetworkProvider>, |
| 32 std::unique_ptr<Settings>, |
| 33 ParentFrameTaskRunners*); |
| 34 ~WorkerShadowFetchContext() override; |
| 35 |
| 36 void Detach(); |
| 37 |
| 38 // FetchContext overrides: |
| 39 void AddAdditionalRequestHeaders(ResourceRequest&, |
| 40 FetchResourceType) override; |
| 41 WebCachePolicy ResourceRequestCachePolicy( |
| 42 const ResourceRequest&, |
| 43 Resource::Type, |
| 44 FetchParameters::DeferOption) const override; |
| 45 void PrepareRequest(ResourceRequest&, RedirectType) override; |
| 46 void DispatchWillSendRequest( |
| 47 unsigned long identifier, |
| 48 ResourceRequest&, |
| 49 const ResourceResponse& redirect_response, |
| 50 const FetchInitiatorInfo& = FetchInitiatorInfo()) override; |
| 51 void DispatchDidReceiveResponse(unsigned long identifier, |
| 52 const ResourceResponse&, |
| 53 WebURLRequest::FrameType, |
| 54 WebURLRequest::RequestContext, |
| 55 Resource*, |
| 56 ResourceResponseType) override; |
| 57 void DispatchDidReceiveData(unsigned long identifier, |
| 58 const char* data, |
| 59 int data_length) override; |
| 60 void DispatchDidReceiveEncodedData(unsigned long identifier, |
| 61 int encoded_data_length) override; |
| 62 void DispatchDidFinishLoading(unsigned long identifier, |
| 63 double finish_time, |
| 64 int64_t encoded_data_length, |
| 65 int64_t decoded_body_length) override; |
| 66 void DispatchDidFail(unsigned long identifier, |
| 67 const ResourceError&, |
| 68 int64_t encoded_data_length, |
| 69 bool is_internal_request) override; |
| 70 void AddResourceTiming(const ResourceTimingInfo&) override; |
| 71 bool AllowImage(bool, const KURL&) const override; |
| 72 bool IsControlledByServiceWorker() const override; |
| 73 int64_t ServiceWorkerID() const override; |
| 74 void PopulateResourceRequest(const KURL&, |
| 75 Resource::Type, |
| 76 const ClientHintsPreferences&, |
| 77 const FetchParameters::ResourceWidth&, |
| 78 const ResourceLoaderOptions&, |
| 79 SecurityViolationReportingPolicy, |
| 80 ResourceRequest&) override; |
| 81 void SetFirstPartyCookieAndRequestorOrigin(ResourceRequest&) override; |
| 82 RefPtr<WebTaskRunner> LoadingTaskRunner() const override; |
| 83 |
| 84 ExecutionContext& GetExecutionContext(); |
| 85 SecurityContext& GetSecurityContext(); |
| 86 ThreadableLoadingContext& GetThreadableLoadingContext(); |
| 87 |
| 88 DECLARE_TRACE(); |
| 89 |
| 90 // BaseFetchContext overrides: |
| 91 // TODO(kinuko): Implement these. |
| 92 ContentSettingsClient* GetContentSettingsClient() const final { |
| 93 return nullptr; |
| 94 } |
| 95 Settings* GetSettings() const final; |
| 96 SubresourceFilter* GetSubresourceFilter() const final { return nullptr; } |
| 97 |
| 98 protected: |
| 99 // BaseFetchContext overrides: |
| 100 // TODO(kinuko): Implement these. |
| 101 SecurityContext* GetParentSecurityContext() const final; |
| 102 bool ShouldBlockRequestByInspector(const ResourceRequest&) const final { |
| 103 return false; |
| 104 } |
| 105 void DispatchDidBlockRequest(const ResourceRequest&, |
| 106 const FetchInitiatorInfo&, |
| 107 ResourceRequestBlockedReason) const final {} |
| 108 void ReportLocalLoadFailed(const KURL&) const final {} |
| 109 bool ShouldBypassMainWorldCSP() const final { return false; } |
| 110 bool IsSVGImageChromeClient() const final { return false; } |
| 111 void CountUsage(UseCounter::Feature) const final; |
| 112 void CountDeprecation(UseCounter::Feature) const final; |
| 113 bool ShouldBlockFetchByMixedContentCheck( |
| 114 const ResourceRequest&, |
| 115 const KURL&, |
| 116 SecurityViolationReportingPolicy) const final { |
| 117 return false; |
| 118 } |
| 119 |
| 120 private: |
| 121 class ExecutionContextImpl; // ExecutionContext implementation. |
| 122 class LoadingContextImpl; // ThreadableLoadingContext implementation. |
| 123 |
| 124 WorkerShadowFetchContext(ExecutionContextImpl*, |
| 125 ApplicationCacheHost*, |
| 126 std::unique_ptr<WebServiceWorkerNetworkProvider>, |
| 127 std::unique_ptr<Settings>, |
| 128 ParentFrameTaskRunners*); |
| 129 |
| 130 Member<ExecutionContextImpl> execution_context_; |
| 131 Member<LoadingContextImpl> loading_context_; |
| 132 Member<ApplicationCacheHost> app_cache_host_; |
| 133 std::unique_ptr<WebServiceWorkerNetworkProvider> service_worker_provider_; |
| 134 std::unique_ptr<Settings> settings_; |
| 135 }; |
| 136 |
| 137 } // namespace blink |
| 138 |
| 139 #endif // WorkerShadowFetchContext_h |
OLD | NEW |