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

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

Issue 2796163002: Migrate WTF::HashCountedSet::add() to ::insert() (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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
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.add(client); 373 m_finishedClients.insert(client);
374 m_clients.remove(client); 374 m_clients.remove(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;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 builder.append(' '); 652 builder.append(' ');
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.add(c); 662 m_finishedClients.insert(c);
663 m_clients.remove(c); 663 m_clients.remove(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.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 } 706 }
707 707
708 void Resource::addClient(ResourceClient* client, 708 void Resource::addClient(ResourceClient* client,
709 PreloadReferencePolicy policy) { 709 PreloadReferencePolicy policy) {
710 CHECK(!m_isAddRemoveClientProhibited); 710 CHECK(!m_isAddRemoveClientProhibited);
711 711
712 willAddClientOrObserver(policy); 712 willAddClientOrObserver(policy);
713 713
714 if (m_isRevalidating) { 714 if (m_isRevalidating) {
715 m_clients.add(client); 715 m_clients.insert(client);
716 return; 716 return;
717 } 717 }
718 718
719 // If an error has occurred or we have existing data to send to the new client 719 // If an error has occurred or we have existing data to send to the new client
720 // and the resource type supprts it, send it asynchronously. 720 // and the resource type supprts it, send it asynchronously.
721 if ((errorOccurred() || !response().isNull()) && 721 if ((errorOccurred() || !response().isNull()) &&
722 !typeNeedsSynchronousCacheHit(getType()) && !m_needsSynchronousCacheHit) { 722 !typeNeedsSynchronousCacheHit(getType()) && !m_needsSynchronousCacheHit) {
723 m_clientsAwaitingCallback.add(client); 723 m_clientsAwaitingCallback.insert(client);
724 ResourceCallback::callbackHandler().schedule(this); 724 ResourceCallback::callbackHandler().schedule(this);
725 return; 725 return;
726 } 726 }
727 727
728 m_clients.add(client); 728 m_clients.insert(client);
729 didAddClient(client); 729 didAddClient(client);
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
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.remove(client))
816 continue; 816 continue;
817 m_clients.add(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
826 // It is still possible for the above loop to finish a new client 826 // It is still possible for the above loop to finish a new client
827 // synchronously. If there's no client waiting we should deschedule. 827 // synchronously. If there's no client waiting we should deschedule.
(...skipping 290 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