Bug 32529

Summary: Rename skipCanLoadCheck to skipSecurityCheck
Product: WebKit Reporter: Nate Chapin <japhet>
Component: WebCore Misc.Assignee: Nate Chapin <japhet>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, beidson, darin, eric, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 30457    
Attachments:
Description Flags
patch
eric: review+
patch2
darin: review-
patch3 - reordered SecurityCheck enum
darin: review+
patch4 - renamed to SecurityCheckPolicy darin: review+

Nate Chapin
Reported 2009-12-14 13:05:15 PST
First step of https://bugs.webkit.org/show_bug.cgi?id=30457. The next step will include separating the can load check into the security check and a check as to whether the current subresource load should be allowed to outlive the page that spawned it.
Attachments
patch (15.38 KB, patch)
2009-12-14 13:09 PST, Nate Chapin
eric: review+
patch2 (15.36 KB, patch)
2009-12-15 11:31 PST, Nate Chapin
darin: review-
patch3 - reordered SecurityCheck enum (15.36 KB, patch)
2009-12-15 14:06 PST, Nate Chapin
darin: review+
patch4 - renamed to SecurityCheckPolicy (15.44 KB, patch)
2009-12-15 14:39 PST, Nate Chapin
darin: review+
Nate Chapin
Comment 1 2009-12-14 13:09:25 PST
Eric Seidel (no email)
Comment 2 2009-12-14 13:18:50 PST
Comment on attachment 44813 [details] patch This looks good to me. Sooooo much more readable!
Brady Eidson
Comment 3 2009-12-14 13:22:05 PST
I think Sam should look at this before it lands, he's the most likely to have an opinion on it.
Adam Barth
Comment 4 2009-12-14 15:50:52 PST
I'm not sure this is the optimal name, but it's lightyears better than what we have currently.
Darin Adler
Comment 5 2009-12-14 17:19:24 PST
Comment on attachment 44813 [details] patch > + void load(DocLoader*, CachedResource*, bool incremental = true, SecurityCheck securityCheck = DoSecurityCheck, bool sendResourceLoadCallbacks = true); One of the great things about using a named type is that you can, and should, leave out the argument name in cases like this one. > > + void load(DocLoader*, bool incremental, SecurityCheck securityCheck, bool sendResourceLoadCallbacks); And this one. > > + Request(DocLoader*, CachedResource*, bool incremental, SecurityCheck securityCheck, bool sendResourceLoadCallbacks); And this one. > + SecurityCheck shouldDoSecurityCheck() const { return m_securityCheck; } The data member and the function member should have the same name. > + void loadRequest(const ResourceRequest&, SecurityCheck securityCheck); Another place where you can omit the argument name. > + if ((securityCheck == DoSecurityCheck) && (fl->state() == FrameStateProvisional || fl->activeDocumentLoader()->isStopping())) We normally would not include the parentheses around the "==" expression. It's so idiomatic to combine "==" with "&&" and "||" that we don't feel we need parentheses to make it clear. > + if ((securityCheck == DoSecurityCheck) Ditto. > + // ok to skip load check since we already asked about the preflight request Would be nice to format this comment as a sentence, which is our preferred style. > + static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, const ResourceRequest&, SecurityCheck securityCheck = DoSecurityCheck, bool sendResourceLoadCallbacks = true, bool shouldContentSniff = true); Another place to omit the argument name. I feel bad about suggesting FrameLoaderTypes for this. Wish I could have thought of a better header.
Nate Chapin
Comment 6 2009-12-15 09:01:45 PST
(In reply to comment #5) > (From update of attachment 44813 [details]) > > + void load(DocLoader*, CachedResource*, bool incremental = true, SecurityCheck securityCheck = DoSecurityCheck, bool sendResourceLoadCallbacks = true); > > One of the great things about using a named type is that you can, and should, > leave out the argument name in cases like this one. > > > > + void load(DocLoader*, bool incremental, SecurityCheck securityCheck, bool sendResourceLoadCallbacks); > > And this one. > > > > + Request(DocLoader*, CachedResource*, bool incremental, SecurityCheck securityCheck, bool sendResourceLoadCallbacks); > > And this one. > > > + SecurityCheck shouldDoSecurityCheck() const { return m_securityCheck; } > > The data member and the function member should have the same name. > > > + void loadRequest(const ResourceRequest&, SecurityCheck securityCheck); > > Another place where you can omit the argument name. > > > + if ((securityCheck == DoSecurityCheck) && (fl->state() == FrameStateProvisional || fl->activeDocumentLoader()->isStopping())) > > We normally would not include the parentheses around the "==" expression. It's > so idiomatic to combine "==" with "&&" and "||" that we don't feel we need > parentheses to make it clear. > > > + if ((securityCheck == DoSecurityCheck) > > Ditto. > > > + // ok to skip load check since we already asked about the preflight request > > Would be nice to format this comment as a sentence, which is our preferred > style. > > > + static PassRefPtr<SubresourceLoader> create(Frame*, SubresourceLoaderClient*, const ResourceRequest&, SecurityCheck securityCheck = DoSecurityCheck, bool sendResourceLoadCallbacks = true, bool shouldContentSniff = true); > > Another place to omit the argument name. > > I feel bad about suggesting FrameLoaderTypes for this. Wish I could have > thought of a better header. All are now done locally. These changes seem pretty trivial to me, do you want me to upload and go through another review cycle or just submit?
Nate Chapin
Comment 7 2009-12-15 11:31:43 PST
Created attachment 44891 [details] patch2 Better safe than sorry, here's the patch with darin's comments addressed.
WebKit Review Bot
Comment 8 2009-12-15 11:32:09 PST
style-queue ran check-webkit-style on attachment 44891 [details] without any errors.
Darin Adler
Comment 9 2009-12-15 13:59:03 PST
Comment on attachment 44891 [details] patch2 Sorry, I'm not trying to be difficult, but I see a problem now introduced by the changes I suggested. > + enum SecurityCheck { > + DoSecurityCheck, > + SkipSecurityCheck > + }; > - bool shouldSkipCanLoadCheck() const { return m_shouldSkipCanLoadCheck; } > + SecurityCheck shouldDoSecurityCheck() const { return m_shouldDoSecurityCheck; } This is a risky combination. The value of DoSecurityCheck is 0 and SkipSecurityCheck is 1, so this code: if (object->shouldDoSecurityCheck()) would look right, but be wrong. We should make the name of the function and data member be shouldSkipSecurityCheck or something neutral like securityCheckPolicy that does not imply a true/false mapping.
Nate Chapin
Comment 10 2009-12-15 14:01:04 PST
(In reply to comment #9) > (From update of attachment 44891 [details]) > Sorry, I'm not trying to be difficult, but I see a problem now introduced by > the changes I suggested. > > > + enum SecurityCheck { > > + DoSecurityCheck, > > + SkipSecurityCheck > > + }; > > > - bool shouldSkipCanLoadCheck() const { return m_shouldSkipCanLoadCheck; } > > + SecurityCheck shouldDoSecurityCheck() const { return m_shouldDoSecurityCheck; } > > This is a risky combination. The value of DoSecurityCheck is 0 and > SkipSecurityCheck is 1, so this code: > > if (object->shouldDoSecurityCheck()) > > would look right, but be wrong. We should make the name of the function and > data member be shouldSkipSecurityCheck or something neutral like > securityCheckPolicy that does not imply a true/false mapping. Good point. Do you have a preference on renaming vs. switching the ordering in the enum so SkipSecurityCheck is 0 and DoSecurityCheck is 1?
Darin Adler
Comment 11 2009-12-15 14:03:14 PST
(In reply to comment #10) > Good point. Do you have a preference on renaming vs. switching the ordering in > the enum so SkipSecurityCheck is 0 and DoSecurityCheck is 1? I slightly prefer switching the ordering, because I think an affirmative “do the check” is an easier concept than “skip the check”.
Nate Chapin
Comment 12 2009-12-15 14:06:43 PST
Created attachment 44909 [details] patch3 - reordered SecurityCheck enum
WebKit Review Bot
Comment 13 2009-12-15 14:08:03 PST
style-queue ran check-webkit-style on attachment 44909 [details] without any errors.
Darin Adler
Comment 14 2009-12-15 14:09:50 PST
Comment on attachment 44909 [details] patch3 - reordered SecurityCheck enum This is great. r=me Next time we name a type like this, we should consider how the type name works conceptually. The type is named SecurityCheck, yet the object is not a security check. It's a decision about whether security checks should be performed. I think I would have called the type SecurityCheckPolicy.
Nate Chapin
Comment 15 2009-12-15 14:12:47 PST
(In reply to comment #14) > (From update of attachment 44909 [details]) > This is great. r=me > > Next time we name a type like this, we should consider how the type name works > conceptually. The type is named SecurityCheck, yet the object is not a security > check. It's a decision about whether security checks should be performed. I > think I would have called the type SecurityCheckPolicy. Yeah, SecurityCheckPolicy is probably a better name. I'll rename it if you're willing to suffer through another round of review :)
Darin Adler
Comment 16 2009-12-15 14:19:06 PST
(In reply to comment #15) > I'll rename it if you're willing to suffer through another round of review :) I'm game.
Nate Chapin
Comment 17 2009-12-15 14:39:45 PST
Created attachment 44912 [details] patch4 - renamed to SecurityCheckPolicy
Nate Chapin
Comment 18 2009-12-16 11:34:38 PST
Note You need to log in before you can comment on or make changes to this bug.