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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 // excessive IPC congestion. We limit this to 100 per thread to throttle the | 73 // excessive IPC congestion. We limit this to 100 per thread to throttle the |
74 // requests (the value is arbitrarily chosen). | 74 // requests (the value is arbitrarily chosen). |
75 static const size_t kMaxOutstandingRequestsPerThread = 100; | 75 static const size_t kMaxOutstandingRequestsPerThread = 100; |
76 static const double progressNotificationIntervalMS = 50; | 76 static const double progressNotificationIntervalMS = 50; |
77 | 77 |
78 class FileReader::ThrottlingController FINAL : public NoBaseWillBeGarbageCollect edFinalized<FileReader::ThrottlingController>, public WillBeHeapSupplement<Local Frame>, public WillBeHeapSupplement<WorkerClients> { | 78 class FileReader::ThrottlingController FINAL : public NoBaseWillBeGarbageCollect edFinalized<FileReader::ThrottlingController>, public WillBeHeapSupplement<Local Frame>, public WillBeHeapSupplement<WorkerClients> { |
79 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); | 79 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); |
80 public: | 80 public: |
81 static ThrottlingController* from(ExecutionContext* context) | 81 static ThrottlingController* from(ExecutionContext* context) |
82 { | 82 { |
83 if (!context) | |
84 return 0; | |
85 | |
83 if (context->isDocument()) { | 86 if (context->isDocument()) { |
84 Document* document = toDocument(context); | 87 Document* document = toDocument(context); |
85 if (!document->frame()) | 88 if (!document->frame()) |
86 return 0; | 89 return 0; |
87 | 90 |
88 ThrottlingController* controller = static_cast<ThrottlingController* >(WillBeHeapSupplement<LocalFrame>::from(document->frame(), supplementName())); | 91 ThrottlingController* controller = static_cast<ThrottlingController* >(WillBeHeapSupplement<LocalFrame>::from(document->frame(), supplementName())); |
89 if (controller) | 92 if (controller) |
90 return controller; | 93 return controller; |
91 | 94 |
92 controller = new ThrottlingController(); | 95 controller = new ThrottlingController(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 if (m_state == LOADING) { | 281 if (m_state == LOADING) { |
279 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs."); | 282 exceptionState.throwDOMException(InvalidStateError, "The object is alrea dy busy reading Blobs."); |
280 return; | 283 return; |
281 } | 284 } |
282 | 285 |
283 if (blob->hasBeenClosed()) { | 286 if (blob->hasBeenClosed()) { |
284 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile( ) ? "File" : "Blob") + " has been closed."); | 287 exceptionState.throwDOMException(InvalidStateError, String(blob->isFile( ) ? "File" : "Blob") + " has been closed."); |
285 return; | 288 return; |
286 } | 289 } |
287 | 290 |
291 if (!throttlingController()) { | |
292 exceptionState.throwDOMException(NotSupportedError, "Reading from a Docu ment-detached FileReader is not supported."); | |
kinuko
2014/07/17 15:22:24
I don't have strong opinion, but AbortError might
| |
293 return; | |
294 } | |
295 | |
288 // "Snapshot" the Blob data rather than the Blob itself as ongoing | 296 // "Snapshot" the Blob data rather than the Blob itself as ongoing |
289 // read operations should not be affected if close() is called on | 297 // read operations should not be affected if close() is called on |
290 // the Blob being read. | 298 // the Blob being read. |
291 m_blobDataHandle = blob->blobDataHandle(); | 299 m_blobDataHandle = blob->blobDataHandle(); |
292 m_blobType = blob->type(); | 300 m_blobType = blob->type(); |
293 m_readType = type; | 301 m_readType = type; |
294 m_state = LOADING; | 302 m_state = LOADING; |
295 m_loadingState = LoadingStatePending; | 303 m_loadingState = LoadingStatePending; |
296 m_error = nullptr; | 304 m_error = nullptr; |
297 throttlingController()->pushReader(this); | 305 throttlingController()->pushReader(this); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 // since any of the events could call abort(), which internally checks | 393 // since any of the events could call abort(), which internally checks |
386 // if we're still loading (therefore we need abort process) or not. | 394 // if we're still loading (therefore we need abort process) or not. |
387 m_loadingState = LoadingStateNone; | 395 m_loadingState = LoadingStateNone; |
388 | 396 |
389 fireEvent(EventTypeNames::progress); | 397 fireEvent(EventTypeNames::progress); |
390 | 398 |
391 ASSERT(m_state != DONE); | 399 ASSERT(m_state != DONE); |
392 m_state = DONE; | 400 m_state = DONE; |
393 | 401 |
394 // Unregister the reader. | 402 // Unregister the reader. |
395 ThrottlingController::FinishReaderType finalStep = throttlingController()->r emoveReader(this); | 403 ThrottlingController::FinishReaderType finalStep = throttlingController()->r emoveReader(this); |
kinuko
2014/07/17 15:22:24
I assume these loader client methods are called wh
sof
2014/07/17 15:42:44
Good question; my assumption was that a valid Exec
sof
2014/07/17 22:12:01
kinuko-san, thanks for raising the lifetime questi
| |
396 | 404 |
397 fireEvent(EventTypeNames::load); | 405 fireEvent(EventTypeNames::load); |
398 fireEvent(EventTypeNames::loadend); | 406 fireEvent(EventTypeNames::loadend); |
399 | 407 |
400 // All possible events have fired and we're done, no more pending activity. | 408 // All possible events have fired and we're done, no more pending activity. |
401 throttlingController()->finishReader(this, finalStep); | 409 throttlingController()->finishReader(this, finalStep); |
402 } | 410 } |
403 | 411 |
404 void FileReader::didFail(FileError::ErrorCode errorCode) | 412 void FileReader::didFail(FileError::ErrorCode errorCode) |
405 { | 413 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 return m_loader->stringResult(); | 463 return m_loader->stringResult(); |
456 } | 464 } |
457 | 465 |
458 void FileReader::trace(Visitor* visitor) | 466 void FileReader::trace(Visitor* visitor) |
459 { | 467 { |
460 visitor->trace(m_error); | 468 visitor->trace(m_error); |
461 EventTargetWithInlineData::trace(visitor); | 469 EventTargetWithInlineData::trace(visitor); |
462 } | 470 } |
463 | 471 |
464 } // namespace WebCore | 472 } // namespace WebCore |
OLD | NEW |