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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/FileReader.cpp

Issue 2645303002: Use a new Supplement constructor for supplements in core/ (Closed)
Patch Set: temp Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLDocumentParserTest.cpp » ('j') | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController); 74 USING_GARBAGE_COLLECTED_MIXIN(FileReader::ThrottlingController);
75 75
76 public: 76 public:
77 static ThrottlingController* from(ExecutionContext* context) { 77 static ThrottlingController* from(ExecutionContext* context) {
78 if (!context) 78 if (!context)
79 return 0; 79 return 0;
80 80
81 ThrottlingController* controller = static_cast<ThrottlingController*>( 81 ThrottlingController* controller = static_cast<ThrottlingController*>(
82 Supplement<ExecutionContext>::from(*context, supplementName())); 82 Supplement<ExecutionContext>::from(*context, supplementName()));
83 if (!controller) { 83 if (!controller) {
84 controller = new ThrottlingController; 84 controller = new ThrottlingController(*context);
85 provideTo(*context, supplementName(), controller); 85 provideTo(*context, supplementName(), controller);
86 } 86 }
87 return controller; 87 return controller;
88 } 88 }
89 89
90 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders }; 90 enum FinishReaderType { DoNotRunPendingReaders, RunPendingReaders };
91 91
92 static void pushReader(ExecutionContext* context, FileReader* reader) { 92 static void pushReader(ExecutionContext* context, FileReader* reader) {
93 ThrottlingController* controller = from(context); 93 ThrottlingController* controller = from(context);
94 if (!controller) 94 if (!controller)
(...skipping 24 matching lines...) Expand all
119 InspectorInstrumentation::asyncTaskCanceled(context, reader); 119 InspectorInstrumentation::asyncTaskCanceled(context, reader);
120 } 120 }
121 121
122 DEFINE_INLINE_TRACE() { 122 DEFINE_INLINE_TRACE() {
123 visitor->trace(m_pendingReaders); 123 visitor->trace(m_pendingReaders);
124 visitor->trace(m_runningReaders); 124 visitor->trace(m_runningReaders);
125 Supplement<ExecutionContext>::trace(visitor); 125 Supplement<ExecutionContext>::trace(visitor);
126 } 126 }
127 127
128 private: 128 private:
129 ThrottlingController() 129 explicit ThrottlingController(ExecutionContext& context)
130 : m_maxRunningReaders(kMaxOutstandingRequestsPerThread) {} 130 : Supplement<ExecutionContext>(context),
131 m_maxRunningReaders(kMaxOutstandingRequestsPerThread) {}
131 132
132 void pushReader(FileReader* reader) { 133 void pushReader(FileReader* reader) {
133 if (m_pendingReaders.isEmpty() && 134 if (m_pendingReaders.isEmpty() &&
134 m_runningReaders.size() < m_maxRunningReaders) { 135 m_runningReaders.size() < m_maxRunningReaders) {
135 reader->executePendingRead(); 136 reader->executePendingRead();
136 ASSERT(!m_runningReaders.contains(reader)); 137 ASSERT(!m_runningReaders.contains(reader));
137 m_runningReaders.add(reader); 138 m_runningReaders.add(reader);
138 return; 139 return;
139 } 140 }
140 m_pendingReaders.append(reader); 141 m_pendingReaders.append(reader);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0)); 469 ProgressEvent::create(type, false, m_loader->bytesLoaded(), 0));
469 } 470 }
470 471
471 DEFINE_TRACE(FileReader) { 472 DEFINE_TRACE(FileReader) {
472 visitor->trace(m_error); 473 visitor->trace(m_error);
473 EventTargetWithInlineData::trace(visitor); 474 EventTargetWithInlineData::trace(visitor);
474 ContextLifecycleObserver::trace(visitor); 475 ContextLifecycleObserver::trace(visitor);
475 } 476 }
476 477
477 } // namespace blink 478 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLDocumentParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698