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

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

Issue 2191633003: Move ResourceClient to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-raw-resource-client
Patch Set: rebase Created 4 years, 4 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 rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 Boston, MA 02110-1301, USA. 21 Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/fetch/Resource.h" 24 #include "core/fetch/Resource.h"
25 25
26 #include "core/fetch/CachedMetadata.h" 26 #include "core/fetch/CachedMetadata.h"
27 #include "core/fetch/CrossOriginAccessControl.h" 27 #include "core/fetch/CrossOriginAccessControl.h"
28 #include "core/fetch/FetchInitiatorTypeNames.h" 28 #include "core/fetch/FetchInitiatorTypeNames.h"
29 #include "core/fetch/MemoryCache.h" 29 #include "core/fetch/MemoryCache.h"
30 #include "core/fetch/ResourceClient.h" 30 #include "core/fetch/ResourceClient.h"
31 #include "core/fetch/ResourceClientOrObserverWalker.h" 31 #include "core/fetch/ResourceClientWalker.h"
32 #include "core/fetch/ResourceLoader.h" 32 #include "core/fetch/ResourceLoader.h"
33 #include "core/inspector/InstanceCounters.h" 33 #include "core/inspector/InstanceCounters.h"
34 #include "platform/Histogram.h" 34 #include "platform/Histogram.h"
35 #include "platform/Logging.h" 35 #include "platform/Logging.h"
36 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
37 #include "platform/SharedBuffer.h" 37 #include "platform/SharedBuffer.h"
38 #include "platform/TraceEvent.h" 38 #include "platform/TraceEvent.h"
39 #include "platform/network/HTTPParsers.h" 39 #include "platform/network/HTTPParsers.h"
40 #include "platform/weborigin/KURL.h" 40 #include "platform/weborigin/KURL.h"
41 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 Resource::~Resource() 325 Resource::~Resource()
326 { 326 {
327 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); 327 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter);
328 } 328 }
329 329
330 DEFINE_TRACE(Resource) 330 DEFINE_TRACE(Resource)
331 { 331 {
332 visitor->trace(m_loader); 332 visitor->trace(m_loader);
333 visitor->trace(m_cacheHandler); 333 visitor->trace(m_cacheHandler);
334 visitor->trace(m_clients);
335 visitor->trace(m_clientsAwaitingCallback);
336 visitor->trace(m_finishedClients);
334 } 337 }
335 338
336 void Resource::setLoader(ResourceLoader* loader) 339 void Resource::setLoader(ResourceLoader* loader)
337 { 340 {
338 RELEASE_ASSERT(!m_loader); 341 RELEASE_ASSERT(!m_loader);
339 ASSERT(stillNeedsLoad()); 342 ASSERT(stillNeedsLoad());
340 m_loader = loader; 343 m_loader = loader;
341 m_status = Pending; 344 m_status = Pending;
342 } 345 }
343 346
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 379
377 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) 380 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
378 { 381 {
379 m_options.dataBufferingPolicy = dataBufferingPolicy; 382 m_options.dataBufferingPolicy = dataBufferingPolicy;
380 m_data.clear(); 383 m_data.clear();
381 setEncodedSize(0); 384 setEncodedSize(0);
382 } 385 }
383 386
384 void Resource::markClientsAndObserversFinished() 387 void Resource::markClientsAndObserversFinished()
385 { 388 {
386 HashCountedSet<ResourceClient*> clients; 389 HeapHashCountedSet<WeakMember<ResourceClient>> clients;
387 m_clients.swap(clients); 390 m_clients.swap(clients);
388 for (const auto& it : clients) 391 for (const auto& it : clients)
389 m_finishedClients.add(it.key, it.value); 392 m_finishedClients.add(it.key, it.value);
390 } 393 }
391 394
392 void Resource::error(const ResourceError& error) 395 void Resource::error(const ResourceError& error)
393 { 396 {
394 ASSERT(!error.isNull()); 397 ASSERT(!error.isNull());
395 m_error = error; 398 m_error = error;
396 m_isRevalidating = false; 399 m_isRevalidating = false;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return; 715 return;
713 } 716 }
714 717
715 m_clients.add(client); 718 m_clients.add(client);
716 didAddClient(client); 719 didAddClient(client);
717 return; 720 return;
718 } 721 }
719 722
720 void Resource::removeClient(ResourceClient* client) 723 void Resource::removeClient(ResourceClient* client)
721 { 724 {
722 ASSERT(hasClient(client)); 725 if (!hasClient(client)) {
726 // In this case, the client is swept from client lists because they
727 // hold clients as weak member.
haraken 2016/08/12 10:45:20 // This code may be called in a pre-finalizer, whe
yhirano 2016/08/16 08:57:24 Done.
728 didRemoveClientOrObserver();
729 return;
730 }
723 if (m_finishedClients.contains(client)) 731 if (m_finishedClients.contains(client))
724 m_finishedClients.remove(client); 732 m_finishedClients.remove(client);
725 else if (m_clientsAwaitingCallback.contains(client)) 733 else if (m_clientsAwaitingCallback.contains(client))
726 m_clientsAwaitingCallback.remove(client); 734 m_clientsAwaitingCallback.remove(client);
727 else 735 else
728 m_clients.remove(client); 736 m_clients.remove(client);
729 737
730 if (m_clientsAwaitingCallback.isEmpty()) 738 if (m_clientsAwaitingCallback.isEmpty())
731 ResourceCallback::callbackHandler().cancel(this); 739 ResourceCallback::callbackHandler().cancel(this);
732 740
733 didRemoveClientOrObserver(); 741 didRemoveClientOrObserver();
734 // This object may be dead here.
735 } 742 }
736 743
737 void Resource::didRemoveClientOrObserver() 744 void Resource::didRemoveClientOrObserver()
738 { 745 {
739 if (!hasClientsOrObservers()) { 746 if (!hasClientsOrObservers()) {
740 memoryCache()->makeDead(this); 747 memoryCache()->makeDead(this);
741 allClientsAndObserversRemoved(); 748 allClientsAndObserversRemoved();
742 749
743 // RFC2616 14.9.2: 750 // RFC2616 14.9.2:
744 // "no-store: ... MUST make a best-effort attempt to remove the informat ion from volatile storage as promptly as possible" 751 // "no-store: ... MUST make a best-effort attempt to remove the informat ion from volatile storage as promptly as possible"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 { 809 {
803 // We're going to notify clients one by one. It is simple if the client does nothing. 810 // We're going to notify clients one by one. It is simple if the client does nothing.
804 // However there are a couple other things that can happen. 811 // However there are a couple other things that can happen.
805 // 812 //
806 // 1. Clients can be added during the loop. Make sure they are not processed . 813 // 1. Clients can be added during the loop. Make sure they are not processed .
807 // 2. Clients can be removed during the loop. Make sure they are always avai lable to be 814 // 2. Clients can be removed during the loop. Make sure they are always avai lable to be
808 // removed. Also don't call removed clients or add them back. 815 // removed. Also don't call removed clients or add them back.
809 816
810 // Handle case (1) by saving a list of clients to notify. A separate list al so ensure 817 // Handle case (1) by saving a list of clients to notify. A separate list al so ensure
811 // a client is either in m_clients or m_clientsAwaitingCallback. 818 // a client is either in m_clients or m_clientsAwaitingCallback.
812 Vector<ResourceClient*> clientsToNotify; 819 HeapVector<Member<ResourceClient>> clientsToNotify;
haraken 2016/08/12 10:45:20 Can we use the asVector?
yhirano 2016/08/16 08:57:24 Using asVector means making clientsToNotify a Heap
haraken 2016/08/16 11:55:44 asVector should convert HeapHashCountedSet<WeakMem
yhirano 2016/08/17 08:36:09 I think HashCountedSet<T, ...>.asVector() should r
813 copyToVector(m_clientsAwaitingCallback, clientsToNotify); 820 clientsToNotify.reserveCapacity(m_clientsAwaitingCallback.size());
821 for (const auto& keyvalue : m_clientsAwaitingCallback)
822 clientsToNotify.append(keyvalue.key);
814 823
815 for (const auto& client : clientsToNotify) { 824 for (const auto& client : clientsToNotify) {
816 // Handle case (2) to skip removed clients. 825 // Handle case (2) to skip removed clients.
817 if (!m_clientsAwaitingCallback.remove(client)) 826 if (!m_clientsAwaitingCallback.remove(client))
818 continue; 827 continue;
819 m_clients.add(client); 828 m_clients.add(client);
820 didAddClient(client); 829 didAddClient(client);
821 } 830 }
822 831
823 // It is still possible for the above loop to finish a new client synchronou sly. 832 // It is still possible for the above loop to finish a new client synchronou sly.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 case Resource::TextTrack: 1121 case Resource::TextTrack:
1113 case Resource::Media: 1122 case Resource::Media:
1114 case Resource::Manifest: 1123 case Resource::Manifest:
1115 return false; 1124 return false;
1116 } 1125 }
1117 ASSERT_NOT_REACHED(); 1126 ASSERT_NOT_REACHED();
1118 return false; 1127 return false;
1119 } 1128 }
1120 1129
1121 } // namespace blink 1130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698