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

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

Issue 2399243002: Revert of Make ResourceFetcher return Resources with LoadError instead of nullptrs. (patchset #8 id… (Closed)
Patch Set: 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 rights reserved.
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 resource->setIdentifier(createUniqueIdentifier()); 425 resource->setIdentifier(createUniqueIdentifier());
426 resource->setCacheIdentifier(cacheIdentifier); 426 resource->setCacheIdentifier(cacheIdentifier);
427 resource->finish(); 427 resource->finish();
428 428
429 if (!substituteData.isValid()) 429 if (!substituteData.isValid())
430 memoryCache()->add(resource); 430 memoryCache()->add(resource);
431 431
432 return resource; 432 return resource;
433 } 433 }
434 434
435 Resource* ResourceFetcher::resourceForBlockedRequest(
436 const FetchRequest& request,
437 const ResourceFactory& factory) {
438 Resource* resource = factory.create(request.resourceRequest(),
439 request.options(), request.charset());
440 resource->error(ResourceError::cancelledDueToAccessCheckError(request.url()));
441 return resource;
442 }
443
444 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking( 435 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking(
445 Resource* resource, 436 Resource* resource,
446 const FetchRequest& request) { 437 const FetchRequest& request) {
447 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue 438 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue
448 // to not-block even after being preloaded and discovered. 439 // to not-block even after being preloaded and discovered.
449 if (resource && resource->loader() && 440 if (resource && resource->loader() &&
450 resource->isLoadEventBlockingResourceType() && 441 resource->isLoadEventBlockingResourceType() &&
451 resource->isLinkPreload() && !request.forPreload()) { 442 resource->isLinkPreload() && !request.forPreload()) {
452 m_nonBlockingLoaders.remove(resource->loader()); 443 m_nonBlockingLoaders.remove(resource->loader());
453 m_loaders.add(resource->loader()); 444 m_loaders.add(resource->loader());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url", 488 TRACE_EVENT1("blink", "ResourceFetcher::requestResource", "url",
498 urlForTraceEvent(request.url())); 489 urlForTraceEvent(request.url()));
499 490
500 if (!request.url().isValid()) 491 if (!request.url().isValid())
501 return nullptr; 492 return nullptr;
502 493
503 if (!context().canRequest( 494 if (!context().canRequest(
504 factory.type(), request.resourceRequest(), 495 factory.type(), request.resourceRequest(),
505 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), 496 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()),
506 request.options(), request.forPreload(), 497 request.options(), request.forPreload(),
507 request.getOriginRestriction())) { 498 request.getOriginRestriction()))
508 DCHECK(!substituteData.forceSynchronousLoad()); 499 return nullptr;
509 return resourceForBlockedRequest(request, factory);
510 }
511 500
512 unsigned long identifier = createUniqueIdentifier(); 501 unsigned long identifier = createUniqueIdentifier();
513 request.mutableResourceRequest().setPriority(computeLoadPriority( 502 request.mutableResourceRequest().setPriority(computeLoadPriority(
514 factory.type(), request, ResourcePriority::NotVisible)); 503 factory.type(), request, ResourcePriority::NotVisible));
515 initializeResourceRequest(request.mutableResourceRequest(), factory.type(), 504 initializeResourceRequest(request.mutableResourceRequest(), factory.type(),
516 request.defer()); 505 request.defer());
517 context().willStartLoadingResource( 506 context().willStartLoadingResource(
518 identifier, request.mutableResourceRequest(), factory.type()); 507 identifier, request.mutableResourceRequest(), factory.type());
519 if (!request.url().isValid()) 508 if (!request.url().isValid())
520 return nullptr; 509 return nullptr;
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 visitor->trace(m_context); 1593 visitor->trace(m_context);
1605 visitor->trace(m_archive); 1594 visitor->trace(m_archive);
1606 visitor->trace(m_loaders); 1595 visitor->trace(m_loaders);
1607 visitor->trace(m_nonBlockingLoaders); 1596 visitor->trace(m_nonBlockingLoaders);
1608 visitor->trace(m_documentResources); 1597 visitor->trace(m_documentResources);
1609 visitor->trace(m_preloads); 1598 visitor->trace(m_preloads);
1610 visitor->trace(m_resourceTimingInfoMap); 1599 visitor->trace(m_resourceTimingInfoMap);
1611 } 1600 }
1612 1601
1613 } // namespace blink 1602 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698