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

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

Issue 2231523002: Make ResourceFetcher return Resources with LoadError instead of nullptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, resolve comment rewrap conflicts. Created 4 years, 2 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 void Resource::didAddClient(ResourceClient* c) { 638 void Resource::didAddClient(ResourceClient* c) {
639 if (isLoaded()) { 639 if (isLoaded()) {
640 c->notifyFinished(this); 640 c->notifyFinished(this);
641 if (m_clients.contains(c)) { 641 if (m_clients.contains(c)) {
642 m_finishedClients.add(c); 642 m_finishedClients.add(c);
643 m_clients.remove(c); 643 m_clients.remove(c);
644 } 644 }
645 } 645 }
646 } 646 }
647 647
648 static bool shouldSendCachedDataSynchronouslyForType(Resource::Type type) { 648 static bool typeNeedsSynchronousCacheHit(Resource::Type type) {
649 // Some resources types default to return data synchronously. For most of 649 // Some resources types default to return data synchronously. For most of
650 // these, it's because there are layout tests that expect data to return 650 // these, it's because there are layout tests that expect data to return
651 // synchronously in case of cache hit. In the case of fonts, there was a 651 // synchronously in case of cache hit. In the case of fonts, there was a
652 // performance regression. 652 // performance regression.
653 // FIXME: Get to the point where we don't need to special-case sync/async 653 // FIXME: Get to the point where we don't need to special-case sync/async
654 // behavior for different resource types. 654 // behavior for different resource types.
655 if (type == Resource::Image) 655 if (type == Resource::Image)
656 return true; 656 return true;
657 if (type == Resource::CSSStyleSheet) 657 if (type == Resource::CSSStyleSheet)
658 return true; 658 return true;
(...skipping 29 matching lines...) Expand all
688 688
689 void Resource::addClient(ResourceClient* client, 689 void Resource::addClient(ResourceClient* client,
690 PreloadReferencePolicy policy) { 690 PreloadReferencePolicy policy) {
691 willAddClientOrObserver(policy); 691 willAddClientOrObserver(policy);
692 692
693 if (m_isRevalidating) { 693 if (m_isRevalidating) {
694 m_clients.add(client); 694 m_clients.add(client);
695 return; 695 return;
696 } 696 }
697 697
698 // If we have existing data to send to the new client and the resource type 698 // If an error has occurred or we have existing data to send to the new client
699 // supprts it, send it asynchronously. 699 // and the resource type supprts it, send it asynchronously.
700 if (!m_response.isNull() && 700 if ((errorOccurred() || !m_response.isNull()) &&
701 !shouldSendCachedDataSynchronouslyForType(getType()) && 701 !typeNeedsSynchronousCacheHit(getType()) && !m_needsSynchronousCacheHit) {
702 !m_needsSynchronousCacheHit) {
703 m_clientsAwaitingCallback.add(client); 702 m_clientsAwaitingCallback.add(client);
704 ResourceCallback::callbackHandler().schedule(this); 703 ResourceCallback::callbackHandler().schedule(this);
705 return; 704 return;
706 } 705 }
707 706
708 m_clients.add(client); 707 m_clients.add(client);
709 didAddClient(client); 708 didAddClient(client);
710 return; 709 return;
711 } 710 }
712 711
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 case Resource::TextTrack: 1074 case Resource::TextTrack:
1076 case Resource::Media: 1075 case Resource::Media:
1077 case Resource::Manifest: 1076 case Resource::Manifest:
1078 return false; 1077 return false;
1079 } 1078 }
1080 NOTREACHED(); 1079 NOTREACHED();
1081 return false; 1080 return false;
1082 } 1081 }
1083 1082
1084 } // namespace blink 1083 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698