| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 FileWriter::~FileWriter() { | 62 FileWriter::~FileWriter() { |
| 63 ASSERT(!m_recursionDepth); | 63 ASSERT(!m_recursionDepth); |
| 64 DCHECK(!writer()); | 64 DCHECK(!writer()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 const AtomicString& FileWriter::interfaceName() const { | 67 const AtomicString& FileWriter::interfaceName() const { |
| 68 return EventTargetNames::FileWriter; | 68 return EventTargetNames::FileWriter; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void FileWriter::contextDestroyed() { | 71 void FileWriter::contextDestroyed(ExecutionContext*) { |
| 72 // Make sure we've actually got something to stop, and haven't already called | 72 dispose(); |
| 73 // abort(). | |
| 74 if (writer() && m_readyState == kWriting) { | |
| 75 doOperation(OperationAbort); | |
| 76 m_readyState = kDone; | |
| 77 } | |
| 78 resetWriter(); | |
| 79 } | 73 } |
| 80 | 74 |
| 81 bool FileWriter::hasPendingActivity() const { | 75 bool FileWriter::hasPendingActivity() const { |
| 82 return m_operationInProgress != OperationNone || | 76 return m_operationInProgress != OperationNone || |
| 83 m_queuedOperation != OperationNone || m_readyState == kWriting; | 77 m_queuedOperation != OperationNone || m_readyState == kWriting; |
| 84 } | 78 } |
| 85 | 79 |
| 86 void FileWriter::write(Blob* data, ExceptionState& exceptionState) { | 80 void FileWriter::write(Blob* data, ExceptionState& exceptionState) { |
| 87 if (!getExecutionContext()) | 81 if (!getExecutionContext()) |
| 88 return; | 82 return; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 300 } |
| 307 | 301 |
| 308 void FileWriter::setError(FileError::ErrorCode errorCode, | 302 void FileWriter::setError(FileError::ErrorCode errorCode, |
| 309 ExceptionState& exceptionState) { | 303 ExceptionState& exceptionState) { |
| 310 ASSERT(errorCode); | 304 ASSERT(errorCode); |
| 311 FileError::throwDOMException(exceptionState, errorCode); | 305 FileError::throwDOMException(exceptionState, errorCode); |
| 312 m_error = FileError::createDOMException(errorCode); | 306 m_error = FileError::createDOMException(errorCode); |
| 313 } | 307 } |
| 314 | 308 |
| 315 void FileWriter::dispose() { | 309 void FileWriter::dispose() { |
| 316 contextDestroyed(); | 310 // Make sure we've actually got something to stop, and haven't already called |
| 311 // abort(). |
| 312 if (writer() && m_readyState == kWriting) { |
| 313 doOperation(OperationAbort); |
| 314 m_readyState = kDone; |
| 315 } |
| 316 resetWriter(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 DEFINE_TRACE(FileWriter) { | 319 DEFINE_TRACE(FileWriter) { |
| 320 visitor->trace(m_error); | 320 visitor->trace(m_error); |
| 321 visitor->trace(m_blobBeingWritten); | 321 visitor->trace(m_blobBeingWritten); |
| 322 EventTargetWithInlineData::trace(visitor); | 322 EventTargetWithInlineData::trace(visitor); |
| 323 FileWriterBase::trace(visitor); | 323 FileWriterBase::trace(visitor); |
| 324 ContextLifecycleObserver::trace(visitor); | 324 ContextLifecycleObserver::trace(visitor); |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace blink | 327 } // namespace blink |
| OLD | NEW |