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

Side by Side Diff: Source/modules/filesystem/FileWriter.cpp

Issue 383993008: Revert of FileWriter should not use deprecated {,un}setPendingActivity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/filesystem/FileWriter.h ('k') | no next file » | 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 void FileWriter::stop() 81 void FileWriter::stop()
82 { 82 {
83 // Make sure we've actually got something to stop, and haven't already calle d abort(). 83 // Make sure we've actually got something to stop, and haven't already calle d abort().
84 if (!writer() || m_readyState != WRITING) 84 if (!writer() || m_readyState != WRITING)
85 return; 85 return;
86 doOperation(OperationAbort); 86 doOperation(OperationAbort);
87 m_readyState = DONE; 87 m_readyState = DONE;
88 } 88 }
89 89
90 bool FileWriter::hasPendingActivity() const
91 {
92 return m_operationInProgress != OperationNone || m_queuedOperation != Operat ionNone || m_readyState != WRITING;
93 }
94
95 void FileWriter::write(Blob* data, ExceptionState& exceptionState) 90 void FileWriter::write(Blob* data, ExceptionState& exceptionState)
96 { 91 {
97 ASSERT(writer()); 92 ASSERT(writer());
98 ASSERT(data); 93 ASSERT(data);
99 ASSERT(m_truncateLength == -1); 94 ASSERT(m_truncateLength == -1);
100 if (m_readyState == WRITING) { 95 if (m_readyState == WRITING) {
101 setError(FileError::INVALID_STATE_ERR, exceptionState); 96 setError(FileError::INVALID_STATE_ERR, exceptionState);
102 return; 97 return;
103 } 98 }
104 if (!data) { 99 if (!data) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // already handled the cleanup and signalCompletion call. 197 // already handled the cleanup and signalCompletion call.
203 double now = currentTimeMS(); 198 double now = currentTimeMS();
204 if (complete || !m_lastProgressNotificationTimeMS || (now - m_lastProgressNo tificationTimeMS > progressNotificationIntervalMS)) { 199 if (complete || !m_lastProgressNotificationTimeMS || (now - m_lastProgressNo tificationTimeMS > progressNotificationIntervalMS)) {
205 m_lastProgressNotificationTimeMS = now; 200 m_lastProgressNotificationTimeMS = now;
206 fireEvent(EventTypeNames::progress); 201 fireEvent(EventTypeNames::progress);
207 } 202 }
208 203
209 if (complete) { 204 if (complete) {
210 if (numAborts == m_numAborts) 205 if (numAborts == m_numAborts)
211 signalCompletion(FileError::OK); 206 signalCompletion(FileError::OK);
207 unsetPendingActivity(this);
212 } 208 }
213 } 209 }
214 210
215 void FileWriter::didTruncate() 211 void FileWriter::didTruncate()
216 { 212 {
217 if (m_operationInProgress == OperationAbort) { 213 if (m_operationInProgress == OperationAbort) {
218 completeAbort(); 214 completeAbort();
219 return; 215 return;
220 } 216 }
221 ASSERT(m_operationInProgress == OperationTruncate); 217 ASSERT(m_operationInProgress == OperationTruncate);
222 ASSERT(m_truncateLength >= 0); 218 ASSERT(m_truncateLength >= 0);
223 setLength(m_truncateLength); 219 setLength(m_truncateLength);
224 if (position() > length()) 220 if (position() > length())
225 setPosition(length()); 221 setPosition(length());
226 m_operationInProgress = OperationNone; 222 m_operationInProgress = OperationNone;
227 signalCompletion(FileError::OK); 223 signalCompletion(FileError::OK);
224 unsetPendingActivity(this);
228 } 225 }
229 226
230 void FileWriter::didFail(blink::WebFileError code) 227 void FileWriter::didFail(blink::WebFileError code)
231 { 228 {
232 ASSERT(m_operationInProgress != OperationNone); 229 ASSERT(m_operationInProgress != OperationNone);
233 ASSERT(static_cast<FileError::ErrorCode>(code) != FileError::OK); 230 ASSERT(static_cast<FileError::ErrorCode>(code) != FileError::OK);
234 if (m_operationInProgress == OperationAbort) { 231 if (m_operationInProgress == OperationAbort) {
235 completeAbort(); 232 completeAbort();
236 return; 233 return;
237 } 234 }
238 ASSERT(m_queuedOperation == OperationNone); 235 ASSERT(m_queuedOperation == OperationNone);
239 ASSERT(m_readyState == WRITING); 236 ASSERT(m_readyState == WRITING);
240 m_blobBeingWritten.clear(); 237 m_blobBeingWritten.clear();
241 m_operationInProgress = OperationNone; 238 m_operationInProgress = OperationNone;
242 signalCompletion(static_cast<FileError::ErrorCode>(code)); 239 signalCompletion(static_cast<FileError::ErrorCode>(code));
240 unsetPendingActivity(this);
243 } 241 }
244 242
245 void FileWriter::completeAbort() 243 void FileWriter::completeAbort()
246 { 244 {
247 ASSERT(m_operationInProgress == OperationAbort); 245 ASSERT(m_operationInProgress == OperationAbort);
248 m_operationInProgress = OperationNone; 246 m_operationInProgress = OperationNone;
249 Operation operation = m_queuedOperation; 247 Operation operation = m_queuedOperation;
250 m_queuedOperation = OperationNone; 248 m_queuedOperation = OperationNone;
251 doOperation(operation); 249 doOperation(operation);
250 unsetPendingActivity(this);
252 } 251 }
253 252
254 void FileWriter::doOperation(Operation operation) 253 void FileWriter::doOperation(Operation operation)
255 { 254 {
256 switch (operation) { 255 switch (operation) {
257 case OperationWrite: 256 case OperationWrite:
258 ASSERT(m_operationInProgress == OperationNone); 257 ASSERT(m_operationInProgress == OperationNone);
259 ASSERT(m_truncateLength == -1); 258 ASSERT(m_truncateLength == -1);
260 ASSERT(m_blobBeingWritten.get()); 259 ASSERT(m_blobBeingWritten.get());
261 ASSERT(m_readyState == WRITING); 260 ASSERT(m_readyState == WRITING);
261 setPendingActivity(this);
262 writer()->write(position(), m_blobBeingWritten->uuid()); 262 writer()->write(position(), m_blobBeingWritten->uuid());
263 break; 263 break;
264 case OperationTruncate: 264 case OperationTruncate:
265 ASSERT(m_operationInProgress == OperationNone); 265 ASSERT(m_operationInProgress == OperationNone);
266 ASSERT(m_truncateLength >= 0); 266 ASSERT(m_truncateLength >= 0);
267 ASSERT(m_readyState == WRITING); 267 ASSERT(m_readyState == WRITING);
268 setPendingActivity(this);
268 writer()->truncate(m_truncateLength); 269 writer()->truncate(m_truncateLength);
269 break; 270 break;
270 case OperationNone: 271 case OperationNone:
271 ASSERT(m_operationInProgress == OperationNone); 272 ASSERT(m_operationInProgress == OperationNone);
272 ASSERT(m_truncateLength == -1); 273 ASSERT(m_truncateLength == -1);
273 ASSERT(!m_blobBeingWritten.get()); 274 ASSERT(!m_blobBeingWritten.get());
274 ASSERT(m_readyState == DONE); 275 ASSERT(m_readyState == DONE);
275 break; 276 break;
276 case OperationAbort: 277 case OperationAbort:
277 if (m_operationInProgress == OperationWrite || m_operationInProgress == OperationTruncate) 278 if (m_operationInProgress == OperationWrite || m_operationInProgress == OperationTruncate)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 320
320 void FileWriter::trace(Visitor* visitor) 321 void FileWriter::trace(Visitor* visitor)
321 { 322 {
322 visitor->trace(m_error); 323 visitor->trace(m_error);
323 visitor->trace(m_blobBeingWritten); 324 visitor->trace(m_blobBeingWritten);
324 FileWriterBase::trace(visitor); 325 FileWriterBase::trace(visitor);
325 EventTargetWithInlineData::trace(visitor); 326 EventTargetWithInlineData::trace(visitor);
326 } 327 }
327 328
328 } // namespace WebCore 329 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/filesystem/FileWriter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698