| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 , ActiveDOMObject(context) | 56 , ActiveDOMObject(context) |
| 57 , m_readyState(INIT) | 57 , m_readyState(INIT) |
| 58 , m_operationInProgress(OperationNone) | 58 , m_operationInProgress(OperationNone) |
| 59 , m_queuedOperation(OperationNone) | 59 , m_queuedOperation(OperationNone) |
| 60 , m_bytesWritten(0) | 60 , m_bytesWritten(0) |
| 61 , m_bytesToWrite(0) | 61 , m_bytesToWrite(0) |
| 62 , m_truncateLength(-1) | 62 , m_truncateLength(-1) |
| 63 , m_numAborts(0) | 63 , m_numAborts(0) |
| 64 , m_recursionDepth(0) | 64 , m_recursionDepth(0) |
| 65 , m_lastProgressNotificationTimeMS(0) | 65 , m_lastProgressNotificationTimeMS(0) |
| 66 , m_asyncOperationId(0) | |
| 67 { | 66 { |
| 68 } | 67 } |
| 69 | 68 |
| 70 FileWriter::~FileWriter() | 69 FileWriter::~FileWriter() |
| 71 { | 70 { |
| 72 ASSERT(!m_recursionDepth); | 71 ASSERT(!m_recursionDepth); |
| 73 if (m_readyState == WRITING) | 72 if (m_readyState == WRITING) |
| 74 stop(); | 73 stop(); |
| 75 } | 74 } |
| 76 | 75 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 { | 242 { |
| 244 ASSERT(m_operationInProgress == OperationAbort); | 243 ASSERT(m_operationInProgress == OperationAbort); |
| 245 m_operationInProgress = OperationNone; | 244 m_operationInProgress = OperationNone; |
| 246 Operation operation = m_queuedOperation; | 245 Operation operation = m_queuedOperation; |
| 247 m_queuedOperation = OperationNone; | 246 m_queuedOperation = OperationNone; |
| 248 doOperation(operation); | 247 doOperation(operation); |
| 249 } | 248 } |
| 250 | 249 |
| 251 void FileWriter::doOperation(Operation operation) | 250 void FileWriter::doOperation(Operation operation) |
| 252 { | 251 { |
| 253 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarting(g
etExecutionContext(), "FileWriter", m_asyncOperationId); | 252 InspectorInstrumentation::asyncTaskScheduled(getExecutionContext(), "FileWri
ter", this); |
| 254 switch (operation) { | 253 switch (operation) { |
| 255 case OperationWrite: | 254 case OperationWrite: |
| 256 ASSERT(m_operationInProgress == OperationNone); | 255 ASSERT(m_operationInProgress == OperationNone); |
| 257 ASSERT(m_truncateLength == -1); | 256 ASSERT(m_truncateLength == -1); |
| 258 ASSERT(m_blobBeingWritten.get()); | 257 ASSERT(m_blobBeingWritten.get()); |
| 259 ASSERT(m_readyState == WRITING); | 258 ASSERT(m_readyState == WRITING); |
| 260 writer()->write(position(), m_blobBeingWritten->uuid()); | 259 writer()->write(position(), m_blobBeingWritten->uuid()); |
| 261 break; | 260 break; |
| 262 case OperationTruncate: | 261 case OperationTruncate: |
| 263 ASSERT(m_operationInProgress == OperationNone); | 262 ASSERT(m_operationInProgress == OperationNone); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 292 if (FileError::OK != code) { | 291 if (FileError::OK != code) { |
| 293 m_error = FileError::create(code); | 292 m_error = FileError::create(code); |
| 294 if (FileError::ABORT_ERR == code) | 293 if (FileError::ABORT_ERR == code) |
| 295 fireEvent(EventTypeNames::abort); | 294 fireEvent(EventTypeNames::abort); |
| 296 else | 295 else |
| 297 fireEvent(EventTypeNames::error); | 296 fireEvent(EventTypeNames::error); |
| 298 } else | 297 } else |
| 299 fireEvent(EventTypeNames::write); | 298 fireEvent(EventTypeNames::write); |
| 300 fireEvent(EventTypeNames::writeend); | 299 fireEvent(EventTypeNames::writeend); |
| 301 | 300 |
| 302 InspectorInstrumentation::traceAsyncOperationCompleted(getExecutionContext()
, m_asyncOperationId); | 301 InspectorInstrumentation::asyncTaskCanceled(getExecutionContext(), this); |
| 303 m_asyncOperationId = 0; | |
| 304 } | 302 } |
| 305 | 303 |
| 306 void FileWriter::fireEvent(const AtomicString& type) | 304 void FileWriter::fireEvent(const AtomicString& type) |
| 307 { | 305 { |
| 308 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
CallbackStarting(getExecutionContext(), m_asyncOperationId); | 306 InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), this); |
| 309 ++m_recursionDepth; | 307 ++m_recursionDepth; |
| 310 dispatchEvent(ProgressEvent::create(type, true, m_bytesWritten, m_bytesToWri
te)); | 308 dispatchEvent(ProgressEvent::create(type, true, m_bytesWritten, m_bytesToWri
te)); |
| 311 --m_recursionDepth; | 309 --m_recursionDepth; |
| 312 ASSERT(m_recursionDepth >= 0); | 310 ASSERT(m_recursionDepth >= 0); |
| 313 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | |
| 314 } | 311 } |
| 315 | 312 |
| 316 void FileWriter::setError(FileError::ErrorCode errorCode, ExceptionState& except
ionState) | 313 void FileWriter::setError(FileError::ErrorCode errorCode, ExceptionState& except
ionState) |
| 317 { | 314 { |
| 318 ASSERT(errorCode); | 315 ASSERT(errorCode); |
| 319 FileError::throwDOMException(exceptionState, errorCode); | 316 FileError::throwDOMException(exceptionState, errorCode); |
| 320 m_error = FileError::create(errorCode); | 317 m_error = FileError::create(errorCode); |
| 321 } | 318 } |
| 322 | 319 |
| 323 DEFINE_TRACE(FileWriter) | 320 DEFINE_TRACE(FileWriter) |
| 324 { | 321 { |
| 325 visitor->trace(m_error); | 322 visitor->trace(m_error); |
| 326 visitor->trace(m_blobBeingWritten); | 323 visitor->trace(m_blobBeingWritten); |
| 327 EventTargetWithInlineData::trace(visitor); | 324 EventTargetWithInlineData::trace(visitor); |
| 328 FileWriterBase::trace(visitor); | 325 FileWriterBase::trace(visitor); |
| 329 ActiveDOMObject::trace(visitor); | 326 ActiveDOMObject::trace(visitor); |
| 330 } | 327 } |
| 331 | 328 |
| 332 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |