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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/FileReaderLoader.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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 #include "core/fileapi/Blob.h" 36 #include "core/fileapi/Blob.h"
37 #include "core/fileapi/FileReaderLoaderClient.h" 37 #include "core/fileapi/FileReaderLoaderClient.h"
38 #include "core/html/parser/TextResourceDecoder.h" 38 #include "core/html/parser/TextResourceDecoder.h"
39 #include "core/loader/ThreadableLoader.h" 39 #include "core/loader/ThreadableLoader.h"
40 #include "core/streams/Stream.h" 40 #include "core/streams/Stream.h"
41 #include "platform/blob/BlobRegistry.h" 41 #include "platform/blob/BlobRegistry.h"
42 #include "platform/blob/BlobURL.h" 42 #include "platform/blob/BlobURL.h"
43 #include "platform/network/ResourceRequest.h" 43 #include "platform/network/ResourceRequest.h"
44 #include "platform/network/ResourceResponse.h" 44 #include "platform/network/ResourceResponse.h"
45 #include "public/platform/WebURLRequest.h" 45 #include "public/platform/WebURLRequest.h"
46 #include "wtf/PassOwnPtr.h"
47 #include "wtf/PassRefPtr.h" 46 #include "wtf/PassRefPtr.h"
47 #include "wtf/PtrUtil.h"
48 #include "wtf/RefPtr.h" 48 #include "wtf/RefPtr.h"
49 #include "wtf/Vector.h" 49 #include "wtf/Vector.h"
50 #include "wtf/text/Base64.h" 50 #include "wtf/text/Base64.h"
51 #include "wtf/text/StringBuilder.h" 51 #include "wtf/text/StringBuilder.h"
52 #include <memory>
52 53
53 namespace blink { 54 namespace blink {
54 55
55 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl ient) 56 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl ient)
56 : m_readType(readType) 57 : m_readType(readType)
57 , m_client(client) 58 , m_client(client)
58 , m_urlForReadingIsStream(false) 59 , m_urlForReadingIsStream(false)
59 , m_isRawDataConverted(false) 60 , m_isRawDataConverted(false)
60 , m_stringResult("") 61 , m_stringResult("")
61 , m_finishedLoading(false) 62 , m_finishedLoading(false)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 167
167 // If we get any error, we do not need to keep a buffer around. 168 // If we get any error, we do not need to keep a buffer around.
168 if (m_errorCode) { 169 if (m_errorCode) {
169 m_rawData.reset(); 170 m_rawData.reset();
170 m_stringResult = ""; 171 m_stringResult = "";
171 m_isRawDataConverted = true; 172 m_isRawDataConverted = true;
172 m_decoder.reset(); 173 m_decoder.reset();
173 } 174 }
174 } 175 }
175 176
176 void FileReaderLoader::didReceiveResponse(unsigned long, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle) 177 void FileReaderLoader::didReceiveResponse(unsigned long, const ResourceResponse& response, std::unique_ptr<WebDataConsumerHandle> handle)
177 { 178 {
178 ASSERT_UNUSED(handle, !handle); 179 ASSERT_UNUSED(handle, !handle);
179 if (response.httpStatusCode() != 200) { 180 if (response.httpStatusCode() != 200) {
180 failed(httpStatusCodeToErrorCode(response.httpStatusCode())); 181 failed(httpStatusCodeToErrorCode(response.httpStatusCode()));
181 return; 182 return;
182 } 183 }
183 184
184 // A negative value means that the content length wasn't specified. 185 // A negative value means that the content length wasn't specified.
185 m_totalBytes = response.expectedContentLength(); 186 m_totalBytes = response.expectedContentLength();
186 187
(...skipping 17 matching lines...) Expand all
204 if (m_readType != ReadByClient) { 205 if (m_readType != ReadByClient) {
205 // Check that we can cast to unsigned since we have to do 206 // Check that we can cast to unsigned since we have to do
206 // so to call ArrayBuffer's create function. 207 // so to call ArrayBuffer's create function.
207 // FIXME: Support reading more than the current size limit of ArrayBuffe r. 208 // FIXME: Support reading more than the current size limit of ArrayBuffe r.
208 if (initialBufferLength > std::numeric_limits<unsigned>::max()) { 209 if (initialBufferLength > std::numeric_limits<unsigned>::max()) {
209 failed(FileError::NOT_READABLE_ERR); 210 failed(FileError::NOT_READABLE_ERR);
210 return; 211 return;
211 } 212 }
212 213
213 if (initialBufferLength < 0) 214 if (initialBufferLength < 0)
214 m_rawData = adoptPtr(new ArrayBufferBuilder()); 215 m_rawData = wrapUnique(new ArrayBufferBuilder());
215 else 216 else
216 m_rawData = adoptPtr(new ArrayBufferBuilder(static_cast<unsigned>(in itialBufferLength))); 217 m_rawData = wrapUnique(new ArrayBufferBuilder(static_cast<unsigned>( initialBufferLength)));
217 218
218 if (!m_rawData || !m_rawData->isValid()) { 219 if (!m_rawData || !m_rawData->isValid()) {
219 failed(FileError::NOT_READABLE_ERR); 220 failed(FileError::NOT_READABLE_ERR);
220 return; 221 return;
221 } 222 }
222 223
223 if (initialBufferLength >= 0) { 224 if (initialBufferLength >= 0) {
224 // Total size is known. Set m_rawData to ignore overflowed data. 225 // Total size is known. Set m_rawData to ignore overflowed data.
225 m_rawData->setVariableCapacity(false); 226 m_rawData->setVariableCapacity(false);
226 } 227 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 m_stringResult = builder.toString(); 403 m_stringResult = builder.toString();
403 } 404 }
404 405
405 void FileReaderLoader::setEncoding(const String& encoding) 406 void FileReaderLoader::setEncoding(const String& encoding)
406 { 407 {
407 if (!encoding.isEmpty()) 408 if (!encoding.isEmpty())
408 m_encoding = WTF::TextEncoding(encoding); 409 m_encoding = WTF::TextEncoding(encoding);
409 } 410 }
410 411
411 } // namespace blink 412 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderLoader.h ('k') | third_party/WebKit/Source/core/frame/DOMTimer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698