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

Side by Side Diff: third_party/WebKit/Source/core/loader/WorkerFetchContext.h

Issue 2807533003: [WIP2] off-main-thread loading
Patch Set: call set_is_secure_context in EmbeddedSharedWorkerStub::CreateWorkerFetchContext() 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 unified diff | Download patch
OLDNEW
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/Supplementable.h"
10 #include "platform/loader/fetch/FetchContext.h" 11 #include "platform/loader/fetch/FetchContext.h"
11 #include "platform/wtf/Forward.h" 12 #include "platform/wtf/Forward.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 class WorkerClients; 16 class ResourceFetcher;
17 class WebTaskRunner;
16 class WebURLLoader; 18 class WebURLLoader;
17 class WebWorkerFetchContext; 19 class WebWorkerFetchContext;
20 class WorkerClients;
18 class WorkerGlobalScope; 21 class WorkerGlobalScope;
19 22
20 CORE_EXPORT void ProvideWorkerFetchContextToWorker( 23 CORE_EXPORT void ProvideWorkerFetchContextToWorker(
21 WorkerClients*, 24 WorkerClients*,
22 std::unique_ptr<WebWorkerFetchContext>); 25 std::unique_ptr<WebWorkerFetchContext>);
23 26
24 // The WorkerFetchContext is a FetchContext for workers (dedicated, shared and 27 // The WorkerFetchContext is a FetchContext for workers (dedicated, shared and
25 // service workers). This class is used only when off-main-thread-fetch is 28 // service workers). This class is used only when off-main-thread-fetch is
26 // enabled, and is still under development. 29 // enabled, and is still under development.
27 // TODO(horo): Implement all methods of FetchContext. crbug.com/443374 30 // TODO(horo): Implement all methods of FetchContext. crbug.com/443374
28 class WorkerFetchContext final : public FetchContext { 31 class WorkerFetchContext final : public FetchContext {
29 public: 32 public:
30 static WorkerFetchContext* Create(WorkerGlobalScope&); 33 static WorkerFetchContext* Create(WorkerGlobalScope&);
31 virtual ~WorkerFetchContext(); 34 virtual ~WorkerFetchContext();
32 35
36 ResourceFetcher* GetResourceFetcher();
37
33 // FetchContext implementation: 38 // FetchContext implementation:
34 // TODO(horo): Implement more methods.
35 std::unique_ptr<WebURLLoader> CreateURLLoader() override; 39 std::unique_ptr<WebURLLoader> CreateURLLoader() override;
36 void PrepareRequest(ResourceRequest&, RedirectType) override; 40 void PrepareRequest(ResourceRequest&, RedirectType) override;
37 bool IsControlledByServiceWorker() const override; 41 bool IsControlledByServiceWorker() const override;
42 int64_t ServiceWorkerID() const override;
43 ResourceRequestBlockedReason CanRequest(
44 Resource::Type,
45 const ResourceRequest&,
46 const KURL&,
47 const ResourceLoaderOptions&,
48 SecurityViolationReportingPolicy,
49 FetchParameters::OriginRestriction) const override;
50 ResourceRequestBlockedReason CanFollowRedirect(
51 Resource::Type,
52 const ResourceRequest&,
53 const KURL&,
54 const ResourceLoaderOptions&,
55 SecurityViolationReportingPolicy,
56 FetchParameters::OriginRestriction) const override;
57 void AddAdditionalRequestHeaders(ResourceRequest&,
58 FetchResourceType) override;
59 void DispatchWillSendRequest(unsigned long,
60 ResourceRequest&,
61 const ResourceResponse&,
62 const FetchInitiatorInfo&) override;
63 void DispatchDidReceiveResponse(unsigned long identifier,
64 const ResourceResponse&,
65 WebURLRequest::FrameType,
66 WebURLRequest::RequestContext,
67 Resource*,
68 ResourceResponseType) override;
69 void DispatchDidReceiveData(unsigned long identifier,
70 const char* data,
71 int dataLength) override;
72 void DispatchDidReceiveEncodedData(unsigned long identifier,
73 int encodedDataLength) override;
74 void DispatchDidFinishLoading(unsigned long identifier,
75 double finishTime,
76 int64_t encodedDataLength,
77 int64_t decodedBodyLength) override;
78 void DispatchDidFail(unsigned long identifier,
79 const ResourceError&,
80 int64_t encodedDataLength,
81 bool isInternalRequest) override;
82 ResourceRequestBlockedReason AllowResponse(
83 Resource::Type,
84 const ResourceRequest&,
85 const KURL&,
86 const ResourceLoaderOptions&) const override;
87 void AddResourceTiming(const ResourceTimingInfo&) override;
88 RefPtr<WebTaskRunner> LoadingTaskRunner() const override;
89 RefPtr<WebTaskRunner> TimerTaskRunner() const override;
90 Resource::ResourceCallback* GetResourceCallback() override;
91
92 DECLARE_VIRTUAL_TRACE();
38 93
39 private: 94 private:
40 explicit WorkerFetchContext(std::unique_ptr<WebWorkerFetchContext>); 95 class WorkerResourceCallback;
96 WorkerFetchContext(WorkerGlobalScope&,
97 std::unique_ptr<WebWorkerFetchContext>);
98 void InitializeOnWorkerThread(WorkerGlobalScope&);
41 99
100 ResourceRequestBlockedReason CanRequestInternal(
101 Resource::Type,
102 const ResourceRequest&,
103 const KURL&,
104 const ResourceLoaderOptions&,
105 SecurityViolationReportingPolicy,
106 FetchParameters::OriginRestriction,
107 ResourceRequest::RedirectStatus) const;
108
109 Member<WorkerGlobalScope> worker_global_scope_;
42 std::unique_ptr<WebWorkerFetchContext> web_context_; 110 std::unique_ptr<WebWorkerFetchContext> web_context_;
111 Member<ResourceFetcher> resource_fetcher_;
112 RefPtr<WebTaskRunner> loading_task_runner_;
113 RefPtr<WebTaskRunner> timer_task_runner_;
114 Member<WorkerResourceCallback> resource_callback_;
43 }; 115 };
44 116
45 } // namespace blink 117 } // namespace blink
46 118
47 #endif // WorkerFetchContext_h 119 #endif // WorkerFetchContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698