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

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

Issue 1923003002: Clear Resource::m_loader in Resource::finish() and Resource::error() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 { 328 {
329 if (!m_revalidatingRequest.isNull()) 329 if (!m_revalidatingRequest.isNull())
330 m_revalidatingRequest = ResourceRequest(); 330 m_revalidatingRequest = ResourceRequest();
331 331
332 if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded())) 332 if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded()))
333 memoryCache()->remove(this); 333 memoryCache()->remove(this);
334 334
335 setStatus(status); 335 setStatus(status);
336 ASSERT(errorOccurred()); 336 ASSERT(errorOccurred());
337 m_data.clear(); 337 m_data.clear();
338 m_loader = nullptr;
338 checkNotify(); 339 checkNotify();
339 markClientsAndObserversFinished(); 340 markClientsAndObserversFinished();
340 } 341 }
341 342
342 void Resource::finish() 343 void Resource::finish()
343 { 344 {
344 ASSERT(m_revalidatingRequest.isNull()); 345 ASSERT(m_revalidatingRequest.isNull());
345 if (!errorOccurred()) 346 if (!errorOccurred())
346 m_status = Cached; 347 m_status = Cached;
348 m_loader = nullptr;
347 checkNotify(); 349 checkNotify();
348 markClientsAndObserversFinished(); 350 markClientsAndObserversFinished();
349 } 351 }
350 352
351 AtomicString Resource::httpContentType() const 353 AtomicString Resource::httpContentType() const
352 { 354 {
353 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co ntent_Type).lower()); 355 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co ntent_Type).lower());
354 } 356 }
355 357
356 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const 358 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return builder.toString(); 585 return builder.toString();
584 } 586 }
585 587
586 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const 588 CachedMetadata* Resource::cachedMetadata(unsigned dataTypeID) const
587 { 589 {
588 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID) 590 if (!m_cachedMetadata || m_cachedMetadata->dataTypeID() != dataTypeID)
589 return nullptr; 591 return nullptr;
590 return m_cachedMetadata.get(); 592 return m_cachedMetadata.get();
591 } 593 }
592 594
593 void Resource::clearLoader()
594 {
595 m_loader = nullptr;
596 }
597
598 void Resource::didAddClient(ResourceClient* c) 595 void Resource::didAddClient(ResourceClient* c)
599 { 596 {
600 if (isLoaded()) { 597 if (isLoaded()) {
601 c->notifyFinished(this); 598 c->notifyFinished(this);
602 if (m_clients.contains(c)) { 599 if (m_clients.contains(c)) {
603 m_finishedClients.add(c); 600 m_finishedClients.add(c);
604 m_clients.remove(c); 601 m_clients.remove(c);
605 } 602 }
606 } 603 }
607 } 604 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 cancelTimerFired(&m_cancelTimer); 703 cancelTimerFired(&m_cancelTimer);
707 else if (!m_cancelTimer.isActive()) 704 else if (!m_cancelTimer.isActive())
708 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE); 705 m_cancelTimer.startOneShot(0, BLINK_FROM_HERE);
709 706
710 unlock(); 707 unlock();
711 } 708 }
712 709
713 void Resource::cancelTimerFired(Timer<Resource>* timer) 710 void Resource::cancelTimerFired(Timer<Resource>* timer)
714 { 711 {
715 ASSERT_UNUSED(timer, timer == &m_cancelTimer); 712 ASSERT_UNUSED(timer, timer == &m_cancelTimer);
716 if (hasClientsOrObservers() || !m_loader) 713 if (!hasClientsOrObservers() && m_loader)
717 return; 714 m_loader->cancel();
718 m_loader->cancelIfNotFinishing();
Nate Chapin 2016/04/27 19:48:30 Since m_loader is nulled before sending load compl
719 memoryCache()->remove(this);
Nate Chapin 2016/04/27 19:48:30 This was a dumb hack to work around tests with uns
720 } 715 }
721 716
722 void Resource::setDecodedSize(size_t decodedSize) 717 void Resource::setDecodedSize(size_t decodedSize)
723 { 718 {
724 if (decodedSize == m_decodedSize) 719 if (decodedSize == m_decodedSize)
725 return; 720 return;
726 size_t oldSize = size(); 721 size_t oldSize = size();
727 m_decodedSize = decodedSize; 722 m_decodedSize = decodedSize;
728 memoryCache()->update(this, oldSize, size()); 723 memoryCache()->update(this, oldSize, size());
729 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange); 724 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 case Resource::Media: 1069 case Resource::Media:
1075 return "Media"; 1070 return "Media";
1076 case Resource::Manifest: 1071 case Resource::Manifest:
1077 return "Manifest"; 1072 return "Manifest";
1078 } 1073 }
1079 ASSERT_NOT_REACHED(); 1074 ASSERT_NOT_REACHED();
1080 return "Unknown"; 1075 return "Unknown";
1081 } 1076 }
1082 1077
1083 } // namespace blink 1078 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698