| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 // Embedders like chromium limit the number of simultaneous requests to avoid | 68 // Embedders like chromium limit the number of simultaneous requests to avoid |
| 69 // excessive IPC congestion. We limit this to 100 per thread to throttle the | 69 // excessive IPC congestion. We limit this to 100 per thread to throttle the |
| 70 // requests (the value is arbitrarily chosen). | 70 // requests (the value is arbitrarily chosen). |
| 71 static const size_t kMaxOutstandingRequestsPerThread = 100; | 71 static const size_t kMaxOutstandingRequestsPerThread = 100; |
| 72 static const double progressNotificationIntervalMS = 50; | 72 static const double progressNotificationIntervalMS = 50; |
| 73 | 73 |
| 74 class FileReader::ThrottlingController final : public GarbageCollectedFinalized<
FileReader::ThrottlingController>, public HeapSupplement<ExecutionContext> { | 74 class FileReader::ThrottlingController final : public GarbageCollectedFinalized<
FileReader::ThrottlingController>, public Supplement<ExecutionContext> { |
| 75 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); | 75 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); |
| 76 public: | 76 public: |
| 77 static ThrottlingController* from(ExecutionContext* context) | 77 static ThrottlingController* from(ExecutionContext* context) |
| 78 { | 78 { |
| 79 if (!context) | 79 if (!context) |
| 80 return 0; | 80 return 0; |
| 81 | 81 |
| 82 ThrottlingController* controller = static_cast<ThrottlingController*>(He
apSupplement<ExecutionContext>::from(*context, supplementName())); | 82 ThrottlingController* controller = static_cast<ThrottlingController*>(Su
pplement<ExecutionContext>::from(*context, supplementName())); |
| 83 if (!controller) { | 83 if (!controller) { |
| 84 controller = new ThrottlingController(); | 84 controller = new ThrottlingController; |
| 85 HeapSupplement<ExecutionContext>::provideTo(*context, supplementName
(), controller); | 85 provideTo(*context, supplementName(), controller); |
| 86 } | 86 } |
| 87 return controller; | 87 return controller; |
| 88 } | 88 } |
| 89 | 89 |
| 90 ~ThrottlingController() { } | 90 ~ThrottlingController() { } |
| 91 | 91 |
| 92 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 92 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
| 93 | 93 |
| 94 static void pushReader(ExecutionContext* context, FileReader* reader) | 94 static void pushReader(ExecutionContext* context, FileReader* reader) |
| 95 { | 95 { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 | 120 |
| 121 controller->finishReader(reader, nextStep); | 121 controller->finishReader(reader, nextStep); |
| 122 } | 122 } |
| 123 | 123 |
| 124 DEFINE_INLINE_TRACE() | 124 DEFINE_INLINE_TRACE() |
| 125 { | 125 { |
| 126 #if ENABLE(OILPAN) | 126 #if ENABLE(OILPAN) |
| 127 visitor->trace(m_pendingReaders); | 127 visitor->trace(m_pendingReaders); |
| 128 visitor->trace(m_runningReaders); | 128 visitor->trace(m_runningReaders); |
| 129 #endif | 129 #endif |
| 130 HeapSupplement<ExecutionContext>::trace(visitor); | 130 Supplement<ExecutionContext>::trace(visitor); |
| 131 } | 131 } |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 ThrottlingController() | 134 ThrottlingController() |
| 135 : m_maxRunningReaders(kMaxOutstandingRequestsPerThread) | 135 : m_maxRunningReaders(kMaxOutstandingRequestsPerThread) |
| 136 { | 136 { |
| 137 } | 137 } |
| 138 | 138 |
| 139 void pushReader(FileReader* reader) | 139 void pushReader(FileReader* reader) |
| 140 { | 140 { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } | 469 } |
| 470 | 470 |
| 471 DEFINE_TRACE(FileReader) | 471 DEFINE_TRACE(FileReader) |
| 472 { | 472 { |
| 473 visitor->trace(m_error); | 473 visitor->trace(m_error); |
| 474 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); | 474 RefCountedGarbageCollectedEventTargetWithInlineData<FileReader>::trace(visit
or); |
| 475 ActiveDOMObject::trace(visitor); | 475 ActiveDOMObject::trace(visitor); |
| 476 } | 476 } |
| 477 | 477 |
| 478 } // namespace blink | 478 } // namespace blink |
| OLD | NEW |