WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
162146
Clean-up CachedResourceLoader::requestResource after
r206016
https://bugs.webkit.org/show_bug.cgi?id=162146
Summary
Clean-up CachedResourceLoader::requestResource after r206016
youenn fablet
Reported
2016-09-19 03:38:53 PDT
CachedResourceRequest is moved to construct a CachedResource. This makes CachedResourceLoader::requestResource currently storing some fields of CachedResourceRequest before moving it.
Attachments
Patch
(14.81 KB, patch)
2016-09-19 03:47 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(20.96 KB, patch)
2016-09-21 02:57 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
youenn fablet
Comment 1
2016-09-19 03:47:05 PDT
Created
attachment 289223
[details]
Patch
Alex Christensen
Comment 2
2016-09-20 18:28:46 PDT
Comment on
attachment 289223
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=289223&action=review
> Source/WebCore/loader/cache/CachedResourceLoader.cpp:1178 > + CachedResourceHandle<CachedResource> resource = requestResource(type, WTFMove(request), true);
This value of true should be given a name.
> Source/WebCore/loader/cache/CachedResourceLoader.h:151 > + enum class ForPreload { True, False };
Use this instead of bools. In WebKit we use No, Yes for things like this.
youenn fablet
Comment 3
2016-09-21 02:52:31 PDT
Thanks for the review. (In reply to
comment #2
)
> Comment on
attachment 289223
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=289223&action=review
> > > Source/WebCore/loader/cache/CachedResourceLoader.cpp:1178 > > + CachedResourceHandle<CachedResource> resource = requestResource(type, WTFMove(request), true); > > This value of true should be given a name.
OK, I will use an enum class. The main issue I see is that instead of writing "if (forPreload)" We need to write "if (forPreload == ...)" Maybe we can find a way to have both advantages?
youenn fablet
Comment 4
2016-09-21 02:57:51 PDT
Created
attachment 289440
[details]
Patch
youenn fablet
Comment 5
2016-09-21 03:00:37 PDT
(In reply to
comment #4
)
> Created
attachment 289440
[details]
> Patch
Patch also removed redirectResponse boolean. This improves over
bug 162144
.
Darin Adler
Comment 6
2016-09-21 11:02:23 PDT
Our typical pattern is this: - If we use constants for an argument with a generic type like "bool" that makes it hard to understand the meaning of the argument at the call site we do one of the following: 1) Break into two separate functions rather than using a boolean argument to create two separate behaviors. This underused option is often quite effective in making code easy to read and even can push us toward better factoring. The pattern of “do a big job and then look at a boolean in the middle to do two variations” is not really a great one. 2) Move the boolean into an object that can either be a high level policy object like a security origin or just a simple structure with well-named fields; also helps make code that has to move multiple arguments along from one function to another easier to read. 3) Use a named enum value instead of a boolean. Can be tricky to decide whether to use enum class or enum and whether to make the enum a class member or at the namespace level. - If the value passed in is not a constant, but rather computed, then we are willing to use a boolean and we try not to change to an enum. The time we run into trouble is when we have a function that often takes a constant but sometimes takes a computed value, and the value is not just the enum passed through, rather is computed some other way. Then we often find we have to convert a boolean expression into an enum value and then back to a boolean. Super ugly. But keep the rules above in mind because there are often alternate paths.
youenn fablet
Comment 7
2016-10-17 08:19:27 PDT
This was fixed in another of my patch
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug