RESOLVED FIXED 32529
Rename skipCanLoadCheck to skipSecurityCheck
https://bugs.webkit.org/show_bug.cgi?id=32529
Summary Rename skipCanLoadCheck to skipSecurityCheck
Nate Chapin
Reported Monday, December 14, 2009 9:05:15 PM UTC
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 Monday, December 14, 2009 9:09:25 PM UTC
Eric Seidel (no email)
Comment 2 Monday, December 14, 2009 9:18:50 PM UTC
Comment on attachment 44813 [details] patch This looks good to me. Sooooo much more readable!
Brady Eidson
Comment 3 Monday, December 14, 2009 9:22:05 PM UTC
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 Monday, December 14, 2009 11:50:52 PM UTC
I'm not sure this is the optimal name, but it's lightyears better than what we have currently.
Darin Adler
Comment 5 Tuesday, December 15, 2009 1:19:24 AM UTC
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 Tuesday, December 15, 2009 5:01:45 PM UTC
(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 Tuesday, December 15, 2009 7:31:43 PM UTC
Created attachment 44891 [details] patch2 Better safe than sorry, here's the patch with darin's comments addressed.
WebKit Review Bot
Comment 8 Tuesday, December 15, 2009 7:32:09 PM UTC
style-queue ran check-webkit-style on attachment 44891 [details] without any errors.
Darin Adler
Comment 9 Tuesday, December 15, 2009 9:59:03 PM UTC
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 Tuesday, December 15, 2009 10:01:04 PM UTC
(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 Tuesday, December 15, 2009 10:03:14 PM UTC
(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 Tuesday, December 15, 2009 10:06:43 PM UTC
Created attachment 44909 [details] patch3 - reordered SecurityCheck enum
WebKit Review Bot
Comment 13 Tuesday, December 15, 2009 10:08:03 PM UTC
style-queue ran check-webkit-style on attachment 44909 [details] without any errors.
Darin Adler
Comment 14 Tuesday, December 15, 2009 10:09:50 PM UTC
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 Tuesday, December 15, 2009 10:12:47 PM UTC
(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 Tuesday, December 15, 2009 10:19:06 PM UTC
(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 Tuesday, December 15, 2009 10:39:45 PM UTC
Created attachment 44912 [details] patch4 - renamed to SecurityCheckPolicy
Nate Chapin
Comment 18 Wednesday, December 16, 2009 7:34:38 PM UTC
Note You need to log in before you can comment on or make changes to this bug.