OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WorkerFetchContext_h | 5 #ifndef WorkerFetchContext_h |
6 #define WorkerFetchContext_h | 6 #define WorkerFetchContext_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/loader/fetch/FetchContext.h" | 10 #include "core/loader/BaseFetchContext.h" |
11 #include "platform/wtf/Forward.h" | 11 #include "platform/wtf/Forward.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class WorkerClients; | 15 class ResourceFetcher; |
| 16 class WebTaskRunner; |
16 class WebURLLoader; | 17 class WebURLLoader; |
17 class WebWorkerFetchContext; | 18 class WebWorkerFetchContext; |
18 class WorkerGlobalScope; | 19 class WorkerGlobalScope; |
| 20 class WorkerClients; |
19 | 21 |
20 CORE_EXPORT void ProvideWorkerFetchContextToWorker( | 22 CORE_EXPORT void ProvideWorkerFetchContextToWorker( |
21 WorkerClients*, | 23 WorkerClients*, |
22 std::unique_ptr<WebWorkerFetchContext>); | 24 std::unique_ptr<WebWorkerFetchContext>); |
23 | 25 |
24 // The WorkerFetchContext is a FetchContext for workers (dedicated, shared and | 26 // The WorkerFetchContext is a FetchContext for workers (dedicated, shared and |
25 // service workers). This class is used only when off-main-thread-fetch is | 27 // service workers). This class is used only when off-main-thread-fetch is |
26 // enabled, and is still under development. | 28 // enabled, and is still under development. |
27 // TODO(horo): Implement all methods of FetchContext. crbug.com/443374 | 29 // TODO(horo): Implement all methods of FetchContext. crbug.com/443374 |
28 class WorkerFetchContext final : public FetchContext { | 30 class WorkerFetchContext final : public BaseFetchContext { |
29 public: | 31 public: |
30 static WorkerFetchContext* Create(WorkerGlobalScope&); | 32 static WorkerFetchContext* Create(WorkerGlobalScope&); |
31 virtual ~WorkerFetchContext(); | 33 virtual ~WorkerFetchContext(); |
32 | 34 |
| 35 ResourceFetcher* GetResourceFetcher(); |
| 36 |
| 37 // BaseFetchContext implementation: |
| 38 ContentSettingsClient* GetContentSettingsClient() const override; |
| 39 Settings* GetSettings() const override; |
| 40 SubresourceFilter* GetSubresourceFilter() const override; |
| 41 SecurityContext* GetParentSecurityContext() const override; |
| 42 bool ShouldBlockRequestByInspector(const ResourceRequest&) const override; |
| 43 void DispatchDidBlockRequest(const ResourceRequest&, |
| 44 const FetchInitiatorInfo&, |
| 45 ResourceRequestBlockedReason) const override; |
| 46 void ReportLocalLoadFailed(const KURL&) const override; |
| 47 bool ShouldBypassMainWorldCSP() const override; |
| 48 bool IsSVGImageChromeClient() const override; |
| 49 void CountUsage(UseCounter::Feature) const override; |
| 50 void CountDeprecation(UseCounter::Feature) const override; |
| 51 bool ShouldBlockFetchByMixedContentCheck( |
| 52 const ResourceRequest&, |
| 53 const KURL&, |
| 54 SecurityViolationReportingPolicy) const override; |
| 55 |
33 // FetchContext implementation: | 56 // FetchContext implementation: |
34 // TODO(horo): Implement more methods. | 57 // TODO(horo): Implement more methods. |
35 std::unique_ptr<WebURLLoader> CreateURLLoader() override; | 58 std::unique_ptr<WebURLLoader> CreateURLLoader() override; |
36 void PrepareRequest(ResourceRequest&, RedirectType) override; | 59 void PrepareRequest(ResourceRequest&, RedirectType) override; |
37 bool IsControlledByServiceWorker() const override; | 60 bool IsControlledByServiceWorker() const override; |
| 61 RefPtr<WebTaskRunner> LoadingTaskRunner() const override; |
| 62 |
| 63 DECLARE_VIRTUAL_TRACE(); |
38 | 64 |
39 private: | 65 private: |
40 explicit WorkerFetchContext(std::unique_ptr<WebWorkerFetchContext>); | 66 WorkerFetchContext(WorkerGlobalScope&, |
| 67 std::unique_ptr<WebWorkerFetchContext>); |
41 | 68 |
| 69 Member<WorkerGlobalScope> worker_global_scope_; |
42 std::unique_ptr<WebWorkerFetchContext> web_context_; | 70 std::unique_ptr<WebWorkerFetchContext> web_context_; |
| 71 Member<ResourceFetcher> resource_fetcher_; |
| 72 RefPtr<WebTaskRunner> loading_task_runner_; |
43 }; | 73 }; |
44 | 74 |
45 } // namespace blink | 75 } // namespace blink |
46 | 76 |
47 #endif // WorkerFetchContext_h | 77 #endif // WorkerFetchContext_h |
OLD | NEW |