Bug 47041 - Magical true/false parameters are difficult to understand when creating ResourceHandle
Summary: Magical true/false parameters are difficult to understand when creating Resou...
Status: RESOLVED LATER
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-01 19:08 PDT by Adam Barth
Modified: 2010-12-14 12:16 PST (History)
3 users (show)

See Also:


Attachments
Patch (29.94 KB, patch)
2010-10-01 19:11 PDT, Adam Barth
darin: review+
ap: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2010-10-01 19:08:58 PDT
Magical true/false parameters are difficult to understand when creating ResourceHandle
Comment 1 Adam Barth 2010-10-01 19:11:52 PDT
Created attachment 69562 [details]
Patch
Comment 2 Alexey Proskuryakov 2010-10-02 22:45:19 PDT
Comment on attachment 69562 [details]
Patch

+        m_loader = SubresourceLoader::create(m_document->frame(), this, request, securityCheck, sendLoadCallbacks, contentSniffingOption);

It's challenging to come up with good names for these enums and arguments, but I don't remember us ever using "Option" for that. Maybe it's better than what we did before, and we should standardize on it?

+#include "ResourceHandle.h"

Please remove forward declaration of ResourceHandle from ResourceLoader.h, now that you include the header.

The need for additional includes is a common problem with these enums, too. Logically, code that constructs a ResourceLoader shouldn't need to know that there are ResourceHandles below, or to include ResourceHandle.h.

-    if (!shouldContentSniff) {
+    if (contentSniffingOption == ShouldNotSniffContent) {

I don't think that this part is an improvement. All kinds of questions like "are there any other possible values" immediately arise, making the code less readable.

At some sufficiently low level, bools should probably remain bools.

I chose to be extra picky in this review, despite the fact that these problems are well known and not well solved in WebKit code base, because I suspect that you're up to a large scale refactoring here. That would be a good moment to pause and take a second look.
Comment 3 Adam Barth 2010-10-02 22:49:14 PDT
> I chose to be extra picky in this review, despite the fact that these problems are well known and not well solved in WebKit code base, because I suspect that you're up to a large scale refactoring here. That would be a good moment to pause and take a second look.

Oh, I appreciate your being extra picky.  These patches are my way of exploring the code while improving it.  Do you think the enum approach isn't worth doing?  It seems helpful at the call sites where we just pass raw bools today.

In general, I like the way ThreadableLoader works where you pass in an options object.  Would you like me try an approach like that?
Comment 4 Darin Adler 2010-10-03 10:26:05 PDT
Comment on attachment 69562 [details]
Patch

Looks fine. In some other cases we have called these “policies” rather than “options”, so that sort of alternate terminology might be worth considering.
Comment 5 Eric Seidel (no email) 2010-12-14 01:55:46 PST
What's the status here Adam?
Comment 6 Adam Barth 2010-12-14 12:16:03 PST
This patch requires some changes before landing, but I'm busy with other patches at the moment.  I'd like to come back to this patch, but for now I'm markings this as LATER so it doesn't pollute the pending-commit list.