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

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

Issue 2308343002: Replaced PassRefPtr copites with moves in Source/modules. (Closed)
Patch Set: Created 4 years, 3 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/FetchFormDataConsumerHandle.h" 5 #include "modules/fetch/FetchFormDataConsumerHandle.h"
6 6
7 #include "modules/fetch/DataConsumerHandleUtil.h" 7 #include "modules/fetch/DataConsumerHandleUtil.h"
8 #include "modules/fetch/FetchBlobDataConsumerHandle.h" 8 #include "modules/fetch/FetchBlobDataConsumerHandle.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 #include "wtf/ThreadingPrimitives.h" 10 #include "wtf/ThreadingPrimitives.h"
(...skipping 29 matching lines...) Expand all
40 40
41 protected: 41 protected:
42 explicit Context() {} 42 explicit Context() {}
43 }; 43 };
44 44
45 class FetchFormDataConsumerHandle::SimpleContext final : public Context { 45 class FetchFormDataConsumerHandle::SimpleContext final : public Context {
46 class ReaderImpl; 46 class ReaderImpl;
47 public: 47 public:
48 static PassRefPtr<SimpleContext> create(const String& body) { return adoptRe f(new SimpleContext(body)); } 48 static PassRefPtr<SimpleContext> create(const String& body) { return adoptRe f(new SimpleContext(body)); }
49 static PassRefPtr<SimpleContext> create(const void* data, size_t size) { ret urn adoptRef(new SimpleContext(data, size)); } 49 static PassRefPtr<SimpleContext> create(const void* data, size_t size) { ret urn adoptRef(new SimpleContext(data, size)); }
50 static PassRefPtr<SimpleContext> create(PassRefPtr<EncodedFormData> body) { return adoptRef(new SimpleContext(body)); } 50 static PassRefPtr<SimpleContext> create(PassRefPtr<EncodedFormData> body) { return adoptRef(new SimpleContext(std::move(body))); }
51 51
52 std::unique_ptr<Reader> obtainReader(Client* client) override 52 std::unique_ptr<Reader> obtainReader(Client* client) override
53 { 53 {
54 // For memory barrier. 54 // For memory barrier.
55 Mutex m; 55 Mutex m;
56 MutexLocker locker(m); 56 MutexLocker locker(m);
57 return ReaderImpl::create(this, client); 57 return ReaderImpl::create(this, client);
58 } 58 }
59 59
60 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle() 60 PassRefPtr<BlobDataHandle> drainAsBlobDataHandle()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 RELEASE_ASSERT(read <= m_flattenFormData.size() - m_flattenFormDataOffse t); 115 RELEASE_ASSERT(read <= m_flattenFormData.size() - m_flattenFormDataOffse t);
116 m_flattenFormDataOffset += read; 116 m_flattenFormDataOffset += read;
117 117
118 return WebDataConsumerHandle::Ok; 118 return WebDataConsumerHandle::Ok;
119 } 119 }
120 120
121 private: 121 private:
122 class ReaderImpl final : public FetchDataConsumerHandle::Reader { 122 class ReaderImpl final : public FetchDataConsumerHandle::Reader {
123 WTF_MAKE_NONCOPYABLE(ReaderImpl); 123 WTF_MAKE_NONCOPYABLE(ReaderImpl);
124 public: 124 public:
125 static std::unique_ptr<ReaderImpl> create(PassRefPtr<SimpleContext> cont ext, Client* client) { return wrapUnique(new ReaderImpl(context, client)); } 125 static std::unique_ptr<ReaderImpl> create(PassRefPtr<SimpleContext> cont ext, Client* client) { return wrapUnique(new ReaderImpl(std::move(context), clie nt)); }
126 Result read(void* data, size_t size, Flags flags, size_t* readSize) over ride 126 Result read(void* data, size_t size, Flags flags, size_t* readSize) over ride
127 { 127 {
128 return m_context->read(data, size, flags, readSize); 128 return m_context->read(data, size, flags, readSize);
129 } 129 }
130 Result beginRead(const void** buffer, Flags flags, size_t* available) ov erride 130 Result beginRead(const void** buffer, Flags flags, size_t* available) ov erride
131 { 131 {
132 return m_context->beginRead(buffer, flags, available); 132 return m_context->beginRead(buffer, flags, available);
133 } 133 }
134 Result endRead(size_t read) override 134 Result endRead(size_t read) override
135 { 135 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 size_t m_flattenFormDataOffset; 175 size_t m_flattenFormDataOffset;
176 }; 176 };
177 177
178 class FetchFormDataConsumerHandle::ComplexContext final : public Context { 178 class FetchFormDataConsumerHandle::ComplexContext final : public Context {
179 class ReaderImpl; 179 class ReaderImpl;
180 public: 180 public:
181 static PassRefPtr<ComplexContext> create(ExecutionContext* executionContext, 181 static PassRefPtr<ComplexContext> create(ExecutionContext* executionContext,
182 PassRefPtr<EncodedFormData> formData, 182 PassRefPtr<EncodedFormData> formData,
183 FetchBlobDataConsumerHandle::LoaderFactory* factory) 183 FetchBlobDataConsumerHandle::LoaderFactory* factory)
184 { 184 {
185 return adoptRef(new ComplexContext(executionContext, formData, factory)) ; 185 return adoptRef(new ComplexContext(executionContext, std::move(formData) , factory));
186 } 186 }
187 187
188 std::unique_ptr<FetchFormDataConsumerHandle::Reader> obtainReader(Client* cl ient) override 188 std::unique_ptr<FetchFormDataConsumerHandle::Reader> obtainReader(Client* cl ient) override
189 { 189 {
190 // For memory barrier. 190 // For memory barrier.
191 Mutex m; 191 Mutex m;
192 MutexLocker locker(m); 192 MutexLocker locker(m);
193 return ReaderImpl::create(this, client); 193 return ReaderImpl::create(this, client);
194 } 194 }
195 195
196 private: 196 private:
197 class ReaderImpl final : public FetchDataConsumerHandle::Reader { 197 class ReaderImpl final : public FetchDataConsumerHandle::Reader {
198 WTF_MAKE_NONCOPYABLE(ReaderImpl); 198 WTF_MAKE_NONCOPYABLE(ReaderImpl);
199 public: 199 public:
200 static std::unique_ptr<ReaderImpl> create(PassRefPtr<ComplexContext> con text, Client* client) { return wrapUnique(new ReaderImpl(context, client)); } 200 static std::unique_ptr<ReaderImpl> create(PassRefPtr<ComplexContext> con text, Client* client) { return wrapUnique(new ReaderImpl(std::move(context), cli ent)); }
201 Result read(void* data, size_t size, Flags flags, size_t* readSize) over ride 201 Result read(void* data, size_t size, Flags flags, size_t* readSize) over ride
202 { 202 {
203 Result r = m_reader->read(data, size, flags, readSize); 203 Result r = m_reader->read(data, size, flags, readSize);
204 if (!(size == 0 && (r == Ok || r == ShouldWait))) { 204 if (!(size == 0 && (r == Ok || r == ShouldWait))) {
205 m_context->drainFormData(); 205 m_context->drainFormData();
206 } 206 }
207 return r; 207 return r;
208 } 208 }
209 Result beginRead(const void** buffer, Flags flags, size_t* available) ov erride 209 Result beginRead(const void** buffer, Flags flags, size_t* available) ov erride
210 { 210 {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(DOM ArrayBufferView* body) 299 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(DOM ArrayBufferView* body)
300 { 300 {
301 return wrapUnique(new FetchFormDataConsumerHandle(body->baseAddress(), body- >byteLength())); 301 return wrapUnique(new FetchFormDataConsumerHandle(body->baseAddress(), body- >byteLength()));
302 } 302 }
303 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(con st void* data, size_t size) 303 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(con st void* data, size_t size)
304 { 304 {
305 return wrapUnique(new FetchFormDataConsumerHandle(data, size)); 305 return wrapUnique(new FetchFormDataConsumerHandle(data, size));
306 } 306 }
307 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(Exe cutionContext* executionContext, PassRefPtr<EncodedFormData> body) 307 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::create(Exe cutionContext* executionContext, PassRefPtr<EncodedFormData> body)
308 { 308 {
309 return wrapUnique(new FetchFormDataConsumerHandle(executionContext, body)); 309 return wrapUnique(new FetchFormDataConsumerHandle(executionContext, std::mov e(body)));
310 } 310 }
311 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::createForT est( 311 std::unique_ptr<FetchDataConsumerHandle> FetchFormDataConsumerHandle::createForT est(
312 ExecutionContext* executionContext, 312 ExecutionContext* executionContext,
313 PassRefPtr<EncodedFormData> body, 313 PassRefPtr<EncodedFormData> body,
314 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) 314 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory)
315 { 315 {
316 return wrapUnique(new FetchFormDataConsumerHandle(executionContext, body, lo aderFactory)); 316 return wrapUnique(new FetchFormDataConsumerHandle(executionContext, std::mov e(body), loaderFactory));
317 } 317 }
318 318
319 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(const String& body) : m _context(SimpleContext::create(body)) {} 319 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(const String& body) : m _context(SimpleContext::create(body)) {}
320 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(const void* data, size_ t size) : m_context(SimpleContext::create(data, size)) {} 320 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(const void* data, size_ t size) : m_context(SimpleContext::create(data, size)) {}
321 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(ExecutionContext* execu tionContext, 321 FetchFormDataConsumerHandle::FetchFormDataConsumerHandle(ExecutionContext* execu tionContext,
322 PassRefPtr<EncodedFormData> body, 322 PassRefPtr<EncodedFormData> body,
323 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory) 323 FetchBlobDataConsumerHandle::LoaderFactory* loaderFactory)
324 { 324 {
325 if (isSimple(body.get())) { 325 if (isSimple(body.get())) {
326 m_context = SimpleContext::create(body); 326 m_context = SimpleContext::create(std::move(body));
327 } else { 327 } else {
328 m_context = ComplexContext::create(executionContext, body, loaderFactory ); 328 m_context = ComplexContext::create(executionContext, std::move(body), lo aderFactory);
329 } 329 }
330 } 330 }
331 FetchFormDataConsumerHandle::~FetchFormDataConsumerHandle() {} 331 FetchFormDataConsumerHandle::~FetchFormDataConsumerHandle() {}
332 332
333 std::unique_ptr<FetchDataConsumerHandle::Reader> FetchFormDataConsumerHandle::ob tainFetchDataReader(Client* client) 333 std::unique_ptr<FetchDataConsumerHandle::Reader> FetchFormDataConsumerHandle::ob tainFetchDataReader(Client* client)
334 { 334 {
335 return m_context->obtainReader(client); 335 return m_context->obtainReader(client);
336 } 336 }
337 337
338 } // namespace blink 338 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698