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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandle.cpp

Issue 2181243002: Move ThreadableLoader to Oilpan heap (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-bridge-peer-in-worker-threadable-loader
Patch Set: fix Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "modules/fetch/FetchBlobDataConsumerHandle.h" 5 #include "modules/fetch/FetchBlobDataConsumerHandle.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/fetch/FetchInitiatorTypeNames.h" 8 #include "core/fetch/FetchInitiatorTypeNames.h"
9 #include "core/loader/ThreadableLoaderClient.h" 9 #include "core/loader/ThreadableLoaderClient.h"
10 #include "modules/fetch/CompositeDataConsumerHandle.h" 10 #include "modules/fetch/CompositeDataConsumerHandle.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 , m_blobDataHandle(blobDataHandle) 69 , m_blobDataHandle(blobDataHandle)
70 , m_loaderFactory(loaderFactory) 70 , m_loaderFactory(loaderFactory)
71 , m_receivedResponse(false) { } 71 , m_receivedResponse(false) { }
72 72
73 ~BlobLoaderContext() override 73 ~BlobLoaderContext() override
74 { 74 {
75 if (m_loader && !m_receivedResponse) 75 if (m_loader && !m_receivedResponse)
76 m_updater->update(createUnexpectedErrorDataConsumerHandle()); 76 m_updater->update(createUnexpectedErrorDataConsumerHandle());
77 if (m_loader) { 77 if (m_loader) {
78 m_loader->cancel(); 78 m_loader->cancel();
79 m_loader.reset(); 79 m_loader = nullptr;
80 } 80 }
81 } 81 }
82 82
83 void start(ExecutionContext* executionContext) override 83 void start(ExecutionContext* executionContext) override
84 { 84 {
85 ASSERT(executionContext->isContextThread()); 85 ASSERT(executionContext->isContextThread());
86 ASSERT(!m_loader); 86 ASSERT(!m_loader);
87 87
88 KURL url = BlobURL::createPublicURL(executionContext->getSecurityOrigin( )); 88 KURL url = BlobURL::createPublicURL(executionContext->getSecurityOrigin( ));
89 if (url.isEmpty()) { 89 if (url.isEmpty()) {
90 m_updater->update(createUnexpectedErrorDataConsumerHandle()); 90 m_updater->update(createUnexpectedErrorDataConsumerHandle());
91 return; 91 return;
92 } 92 }
93 BlobRegistry::registerPublicBlobURL(executionContext->getSecurityOrigin( ), url, m_blobDataHandle); 93 BlobRegistry::registerPublicBlobURL(executionContext->getSecurityOrigin( ), url, m_blobDataHandle);
94 94
95 m_loader = createLoader(executionContext, this); 95 m_loader = createLoader(executionContext, this);
96 ASSERT(m_loader); 96 ASSERT(m_loader);
97 97
98 ResourceRequest request(url); 98 ResourceRequest request(url);
99 request.setRequestContext(WebURLRequest::RequestContextInternal); 99 request.setRequestContext(WebURLRequest::RequestContextInternal);
100 request.setUseStreamOnResponse(true); 100 request.setUseStreamOnResponse(true);
101 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpa ce', as 'data:' can never be external. 101 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpa ce', as 'data:' can never be external.
102 m_loader->start(request); 102 m_loader->start(request);
103 } 103 }
104 104
105 private: 105 private:
106 std::unique_ptr<ThreadableLoader> createLoader(ExecutionContext* executionCo ntext, ThreadableLoaderClient* client) const 106 ThreadableLoader* createLoader(ExecutionContext* executionContext, Threadabl eLoaderClient* client) const
107 { 107 {
108 ThreadableLoaderOptions options; 108 ThreadableLoaderOptions options;
109 options.preflightPolicy = ConsiderPreflight; 109 options.preflightPolicy = ConsiderPreflight;
110 options.crossOriginRequestPolicy = DenyCrossOriginRequests; 110 options.crossOriginRequestPolicy = DenyCrossOriginRequests;
111 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo licy; 111 options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPo licy;
112 options.initiator = FetchInitiatorTypeNames::internal; 112 options.initiator = FetchInitiatorTypeNames::internal;
113 113
114 ResourceLoaderOptions resourceLoaderOptions; 114 ResourceLoaderOptions resourceLoaderOptions;
115 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; 115 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
116 116
(...skipping 10 matching lines...) Expand all
127 // |WebDataConsumerHandle| since we call 127 // |WebDataConsumerHandle| since we call
128 // request.setUseStreamOnResponse(). 128 // request.setUseStreamOnResponse().
129 m_updater->update(createUnexpectedErrorDataConsumerHandle()); 129 m_updater->update(createUnexpectedErrorDataConsumerHandle());
130 return; 130 return;
131 } 131 }
132 m_updater->update(std::move(handle)); 132 m_updater->update(std::move(handle));
133 } 133 }
134 134
135 void didFinishLoading(unsigned long, double) override 135 void didFinishLoading(unsigned long, double) override
136 { 136 {
137 m_loader.reset(); 137 m_loader = nullptr;
138 } 138 }
139 139
140 void didFail(const ResourceError&) override 140 void didFail(const ResourceError&) override
141 { 141 {
142 if (!m_receivedResponse) 142 if (!m_receivedResponse)
143 m_updater->update(createUnexpectedErrorDataConsumerHandle()); 143 m_updater->update(createUnexpectedErrorDataConsumerHandle());
144 m_loader.reset(); 144 m_loader = nullptr;
145 } 145 }
146 146
147 void didFailRedirectCheck() override 147 void didFailRedirectCheck() override
148 { 148 {
149 // We don't expect redirects for Blob loading. 149 // We don't expect redirects for Blob loading.
150 ASSERT_NOT_REACHED(); 150 ASSERT_NOT_REACHED();
151 } 151 }
152 152
153 Persistent<CompositeDataConsumerHandle::Updater> m_updater; 153 Persistent<CompositeDataConsumerHandle::Updater> m_updater;
154 154
155 RefPtr<BlobDataHandle> m_blobDataHandle; 155 RefPtr<BlobDataHandle> m_blobDataHandle;
156 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory; 156 Persistent<FetchBlobDataConsumerHandle::LoaderFactory> m_loaderFactory;
157 std::unique_ptr<ThreadableLoader> m_loader; 157 Persistent<ThreadableLoader> m_loader;
158 158
159 bool m_receivedResponse; 159 bool m_receivedResponse;
160 }; 160 };
161 161
162 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac tory { 162 class DefaultLoaderFactory final : public FetchBlobDataConsumerHandle::LoaderFac tory {
163 public: 163 public:
164 std::unique_ptr<ThreadableLoader> create( 164 ThreadableLoader* create(
165 ExecutionContext& executionContext, 165 ExecutionContext& executionContext,
166 ThreadableLoaderClient* client, 166 ThreadableLoaderClient* client,
167 const ThreadableLoaderOptions& options, 167 const ThreadableLoaderOptions& options,
168 const ResourceLoaderOptions& resourceLoaderOptions) override 168 const ResourceLoaderOptions& resourceLoaderOptions) override
169 { 169 {
170 return ThreadableLoader::create(executionContext, client, options, resou rceLoaderOptions); 170 return ThreadableLoader::create(executionContext, client, options, resou rceLoaderOptions);
171 } 171 }
172 }; 172 };
173 173
174 } // namespace 174 } // namespace
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 return wrapUnique(new FetchBlobDataConsumerHandle(executionContext, blobData Handle, new DefaultLoaderFactory)); 308 return wrapUnique(new FetchBlobDataConsumerHandle(executionContext, blobData Handle, new DefaultLoaderFactory));
309 } 309 }
310 310
311 std::unique_ptr<FetchDataConsumerHandle::Reader> FetchBlobDataConsumerHandle::ob tainFetchDataReader(Client* client) 311 std::unique_ptr<FetchDataConsumerHandle::Reader> FetchBlobDataConsumerHandle::ob tainFetchDataReader(Client* client)
312 { 312 {
313 return m_readerContext->obtainReader(client); 313 return m_readerContext->obtainReader(client);
314 } 314 }
315 315
316 } // namespace blink 316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698