Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 26 matching lines...) Expand all Loading... | |
| 37 #include "core/fileapi/Blob.h" | 37 #include "core/fileapi/Blob.h" |
| 38 #include "public/platform/WebFileWriter.h" | 38 #include "public/platform/WebFileWriter.h" |
| 39 #include "public/platform/WebURL.h" | 39 #include "public/platform/WebURL.h" |
| 40 #include "wtf/CurrentTime.h" | 40 #include "wtf/CurrentTime.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 static const int kMaxRecursionDepth = 3; | 44 static const int kMaxRecursionDepth = 3; |
| 45 static const double progressNotificationIntervalMS = 50; | 45 static const double progressNotificationIntervalMS = 50; |
| 46 | 46 |
| 47 PassRefPtr<FileWriter> FileWriter::create(ExecutionContext* context) | 47 PassRefPtrWillBeRawPtr<FileWriter> FileWriter::create(ExecutionContext* context) |
| 48 { | 48 { |
| 49 RefPtr<FileWriter> fileWriter(adoptRef(new FileWriter(context))); | 49 RefPtrWillBeRawPtr<FileWriter> fileWriter(adoptRefWillBeRefCountedGarbageCol lected(new FileWriter(context))); |
| 50 fileWriter->suspendIfNeeded(); | 50 fileWriter->suspendIfNeeded(); |
| 51 return fileWriter.release(); | 51 return fileWriter.release(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 FileWriter::FileWriter(ExecutionContext* context) | 54 FileWriter::FileWriter(ExecutionContext* context) |
| 55 : ActiveDOMObject(context) | 55 : ActiveDOMObject(context) |
| 56 , m_readyState(INIT) | 56 , m_readyState(INIT) |
| 57 , m_operationInProgress(OperationNone) | 57 , m_operationInProgress(OperationNone) |
| 58 , m_queuedOperation(OperationNone) | 58 , m_queuedOperation(OperationNone) |
| 59 , m_bytesWritten(0) | 59 , m_bytesWritten(0) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 ASSERT(m_truncateLength == -1); | 274 ASSERT(m_truncateLength == -1); |
| 275 ASSERT(!m_blobBeingWritten.get()); | 275 ASSERT(!m_blobBeingWritten.get()); |
| 276 ASSERT(m_readyState == DONE); | 276 ASSERT(m_readyState == DONE); |
| 277 break; | 277 break; |
| 278 case OperationAbort: | 278 case OperationAbort: |
| 279 if (m_operationInProgress == OperationWrite || m_operationInProgress == OperationTruncate) | 279 if (m_operationInProgress == OperationWrite || m_operationInProgress == OperationTruncate) |
| 280 writer()->cancel(); | 280 writer()->cancel(); |
| 281 else if (m_operationInProgress != OperationAbort) | 281 else if (m_operationInProgress != OperationAbort) |
| 282 operation = OperationNone; | 282 operation = OperationNone; |
| 283 m_queuedOperation = OperationNone; | 283 m_queuedOperation = OperationNone; |
| 284 m_blobBeingWritten.clear(); | 284 m_blobBeingWritten.clear(); |
|
haraken
2014/03/07 08:24:35
This looks dangerous.
FileWriter's destructor cal
sof
2014/03/07 09:37:36
Very well spotted, but isn't this OK, really? i.e.
| |
| 285 m_truncateLength = -1; | 285 m_truncateLength = -1; |
| 286 break; | 286 break; |
| 287 } | 287 } |
| 288 ASSERT(m_queuedOperation == OperationNone); | 288 ASSERT(m_queuedOperation == OperationNone); |
| 289 m_operationInProgress = operation; | 289 m_operationInProgress = operation; |
| 290 } | 290 } |
| 291 | 291 |
| 292 void FileWriter::signalCompletion(FileError::ErrorCode code) | 292 void FileWriter::signalCompletion(FileError::ErrorCode code) |
| 293 { | 293 { |
| 294 m_readyState = DONE; | 294 m_readyState = DONE; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 312 ASSERT(m_recursionDepth >= 0); | 312 ASSERT(m_recursionDepth >= 0); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void FileWriter::setError(FileError::ErrorCode errorCode, ExceptionState& except ionState) | 315 void FileWriter::setError(FileError::ErrorCode errorCode, ExceptionState& except ionState) |
| 316 { | 316 { |
| 317 ASSERT(errorCode); | 317 ASSERT(errorCode); |
| 318 FileError::throwDOMException(exceptionState, errorCode); | 318 FileError::throwDOMException(exceptionState, errorCode); |
| 319 m_error = FileError::create(errorCode); | 319 m_error = FileError::create(errorCode); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void FileWriter::trace(Visitor* visitor) | |
| 323 { | |
| 324 visitor->trace(m_error); | |
| 325 visitor->trace(m_blobBeingWritten); | |
| 326 FileWriterBase::trace(visitor); | |
| 327 } | |
| 328 | |
| 322 } // namespace WebCore | 329 } // namespace WebCore |
| OLD | NEW |