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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/RejectedPromises.cpp

Issue 2776203002: Migrate WTF::Vector::remove() to ::erase() (Closed)
Patch Set: rebase, repatch VectorTest Created 3 years, 8 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/bindings/core/v8/ScriptPromisePropertyBase.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/RejectedPromises.h" 5 #include "bindings/core/v8/RejectedPromises.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (!message->isCollected() && message->hasPromise(data.GetPromise())) { 215 if (!message->isCollected() && message->hasPromise(data.GetPromise())) {
216 message->makePromiseStrong(); 216 message->makePromiseStrong();
217 Platform::current() 217 Platform::current()
218 ->currentThread() 218 ->currentThread()
219 ->scheduler() 219 ->scheduler()
220 ->timerTaskRunner() 220 ->timerTaskRunner()
221 ->postTask(BLINK_FROM_HERE, 221 ->postTask(BLINK_FROM_HERE,
222 WTF::bind(&RejectedPromises::revokeNow, 222 WTF::bind(&RejectedPromises::revokeNow,
223 RefPtr<RejectedPromises>(this), 223 RefPtr<RejectedPromises>(this),
224 WTF::passed(std::move(message)))); 224 WTF::passed(std::move(message))));
225 m_reportedAsErrors.remove(i); 225 m_reportedAsErrors.erase(i);
226 return; 226 return;
227 } 227 }
228 } 228 }
229 } 229 }
230 230
231 std::unique_ptr<RejectedPromises::MessageQueue> 231 std::unique_ptr<RejectedPromises::MessageQueue>
232 RejectedPromises::createMessageQueue() { 232 RejectedPromises::createMessageQueue() {
233 return WTF::makeUnique<MessageQueue>(); 233 return WTF::makeUnique<MessageQueue>();
234 } 234 }
235 235
(...skipping 18 matching lines...) Expand all
254 ->timerTaskRunner() 254 ->timerTaskRunner()
255 ->postTask(BLINK_FROM_HERE, WTF::bind(&RejectedPromises::processQueueNow, 255 ->postTask(BLINK_FROM_HERE, WTF::bind(&RejectedPromises::processQueueNow,
256 PassRefPtr<RejectedPromises>(this), 256 PassRefPtr<RejectedPromises>(this),
257 WTF::passed(std::move(queue)))); 257 WTF::passed(std::move(queue))));
258 } 258 }
259 259
260 void RejectedPromises::processQueueNow(std::unique_ptr<MessageQueue> queue) { 260 void RejectedPromises::processQueueNow(std::unique_ptr<MessageQueue> queue) {
261 // Remove collected handlers. 261 // Remove collected handlers.
262 for (size_t i = 0; i < m_reportedAsErrors.size();) { 262 for (size_t i = 0; i < m_reportedAsErrors.size();) {
263 if (m_reportedAsErrors.at(i)->isCollected()) 263 if (m_reportedAsErrors.at(i)->isCollected())
264 m_reportedAsErrors.remove(i); 264 m_reportedAsErrors.erase(i);
265 else 265 else
266 ++i; 266 ++i;
267 } 267 }
268 268
269 while (!queue->isEmpty()) { 269 while (!queue->isEmpty()) {
270 std::unique_ptr<Message> message = queue->takeFirst(); 270 std::unique_ptr<Message> message = queue->takeFirst();
271 if (message->isCollected()) 271 if (message->isCollected())
272 continue; 272 continue;
273 if (!message->hasHandler()) { 273 if (!message->hasHandler()) {
274 message->report(); 274 message->report();
275 message->makePromiseWeak(); 275 message->makePromiseWeak();
276 m_reportedAsErrors.push_back(std::move(message)); 276 m_reportedAsErrors.push_back(std::move(message));
277 if (m_reportedAsErrors.size() > maxReportedHandlersPendingResolution) 277 if (m_reportedAsErrors.size() > maxReportedHandlersPendingResolution)
278 m_reportedAsErrors.remove(0, maxReportedHandlersPendingResolution / 10); 278 m_reportedAsErrors.erase(0, maxReportedHandlersPendingResolution / 10);
279 } 279 }
280 } 280 }
281 } 281 }
282 282
283 void RejectedPromises::revokeNow(std::unique_ptr<Message> message) { 283 void RejectedPromises::revokeNow(std::unique_ptr<Message> message) {
284 message->revoke(); 284 message->revoke();
285 } 285 }
286 286
287 } // namespace blink 287 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698