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 51 matching lines...) Loading... |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 // Embedders like chromium limit the number of simultaneous requests to avoid | 66 // Embedders like chromium limit the number of simultaneous requests to avoid |
67 // excessive IPC congestion. We limit this to 100 per thread to throttle the | 67 // excessive IPC congestion. We limit this to 100 per thread to throttle the |
68 // requests (the value is arbitrarily chosen). | 68 // requests (the value is arbitrarily chosen). |
69 static const size_t kMaxOutstandingRequestsPerThread = 100; | 69 static const size_t kMaxOutstandingRequestsPerThread = 100; |
70 static const double progressNotificationIntervalMS = 50; | 70 static const double progressNotificationIntervalMS = 50; |
71 | 71 |
72 class FileReader::ThrottlingController final : public GarbageCollected<FileReade
r::ThrottlingController>, public Supplement<ExecutionContext> { | 72 class FileReader::ThrottlingController final : public GarbageCollectedFinalized<
FileReader::ThrottlingController>, public Supplement<ExecutionContext> { |
73 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); | 73 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); |
74 public: | 74 public: |
75 static ThrottlingController* from(ExecutionContext* context) | 75 static ThrottlingController* from(ExecutionContext* context) |
76 { | 76 { |
77 if (!context) | 77 if (!context) |
78 return 0; | 78 return 0; |
79 | 79 |
80 ThrottlingController* controller = static_cast<ThrottlingController*>(Su
pplement<ExecutionContext>::from(*context, supplementName())); | 80 ThrottlingController* controller = static_cast<ThrottlingController*>(Su
pplement<ExecutionContext>::from(*context, supplementName())); |
81 if (!controller) { | 81 if (!controller) { |
82 controller = new ThrottlingController; | 82 controller = new ThrottlingController; |
83 provideTo(*context, supplementName(), controller); | 83 provideTo(*context, supplementName(), controller); |
84 } | 84 } |
85 return controller; | 85 return controller; |
86 } | 86 } |
87 | 87 |
| 88 ~ThrottlingController() { } |
| 89 |
88 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; | 90 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; |
89 | 91 |
90 static void pushReader(ExecutionContext* context, FileReader* reader) | 92 static void pushReader(ExecutionContext* context, FileReader* reader) |
91 { | 93 { |
92 ThrottlingController* controller = from(context); | 94 ThrottlingController* controller = from(context); |
93 if (!controller) | 95 if (!controller) |
94 return; | 96 return; |
95 | 97 |
96 InspectorInstrumentation::asyncTaskScheduled(context, "FileReader", read
er, true); | 98 InspectorInstrumentation::asyncTaskScheduled(context, "FileReader", read
er, true); |
97 controller->pushReader(reader); | 99 controller->pushReader(reader); |
(...skipping 360 matching lines...) Loading... |
458 } | 460 } |
459 | 461 |
460 DEFINE_TRACE(FileReader) | 462 DEFINE_TRACE(FileReader) |
461 { | 463 { |
462 visitor->trace(m_error); | 464 visitor->trace(m_error); |
463 EventTargetWithInlineData::trace(visitor); | 465 EventTargetWithInlineData::trace(visitor); |
464 ActiveDOMObject::trace(visitor); | 466 ActiveDOMObject::trace(visitor); |
465 } | 467 } |
466 | 468 |
467 } // namespace blink | 469 } // namespace blink |
OLD | NEW |