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

Side by Side Diff: Source/WebCore/loader/cache/CachedResource.cpp

Issue 9283038: Merge 105226 - Ensure we don't cancel revalidation of a CachedResource (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 11 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 , m_encodedSize(0) 132 , m_encodedSize(0)
133 , m_decodedSize(0) 133 , m_decodedSize(0)
134 , m_accessCount(0) 134 , m_accessCount(0)
135 , m_handleCount(0) 135 , m_handleCount(0)
136 , m_preloadCount(0) 136 , m_preloadCount(0)
137 , m_preloadResult(PreloadNotReferenced) 137 , m_preloadResult(PreloadNotReferenced)
138 , m_inLiveDecodedResourcesList(false) 138 , m_inLiveDecodedResourcesList(false)
139 , m_requestedFromNetworkingLayer(false) 139 , m_requestedFromNetworkingLayer(false)
140 , m_inCache(false) 140 , m_inCache(false)
141 , m_loading(false) 141 , m_loading(false)
142 , m_switchingClientsToRevalidatedResource(false)
142 , m_type(type) 143 , m_type(type)
143 , m_status(Pending) 144 , m_status(Pending)
144 #ifndef NDEBUG 145 #ifndef NDEBUG
145 , m_deleted(false) 146 , m_deleted(false)
146 , m_lruIndex(0) 147 , m_lruIndex(0)
147 #endif 148 #endif
148 , m_nextInAllResourcesList(0) 149 , m_nextInAllResourcesList(0)
149 , m_prevInAllResourcesList(0) 150 , m_prevInAllResourcesList(0)
150 , m_nextInLiveResourcesList(0) 151 , m_nextInLiveResourcesList(0)
151 , m_prevInLiveResourcesList(0) 152 , m_prevInLiveResourcesList(0)
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // So the code needs to be robust to this assert failing thus the "if (m_res ourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToR evalidate. 514 // So the code needs to be robust to this assert failing thus the "if (m_res ourceToRevalidate->m_proxyResource == this)" in CachedResource::clearResourceToR evalidate.
514 ASSERT(!resource->m_proxyResource); 515 ASSERT(!resource->m_proxyResource);
515 516
516 resource->m_proxyResource = this; 517 resource->m_proxyResource = this;
517 m_resourceToRevalidate = resource; 518 m_resourceToRevalidate = resource;
518 } 519 }
519 520
520 void CachedResource::clearResourceToRevalidate() 521 void CachedResource::clearResourceToRevalidate()
521 { 522 {
522 ASSERT(m_resourceToRevalidate); 523 ASSERT(m_resourceToRevalidate);
524 if (m_switchingClientsToRevalidatedResource)
525 return;
526
523 // A resource may start revalidation before this method has been called, so check that this resource is still the proxy resource before clearing it out. 527 // A resource may start revalidation before this method has been called, so check that this resource is still the proxy resource before clearing it out.
524 if (m_resourceToRevalidate->m_proxyResource == this) { 528 if (m_resourceToRevalidate->m_proxyResource == this) {
525 m_resourceToRevalidate->m_proxyResource = 0; 529 m_resourceToRevalidate->m_proxyResource = 0;
526 m_resourceToRevalidate->deleteIfPossible(); 530 m_resourceToRevalidate->deleteIfPossible();
527 } 531 }
528 m_handlesToRevalidate.clear(); 532 m_handlesToRevalidate.clear();
529 m_resourceToRevalidate = 0; 533 m_resourceToRevalidate = 0;
530 deleteIfPossible(); 534 deleteIfPossible();
531 } 535 }
532 536
533 void CachedResource::switchClientsToRevalidatedResource() 537 void CachedResource::switchClientsToRevalidatedResource()
534 { 538 {
535 ASSERT(m_resourceToRevalidate); 539 ASSERT(m_resourceToRevalidate);
536 ASSERT(m_resourceToRevalidate->inCache()); 540 ASSERT(m_resourceToRevalidate->inCache());
537 ASSERT(!inCache()); 541 ASSERT(!inCache());
538 542
539 LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource % p", this, m_resourceToRevalidate); 543 LOG(ResourceLoading, "CachedResource %p switchClientsToRevalidatedResource % p", this, m_resourceToRevalidate);
540 544
545 m_switchingClientsToRevalidatedResource = true;
541 HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end (); 546 HashSet<CachedResourceHandleBase*>::iterator end = m_handlesToRevalidate.end ();
542 for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate .begin(); it != end; ++it) { 547 for (HashSet<CachedResourceHandleBase*>::iterator it = m_handlesToRevalidate .begin(); it != end; ++it) {
543 CachedResourceHandleBase* handle = *it; 548 CachedResourceHandleBase* handle = *it;
544 handle->m_resource = m_resourceToRevalidate; 549 handle->m_resource = m_resourceToRevalidate;
545 m_resourceToRevalidate->registerHandle(handle); 550 m_resourceToRevalidate->registerHandle(handle);
546 --m_handleCount; 551 --m_handleCount;
547 } 552 }
548 ASSERT(!m_handleCount); 553 ASSERT(!m_handleCount);
549 m_handlesToRevalidate.clear(); 554 m_handlesToRevalidate.clear();
550 555
551 Vector<CachedResourceClient*> clientsToMove; 556 Vector<CachedResourceClient*> clientsToMove;
552 HashCountedSet<CachedResourceClient*>::iterator end2 = m_clients.end(); 557 HashCountedSet<CachedResourceClient*>::iterator end2 = m_clients.end();
553 for (HashCountedSet<CachedResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) { 558 for (HashCountedSet<CachedResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) {
554 CachedResourceClient* client = it->first; 559 CachedResourceClient* client = it->first;
555 unsigned count = it->second; 560 unsigned count = it->second;
556 while (count) { 561 while (count) {
557 clientsToMove.append(client); 562 clientsToMove.append(client);
558 --count; 563 --count;
559 } 564 }
560 } 565 }
561 // Equivalent of calling removeClient() for all clients 566 // Equivalent of calling removeClient() for all clients
562 m_clients.clear(); 567 m_clients.clear();
563 568
564 unsigned moveCount = clientsToMove.size(); 569 unsigned moveCount = clientsToMove.size();
565 for (unsigned n = 0; n < moveCount; ++n) 570 for (unsigned n = 0; n < moveCount; ++n)
566 m_resourceToRevalidate->addClientToSet(clientsToMove[n]); 571 m_resourceToRevalidate->addClientToSet(clientsToMove[n]);
567 for (unsigned n = 0; n < moveCount; ++n) { 572 for (unsigned n = 0; n < moveCount; ++n) {
573 // Calling didAddClient may do anything, including trying to cancel reva lidation.
574 // Assert that it didn't succeed.
575 ASSERT(m_resourceToRevalidate);
568 // Calling didAddClient for a client may end up removing another client. In that case it won't be in the set anymore. 576 // Calling didAddClient for a client may end up removing another client. In that case it won't be in the set anymore.
569 if (m_resourceToRevalidate->m_clients.contains(clientsToMove[n])) 577 if (m_resourceToRevalidate->m_clients.contains(clientsToMove[n]))
570 m_resourceToRevalidate->didAddClient(clientsToMove[n]); 578 m_resourceToRevalidate->didAddClient(clientsToMove[n]);
571 } 579 }
580 m_switchingClientsToRevalidatedResource = false;
572 } 581 }
573 582
574 void CachedResource::updateResponseAfterRevalidation(const ResourceResponse& val idatingResponse) 583 void CachedResource::updateResponseAfterRevalidation(const ResourceResponse& val idatingResponse)
575 { 584 {
576 m_responseTimestamp = currentTime(); 585 m_responseTimestamp = currentTime();
577 586
578 DEFINE_STATIC_LOCAL(const AtomicString, contentHeaderPrefix, ("content-")); 587 DEFINE_STATIC_LOCAL(const AtomicString, contentHeaderPrefix, ("content-"));
579 // RFC2616 10.3.5 588 // RFC2616 10.3.5
580 // Update cached headers from the 304 response 589 // Update cached headers from the 304 response
581 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); 590 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 } 719 }
711 720
712 void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority) 721 void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority)
713 { 722 {
714 if (loadPriority == ResourceLoadPriorityUnresolved) 723 if (loadPriority == ResourceLoadPriorityUnresolved)
715 return; 724 return;
716 m_loadPriority = loadPriority; 725 m_loadPriority = loadPriority;
717 } 726 }
718 727
719 } 728 }
OLDNEW
« no previous file with comments | « Source/WebCore/loader/cache/CachedResource.h ('k') | Source/WebCore/loader/cache/MemoryCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698