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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT(!m_recursionDepth); | 66 ASSERT(!m_recursionDepth); |
67 if (m_readyState == kWriting) | 67 if (m_readyState == kWriting) |
68 contextDestroyed(); | 68 contextDestroyed(); |
69 } | 69 } |
70 | 70 |
71 const AtomicString& FileWriter::interfaceName() const { | 71 const AtomicString& FileWriter::interfaceName() const { |
72 return EventTargetNames::FileWriter; | 72 return EventTargetNames::FileWriter; |
73 } | 73 } |
74 | 74 |
75 void FileWriter::contextDestroyed() { | 75 void FileWriter::contextDestroyed() { |
76 // Make sure we've actually got something to stop, and haven't already called
abort(). | 76 // Make sure we've actually got something to stop, and haven't already called |
| 77 // abort(). |
77 if (!writer() || m_readyState != kWriting) | 78 if (!writer() || m_readyState != kWriting) |
78 return; | 79 return; |
79 doOperation(OperationAbort); | 80 doOperation(OperationAbort); |
80 m_readyState = kDone; | 81 m_readyState = kDone; |
81 } | 82 } |
82 | 83 |
83 bool FileWriter::hasPendingActivity() const { | 84 bool FileWriter::hasPendingActivity() const { |
84 return m_operationInProgress != OperationNone || | 85 return m_operationInProgress != OperationNone || |
85 m_queuedOperation != OperationNone || m_readyState == kWriting; | 86 m_queuedOperation != OperationNone || m_readyState == kWriting; |
86 } | 87 } |
(...skipping 10 matching lines...) Expand all Loading... |
97 setError(FileError::kSecurityErr, exceptionState); | 98 setError(FileError::kSecurityErr, exceptionState); |
98 return; | 99 return; |
99 } | 100 } |
100 | 101 |
101 m_blobBeingWritten = data; | 102 m_blobBeingWritten = data; |
102 m_readyState = kWriting; | 103 m_readyState = kWriting; |
103 m_bytesWritten = 0; | 104 m_bytesWritten = 0; |
104 m_bytesToWrite = data->size(); | 105 m_bytesToWrite = data->size(); |
105 ASSERT(m_queuedOperation == OperationNone); | 106 ASSERT(m_queuedOperation == OperationNone); |
106 if (m_operationInProgress != OperationNone) { | 107 if (m_operationInProgress != OperationNone) { |
107 // We must be waiting for an abort to complete, since m_readyState wasn't kW
riting. | 108 // We must be waiting for an abort to complete, since m_readyState wasn't |
| 109 // kWriting. |
108 ASSERT(m_operationInProgress == OperationAbort); | 110 ASSERT(m_operationInProgress == OperationAbort); |
109 m_queuedOperation = OperationWrite; | 111 m_queuedOperation = OperationWrite; |
110 } else | 112 } else |
111 doOperation(OperationWrite); | 113 doOperation(OperationWrite); |
112 | 114 |
113 fireEvent(EventTypeNames::writestart); | 115 fireEvent(EventTypeNames::writestart); |
114 } | 116 } |
115 | 117 |
116 void FileWriter::seek(long long position, ExceptionState& exceptionState) { | 118 void FileWriter::seek(long long position, ExceptionState& exceptionState) { |
117 ASSERT(writer()); | 119 ASSERT(writer()); |
(...skipping 18 matching lines...) Expand all Loading... |
136 setError(FileError::kSecurityErr, exceptionState); | 138 setError(FileError::kSecurityErr, exceptionState); |
137 return; | 139 return; |
138 } | 140 } |
139 | 141 |
140 m_readyState = kWriting; | 142 m_readyState = kWriting; |
141 m_bytesWritten = 0; | 143 m_bytesWritten = 0; |
142 m_bytesToWrite = 0; | 144 m_bytesToWrite = 0; |
143 m_truncateLength = position; | 145 m_truncateLength = position; |
144 ASSERT(m_queuedOperation == OperationNone); | 146 ASSERT(m_queuedOperation == OperationNone); |
145 if (m_operationInProgress != OperationNone) { | 147 if (m_operationInProgress != OperationNone) { |
146 // We must be waiting for an abort to complete, since m_readyState wasn't kW
riting. | 148 // We must be waiting for an abort to complete, since m_readyState wasn't |
| 149 // kWriting. |
147 ASSERT(m_operationInProgress == OperationAbort); | 150 ASSERT(m_operationInProgress == OperationAbort); |
148 m_queuedOperation = OperationTruncate; | 151 m_queuedOperation = OperationTruncate; |
149 } else | 152 } else |
150 doOperation(OperationTruncate); | 153 doOperation(OperationTruncate); |
151 fireEvent(EventTypeNames::writestart); | 154 fireEvent(EventTypeNames::writestart); |
152 } | 155 } |
153 | 156 |
154 void FileWriter::abort(ExceptionState& exceptionState) { | 157 void FileWriter::abort(ExceptionState& exceptionState) { |
155 ASSERT(writer()); | 158 ASSERT(writer()); |
156 if (m_readyState != kWriting) | 159 if (m_readyState != kWriting) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 309 |
307 DEFINE_TRACE(FileWriter) { | 310 DEFINE_TRACE(FileWriter) { |
308 visitor->trace(m_error); | 311 visitor->trace(m_error); |
309 visitor->trace(m_blobBeingWritten); | 312 visitor->trace(m_blobBeingWritten); |
310 EventTargetWithInlineData::trace(visitor); | 313 EventTargetWithInlineData::trace(visitor); |
311 FileWriterBase::trace(visitor); | 314 FileWriterBase::trace(visitor); |
312 ActiveDOMObject::trace(visitor); | 315 ActiveDOMObject::trace(visitor); |
313 } | 316 } |
314 | 317 |
315 } // namespace blink | 318 } // namespace blink |
OLD | NEW |