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

Side by Side Diff: Source/core/fileapi/FileReader.cpp

Issue 157363003: Implement Blob.close(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 10 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
« no previous file with comments | « Source/core/fileapi/FileReader.h ('k') | Source/core/html/PublicURLManager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep tionState& exceptionState) 215 void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep tionState& exceptionState)
216 { 216 {
217 // If multiple concurrent read methods are called on the same FileReader, In validStateError should be thrown when the state is LOADING. 217 // If multiple concurrent read methods are called on the same FileReader, In validStateError should be thrown when the state is LOADING.
218 if (m_state == LOADING) { 218 if (m_state == LOADING) {
219 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs."); 219 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs.");
220 return; 220 return;
221 } 221 }
222 222
223 m_blob = blob; 223 if (blob->hasBeenClosed()) {
224 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile( ) ? "File" : "Blob") + " has been closed.");
225 return;
226 }
227
228 // "Snapshot" the Blob data rather than the Blob itself as ongoing
229 // read operations should not be affected if close() is called on
230 // the Blob being read.
231 m_blobDataHandle = blob->blobDataHandle();
232 m_blobType = blob->type();
224 m_readType = type; 233 m_readType = type;
225 m_state = LOADING; 234 m_state = LOADING;
226 m_loadingState = LoadingStatePending; 235 m_loadingState = LoadingStatePending;
227 m_error = nullptr; 236 m_error = nullptr;
228 throttlingController()->pushReader(this); 237 throttlingController()->pushReader(this);
229 } 238 }
230 239
231 void FileReader::executePendingRead() 240 void FileReader::executePendingRead()
232 { 241 {
233 ASSERT(m_loadingState == LoadingStatePending); 242 ASSERT(m_loadingState == LoadingStatePending);
234 m_loadingState = LoadingStateLoading; 243 m_loadingState = LoadingStateLoading;
235 244
236 m_loader = adoptPtr(new FileReaderLoader(m_readType, this)); 245 m_loader = adoptPtr(new FileReaderLoader(m_readType, this));
237 m_loader->setEncoding(m_encoding); 246 m_loader->setEncoding(m_encoding);
238 m_loader->setDataType(m_blob->type()); 247 m_loader->setDataType(m_blobType);
239 m_loader->start(executionContext(), m_blob->blobDataHandle()); 248 m_loader->start(executionContext(), m_blobDataHandle);
249 m_blobDataHandle = nullptr;
240 } 250 }
241 251
242 static void delayedAbort(ExecutionContext*, FileReader* reader) 252 static void delayedAbort(ExecutionContext*, FileReader* reader)
243 { 253 {
244 reader->doAbort(); 254 reader->doAbort();
245 } 255 }
246 256
247 void FileReader::abort() 257 void FileReader::abort()
248 { 258 {
249 WTF_LOG(FileAPI, "FileReader: aborting\n"); 259 WTF_LOG(FileAPI, "FileReader: aborting\n");
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 380 }
371 381
372 String FileReader::stringResult() 382 String FileReader::stringResult()
373 { 383 {
374 if (!m_loader || m_error) 384 if (!m_loader || m_error)
375 return String(); 385 return String();
376 return m_loader->stringResult(); 386 return m_loader->stringResult();
377 } 387 }
378 388
379 } // namespace WebCore 389 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/fileapi/FileReader.h ('k') | Source/core/html/PublicURLManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698