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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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/FetchDataLoader.h" 5 #include "modules/fetch/FetchDataLoader.h"
6 6
7 #include "core/html/parser/TextResourceDecoder.h" 7 #include "core/html/parser/TextResourceDecoder.h"
8 #include "wtf/PtrUtil.h"
8 #include "wtf/text/StringBuilder.h" 9 #include "wtf/text/StringBuilder.h"
9 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
10 #include "wtf/typed_arrays/ArrayBufferBuilder.h" 11 #include "wtf/typed_arrays/ArrayBufferBuilder.h"
12 #include <memory>
11 13
12 namespace blink { 14 namespace blink {
13 15
14 namespace { 16 namespace {
15 17
16 class FetchDataLoaderAsBlobHandle 18 class FetchDataLoaderAsBlobHandle
17 : public FetchDataLoader 19 : public FetchDataLoader
18 , public WebDataConsumerHandle::Client { 20 , public WebDataConsumerHandle::Client {
19 public: 21 public:
20 explicit FetchDataLoaderAsBlobHandle(const String& mimeType) 22 explicit FetchDataLoaderAsBlobHandle(const String& mimeType)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 96 }
95 } 97 }
96 98
97 void cancel() override 99 void cancel() override
98 { 100 {
99 m_reader.reset(); 101 m_reader.reset();
100 m_blobData.reset(); 102 m_blobData.reset();
101 m_client.clear(); 103 m_client.clear();
102 } 104 }
103 105
104 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; 106 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader;
105 Member<FetchDataLoader::Client> m_client; 107 Member<FetchDataLoader::Client> m_client;
106 108
107 String m_mimeType; 109 String m_mimeType;
108 OwnPtr<BlobData> m_blobData; 110 std::unique_ptr<BlobData> m_blobData;
109 }; 111 };
110 112
111 class FetchDataLoaderAsArrayBuffer 113 class FetchDataLoaderAsArrayBuffer
112 : public FetchDataLoader 114 : public FetchDataLoader
113 , public WebDataConsumerHandle::Client { 115 , public WebDataConsumerHandle::Client {
114 public: 116 public:
115 FetchDataLoaderAsArrayBuffer() 117 FetchDataLoaderAsArrayBuffer()
116 : m_client(nullptr) { } 118 : m_client(nullptr) { }
117 119
118 DEFINE_INLINE_VIRTUAL_TRACE() 120 DEFINE_INLINE_VIRTUAL_TRACE()
119 { 121 {
120 FetchDataLoader::trace(visitor); 122 FetchDataLoader::trace(visitor);
121 visitor->trace(m_client); 123 visitor->trace(m_client);
122 } 124 }
123 125
124 protected: 126 protected:
125 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client) override 127 void start(FetchDataConsumerHandle* handle, FetchDataLoader::Client* client) override
126 { 128 {
127 ASSERT(!m_client); 129 ASSERT(!m_client);
128 ASSERT(!m_rawData); 130 ASSERT(!m_rawData);
129 ASSERT(!m_reader); 131 ASSERT(!m_reader);
130 m_client = client; 132 m_client = client;
131 m_rawData = adoptPtr(new ArrayBufferBuilder()); 133 m_rawData = wrapUnique(new ArrayBufferBuilder());
132 m_reader = handle->obtainReader(this); 134 m_reader = handle->obtainReader(this);
133 } 135 }
134 136
135 void didGetReadable() override 137 void didGetReadable() override
136 { 138 {
137 ASSERT(m_client); 139 ASSERT(m_client);
138 ASSERT(m_rawData); 140 ASSERT(m_rawData);
139 ASSERT(m_reader); 141 ASSERT(m_reader);
140 142
141 while (true) { 143 while (true) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 m_client.clear(); 186 m_client.clear();
185 } 187 }
186 188
187 void cancel() override 189 void cancel() override
188 { 190 {
189 m_reader.reset(); 191 m_reader.reset();
190 m_rawData.reset(); 192 m_rawData.reset();
191 m_client.clear(); 193 m_client.clear();
192 } 194 }
193 195
194 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; 196 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader;
195 Member<FetchDataLoader::Client> m_client; 197 Member<FetchDataLoader::Client> m_client;
196 198
197 OwnPtr<ArrayBufferBuilder> m_rawData; 199 std::unique_ptr<ArrayBufferBuilder> m_rawData;
198 }; 200 };
199 201
200 class FetchDataLoaderAsString 202 class FetchDataLoaderAsString
201 : public FetchDataLoader 203 : public FetchDataLoader
202 , public WebDataConsumerHandle::Client { 204 , public WebDataConsumerHandle::Client {
203 public: 205 public:
204 FetchDataLoaderAsString() 206 FetchDataLoaderAsString()
205 : m_client(nullptr) { } 207 : m_client(nullptr) { }
206 208
207 DEFINE_INLINE_VIRTUAL_TRACE() 209 DEFINE_INLINE_VIRTUAL_TRACE()
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 272 }
271 273
272 void cancel() override 274 void cancel() override
273 { 275 {
274 m_reader.reset(); 276 m_reader.reset();
275 m_builder.clear(); 277 m_builder.clear();
276 m_decoder.reset(); 278 m_decoder.reset();
277 m_client.clear(); 279 m_client.clear();
278 } 280 }
279 281
280 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; 282 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader;
281 Member<FetchDataLoader::Client> m_client; 283 Member<FetchDataLoader::Client> m_client;
282 284
283 OwnPtr<TextResourceDecoder> m_decoder; 285 std::unique_ptr<TextResourceDecoder> m_decoder;
284 StringBuilder m_builder; 286 StringBuilder m_builder;
285 }; 287 };
286 288
287 class FetchDataLoaderAsStream 289 class FetchDataLoaderAsStream
288 : public FetchDataLoader 290 : public FetchDataLoader
289 , public WebDataConsumerHandle::Client { 291 , public WebDataConsumerHandle::Client {
290 public: 292 public:
291 explicit FetchDataLoaderAsStream(Stream* outStream) 293 explicit FetchDataLoaderAsStream(Stream* outStream)
292 : m_client(nullptr) 294 : m_client(nullptr)
293 , m_outStream(outStream) { } 295 , m_outStream(outStream) { }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 cleanup(); 364 cleanup();
363 } 365 }
364 366
365 void cleanup() 367 void cleanup()
366 { 368 {
367 m_reader.reset(); 369 m_reader.reset();
368 m_client.clear(); 370 m_client.clear();
369 m_outStream.clear(); 371 m_outStream.clear();
370 } 372 }
371 373
372 OwnPtr<FetchDataConsumerHandle::Reader> m_reader; 374 std::unique_ptr<FetchDataConsumerHandle::Reader> m_reader;
373 Member<FetchDataLoader::Client> m_client; 375 Member<FetchDataLoader::Client> m_client;
374 376
375 Member<Stream> m_outStream; 377 Member<Stream> m_outStream;
376 }; 378 };
377 379
378 380
379 } // namespace 381 } // namespace
380 382
381 FetchDataLoader* FetchDataLoader::createLoaderAsBlobHandle(const String& mimeTyp e) 383 FetchDataLoader* FetchDataLoader::createLoaderAsBlobHandle(const String& mimeTyp e)
382 { 384 {
383 return new FetchDataLoaderAsBlobHandle(mimeType); 385 return new FetchDataLoaderAsBlobHandle(mimeType);
384 } 386 }
385 387
386 FetchDataLoader* FetchDataLoader::createLoaderAsArrayBuffer() 388 FetchDataLoader* FetchDataLoader::createLoaderAsArrayBuffer()
387 { 389 {
388 return new FetchDataLoaderAsArrayBuffer(); 390 return new FetchDataLoaderAsArrayBuffer();
389 } 391 }
390 392
391 FetchDataLoader* FetchDataLoader::createLoaderAsString() 393 FetchDataLoader* FetchDataLoader::createLoaderAsString()
392 { 394 {
393 return new FetchDataLoaderAsString(); 395 return new FetchDataLoaderAsString();
394 } 396 }
395 397
396 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream) 398 FetchDataLoader* FetchDataLoader::createLoaderAsStream(Stream* outStream)
397 { 399 {
398 return new FetchDataLoaderAsStream(outStream); 400 return new FetchDataLoaderAsStream(outStream);
399 } 401 }
400 402
401 } // namespace blink 403 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698