Bug 175505 - Update CachedResourceLoader::requestResource() to return a WTF::Expected
Summary: Update CachedResourceLoader::requestResource() to return a WTF::Expected
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on: 175482
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-11 16:55 PDT by Chris Dumez
Modified: 2017-08-15 14:16 PDT (History)
6 users (show)

See Also:


Attachments
Patch (49.54 KB, patch)
2017-08-12 23:26 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (51.55 KB, patch)
2017-08-13 09:18 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (53.77 KB, patch)
2017-08-14 09:54 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (54.16 KB, patch)
2017-08-15 12:40 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-08-11 16:55:22 PDT
Update CachedResourceLoader::requestResource() & co. to return a WTF::Expected instead of using an out parameter for the ResourceError.
Comment 1 Chris Dumez 2017-08-12 23:26:41 PDT
Created attachment 318006 [details]
Patch
Comment 2 Chris Dumez 2017-08-12 23:27:12 PDT
@Sam: Here is what it looks like.
Comment 3 Chris Dumez 2017-08-13 09:18:32 PDT
Created attachment 318010 [details]
Patch
Comment 4 youenn fablet 2017-08-13 20:30:43 PDT
Comment on attachment 318010 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=318010&action=review

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:93
> +        return CachedResourceHandle<T> { static_cast<T*>(cachedResource.value().get()) };

In changed code, a downcast was used. Why using a static_cast here?

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:729
> +                CachedResourceHandle<CachedResource> resource = createResource(type, WTFMove(request), sessionID());

Can we make createResource return a CachedResourceHandle<CachedResource> instead?

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:800
> +            if (!shouldContinueAfterNotifyingLoadedFromMemoryCache(request, resource.get(), error))

Would returning an optional make it better?

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:839
> +                return makeUnexpected(ResourceError { String(), 0, url, String(), ResourceError::Type::AccessControl });

AccessControl is usually the reason of immediate failures.
Would be cool to have not null resource errors in the future.

> Source/WebCore/loader/cache/CachedResourceLoader.cpp:1258
> +        auto resourceValue = resource.value();

auto& maybe?

> Source/WebCore/loader/cache/CachedResourceLoader.h:178
> +    bool shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest&, CachedResource*, ResourceError&);

Pre-existing code issue but it would seem that we should pass a const CachedResource* and probably even better a const CachedResource&.
Comment 5 Chris Dumez 2017-08-14 09:54:05 PDT
Created attachment 318044 [details]
Patch
Comment 6 Chris Dumez 2017-08-15 12:40:16 PDT
Created attachment 318149 [details]
Patch
Comment 7 Chris Dumez 2017-08-15 14:15:13 PDT
Comment on attachment 318149 [details]
Patch

Clearing flags on attachment: 318149

Committed r220760: <http://trac.webkit.org/changeset/220760>
Comment 8 Chris Dumez 2017-08-15 14:15:15 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2017-08-15 14:16:06 PDT
<rdar://problem/33903768>