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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/Resource.cpp

Issue 2799573003: Migrate WTF::HashCountedSet::remove() to ::erase() (Closed)
Patch Set: 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
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 ResourceClientWalker<ResourceClient> w(m_clients); 364 ResourceClientWalker<ResourceClient> w(m_clients);
365 while (ResourceClient* c = w.next()) { 365 while (ResourceClient* c = w.next()) {
366 markClientFinished(c); 366 markClientFinished(c);
367 c->notifyFinished(this); 367 c->notifyFinished(this);
368 } 368 }
369 } 369 }
370 370
371 void Resource::markClientFinished(ResourceClient* client) { 371 void Resource::markClientFinished(ResourceClient* client) {
372 if (m_clients.contains(client)) { 372 if (m_clients.contains(client)) {
373 m_finishedClients.insert(client); 373 m_finishedClients.insert(client);
374 m_clients.remove(client); 374 m_clients.erase(client);
375 } 375 }
376 } 376 }
377 377
378 void Resource::appendData(const char* data, size_t length) { 378 void Resource::appendData(const char* data, size_t length) {
379 TRACE_EVENT0("blink", "Resource::appendData"); 379 TRACE_EVENT0("blink", "Resource::appendData");
380 DCHECK(!m_isRevalidating); 380 DCHECK(!m_isRevalidating);
381 DCHECK(!errorOccurred()); 381 DCHECK(!errorOccurred());
382 if (m_options.dataBufferingPolicy == DoNotBufferData) 382 if (m_options.dataBufferingPolicy == DoNotBufferData)
383 return; 383 return;
384 if (m_data) 384 if (m_data)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 builder.append("in_memory_cache"); 653 builder.append("in_memory_cache");
654 } 654 }
655 return builder.toString(); 655 return builder.toString();
656 } 656 }
657 657
658 void Resource::didAddClient(ResourceClient* c) { 658 void Resource::didAddClient(ResourceClient* c) {
659 if (isLoaded()) { 659 if (isLoaded()) {
660 c->notifyFinished(this); 660 c->notifyFinished(this);
661 if (m_clients.contains(c)) { 661 if (m_clients.contains(c)) {
662 m_finishedClients.insert(c); 662 m_finishedClients.insert(c);
663 m_clients.remove(c); 663 m_clients.erase(c);
664 } 664 }
665 } 665 }
666 } 666 }
667 667
668 static bool typeNeedsSynchronousCacheHit(Resource::Type type) { 668 static bool typeNeedsSynchronousCacheHit(Resource::Type type) {
669 // Some resources types default to return data synchronously. For most of 669 // Some resources types default to return data synchronously. For most of
670 // these, it's because there are layout tests that expect data to return 670 // these, it's because there are layout tests that expect data to return
671 // synchronously in case of cache hit. In the case of fonts, there was a 671 // synchronously in case of cache hit. In the case of fonts, there was a
672 // performance regression. 672 // performance regression.
673 // FIXME: Get to the point where we don't need to special-case sync/async 673 // FIXME: Get to the point where we don't need to special-case sync/async
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 return; 730 return;
731 } 731 }
732 732
733 void Resource::removeClient(ResourceClient* client) { 733 void Resource::removeClient(ResourceClient* client) {
734 CHECK(!m_isAddRemoveClientProhibited); 734 CHECK(!m_isAddRemoveClientProhibited);
735 735
736 // This code may be called in a pre-finalizer, where weak members in the 736 // This code may be called in a pre-finalizer, where weak members in the
737 // HashCountedSet are already swept out. 737 // HashCountedSet are already swept out.
738 738
739 if (m_finishedClients.contains(client)) 739 if (m_finishedClients.contains(client))
740 m_finishedClients.remove(client); 740 m_finishedClients.erase(client);
741 else if (m_clientsAwaitingCallback.contains(client)) 741 else if (m_clientsAwaitingCallback.contains(client))
742 m_clientsAwaitingCallback.remove(client); 742 m_clientsAwaitingCallback.erase(client);
743 else 743 else
744 m_clients.remove(client); 744 m_clients.erase(client);
745 745
746 if (m_clientsAwaitingCallback.isEmpty()) 746 if (m_clientsAwaitingCallback.isEmpty())
747 ResourceCallback::callbackHandler().cancel(this); 747 ResourceCallback::callbackHandler().cancel(this);
748 748
749 didRemoveClientOrObserver(); 749 didRemoveClientOrObserver();
750 } 750 }
751 751
752 void Resource::didRemoveClientOrObserver() { 752 void Resource::didRemoveClientOrObserver() {
753 if (!hasClientsOrObservers() && m_isAlive) { 753 if (!hasClientsOrObservers() && m_isAlive) {
754 m_isAlive = false; 754 m_isAlive = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // available to be removed. Also don't call removed clients or add them 805 // available to be removed. Also don't call removed clients or add them
806 // back. 806 // back.
807 // 807 //
808 // Handle case (1) by saving a list of clients to notify. A separate list also 808 // Handle case (1) by saving a list of clients to notify. A separate list also
809 // ensure a client is either in m_clients or m_clientsAwaitingCallback. 809 // ensure a client is either in m_clients or m_clientsAwaitingCallback.
810 HeapVector<Member<ResourceClient>> clientsToNotify; 810 HeapVector<Member<ResourceClient>> clientsToNotify;
811 copyToVector(m_clientsAwaitingCallback, clientsToNotify); 811 copyToVector(m_clientsAwaitingCallback, clientsToNotify);
812 812
813 for (const auto& client : clientsToNotify) { 813 for (const auto& client : clientsToNotify) {
814 // Handle case (2) to skip removed clients. 814 // Handle case (2) to skip removed clients.
815 if (!m_clientsAwaitingCallback.remove(client)) 815 if (!m_clientsAwaitingCallback.erase(client))
816 continue; 816 continue;
817 m_clients.insert(client); 817 m_clients.insert(client);
818 818
819 // When revalidation starts after waiting clients are scheduled and 819 // When revalidation starts after waiting clients are scheduled and
820 // before they are added here. In such cases, we just add the clients 820 // before they are added here. In such cases, we just add the clients
821 // to |m_clients| without didAddClient(), as in Resource::addClient(). 821 // to |m_clients| without didAddClient(), as in Resource::addClient().
822 if (!m_isRevalidating) 822 if (!m_isRevalidating)
823 didAddClient(client); 823 didAddClient(client);
824 } 824 }
825 825
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 case Resource::Media: 1118 case Resource::Media:
1119 case Resource::Manifest: 1119 case Resource::Manifest:
1120 case Resource::Mock: 1120 case Resource::Mock:
1121 return false; 1121 return false;
1122 } 1122 }
1123 NOTREACHED(); 1123 NOTREACHED();
1124 return false; 1124 return false;
1125 } 1125 }
1126 1126
1127 } // namespace blink 1127 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/platform/wtf/HashCountedSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698