Bug 17210 - Eliminate platform-specific #ifdefs in ResourceError.h and AuthenticationChallenge.h
Summary: Eliminate platform-specific #ifdefs in ResourceError.h and AuthenticationChal...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac All
: P4 Enhancement
Assignee: Darin Fisher (:fishd, Google)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-07 11:36 PST by Darin Fisher (:fishd, Google)
Modified: 2008-02-25 18:22 PST (History)
3 users (show)

See Also:


Attachments
patch v1 (113.98 KB, patch)
2008-02-07 11:46 PST, Darin Fisher (:fishd, Google)
no flags Details | Formatted Diff | Diff
patch v2 (109.88 KB, patch)
2008-02-22 17:12 PST, Darin Fisher (:fishd, Google)
darin: review+
Details | Formatted Diff | Diff
patch v3 (110.78 KB, patch)
2008-02-25 17:48 PST, Darin Fisher (:fishd, Google)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Fisher (:fishd, Google) 2008-02-07 11:36:29 PST
Eliminate platform-specific #ifdefs in ResourceError.h and AuthenticationChallenge.h
Comment 1 Darin Fisher (:fishd, Google) 2008-02-07 11:46:04 PST
Created attachment 18986 [details]
patch v1

This patch introduces ResourceErrorBase and AuthenticationChallengeBase, similar to what was done for ResourceResponse and ResourceRequest.

Some things to note about this patch:

1- Generic implementations of AuthenticationChallenge, ResourceError, ResourceRequest, and ResourceResponse are now in a newly created network/generic directory.  Ports that do not need to customize these classes can just include the generic ones.  There does not seem to be any convention for this in WebKit, so I'm not sure how this will be received.  Please advise if you prefer another way.

2- The global operator== defined for many of these types is now implemented by calling a compare function defined on the *Base class.  That compare function then calls a platformCompare function to allow the platform to implement the equality test for platform-specific fields.  I chose the name "compare" after seeing it used in Vector.h.  I applied this technique to the operator== implemented for ResourceResponse, which frees ResourceResponseBase.cpp of a platform-specific #ifdef.

3- Many of these classes require lazy initialization on Mac and CF ports.  I came up with a fairly uniform way of dealing with this.  Each method that may need to perform lazy initialization, now calls a lazyInit function defined on the *Base class.  That function simply downcasts to the non-Base class and calls a platformLazyInit function.  The *Base class also defines platformLazyInit to do nothing.  That way, if a port does not define platformLazyInit, then all of the lazyInit calls should be simply eliminated by the compiler.  This takes advantage of how method names are shadowed by subclasses in C++.

I've tried to be fairly methodical with this patch.  Hopefully once you review one of the classes, the changes to the second will be obvious and also straightforward to review.
Comment 2 Darin Adler 2008-02-07 11:55:34 PST
(In reply to comment #1)
> 1- Generic implementations of AuthenticationChallenge, ResourceError,
> ResourceRequest, and ResourceResponse are now in a newly created
> network/generic directory.  Ports that do not need to customize these classes
> can just include the generic ones.  There does not seem to be any convention
> for this in WebKit, so I'm not sure how this will be received.  Please advise
> if you prefer another way.

I think it is fine to have these files, but they should be in the top level network directory, not a new one named "generic". I don't think "generic" makes the purpose of the files clearer. Comments in the files should explain when you'd use them.
Comment 3 Darin Fisher (:fishd, Google) 2008-02-07 14:31:17 PST
Well, since not every platform is going to use the generic versions of ResourcError.h, etc., it seems like it would be confusing to have them in the common base directory.  I thought it might be wierd to have a ResourceError.h in platform/network/ as well as in platform/network/mac/.  That doesn't seem awkward (potentially confusing) to you?
Comment 4 Darin Adler 2008-02-10 21:20:18 PST
(In reply to comment #3)
> Well, since not every platform is going to use the generic versions of
> ResourcError.h, etc., it seems like it would be confusing to have them in the
> common base directory.  I thought it might be wierd to have a ResourceError.h
> in platform/network/ as well as in platform/network/mac/.  That doesn't seem
> awkward (potentially confusing) to you?

Sure, that'd be more than awkward; it wouldn't even work with our build system.

I guess I didn't realize that your designs involved same named files in different directories. The old design went out of its way to avoid that; I see now that's the tradeoff here.

I'm still not sure "generic" is the right name for these. I'd like to understand what the quality would be that would allow a platform to use the base versions of the classes without adding anything.

I think Anders Carlsson should probably review this patch. I'll cc him on this bug so he'll notice it.
Comment 5 Darin Fisher (:fishd, Google) 2008-02-10 22:47:07 PST
I'm happy to kill the generic directory if that would be preferred.  I just thought it would be useful for new ports (sort of a starting point for a port).  The qt and curl ports just happen to be able to use most of the files in the generic folder.
Comment 6 Robert Blaut 2008-02-20 03:32:19 PST
P5 is not used for WebKit bugs. [http://webkit.org/quality/bugpriorities.html]
Comment 7 Darin Fisher (:fishd, Google) 2008-02-22 17:12:29 PST
Created attachment 19285 [details]
patch v2

OK, here's a version of the patch sans-generic folder.
Comment 8 Darin Adler 2008-02-23 09:28:45 PST
Comment on attachment 19285 [details]
patch v2

One thing I don't like about this approach is that we end up with so many identically named files in different directories. But it looks like you executed the design just fine.

r=me
Comment 9 Mark Rowe (bdash) 2008-02-25 05:21:50 PST
This patch does not apply cleanly to SVN as of r30564 due to conflicts in WebCore.vcproj and WebCore.xcodeproj.  Can you please regenerate this patch against SVN HEAD and attach it so that it can be landed?
Comment 10 Darin Fisher (:fishd, Google) 2008-02-25 12:58:54 PST
> One thing I don't like about this approach is that we end up with so many
> identically named files in different directories. But it looks like you
> executed the design just fine.

Hi Darin.  I plan on contributing more patches like this, so please let me know if you have a more preferred design that I should apply instead.  Thanks!
Comment 11 Darin Adler 2008-02-25 13:05:40 PST
(In reply to comment #10)
> > One thing I don't like about this approach is that we end up with so many
> > identically named files in different directories. But it looks like you
> > executed the design just fine.
> 
> Hi Darin.  I plan on contributing more patches like this, so please let me know
> if you have a more preferred design that I should apply instead. Thanks!

I'll let you know if I think of something.
Comment 12 Darin Fisher (:fishd, Google) 2008-02-25 17:48:22 PST
Created attachment 19367 [details]
patch v3

OK, here's the merged version.
Comment 13 Mark Rowe (bdash) 2008-02-25 18:22:52 PST
Landed in r30584.