Bug 15334

Summary: Split ResourceResponse into platform specific files
Product: WebKit Reporter: Julien Chaffraix <jchaffraix>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Enhancement CC: mrowe
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
First draft
darin: review-
Patch updated with Darin's comment
none
Patch updated with XCode information and tested on Mac darin: review+

Description Julien Chaffraix 2007-10-01 11:47:38 PDT
ResourceRequest was split into platform specific files (
http://bugs.webkit.org/show_bug.cgi?id=14225). The idea is to have the same with ResourceResponse.

The following patch uses this bug as a guideline to use the same pattern with ResourceResponse.
Comment 1 Julien Chaffraix 2007-10-01 12:02:16 PDT
Created attachment 16487 [details]
First draft

The patch should cover all platforms but has only been tested on Linux (both qt and gdk).

The patch also misses the entries in WebCore.xcodeproj/project.pbxproj as I do not have a mac with Xcode on which generating those entries.
Comment 2 Eric Seidel (no email) 2007-10-01 12:45:52 PDT
Hum... I didn't look very closely, but normally we use Foo instead of FooBase for base class names, and then each platform has its own implementation, like FooMac or FooWin, etc.  But perhaps that won't work for this case... again I didn't look closely.
Comment 3 Dave Hyatt 2007-10-01 13:40:42 PDT
If you look at other examples in platform, we usually retain a single cross-platform header and then just use ifdefs in that header for platform-specific methods.  This way we don't have a proliferation of platform-specific header files.

We make exceptions sometimes but usually only for classes for which the bulk of the implementation (nearly all) is platform-specific.

Comment 4 Dave Hyatt 2007-10-01 13:42:44 PDT
I am not sure why ResourceRequest was split up the way it was.  It doesn't really follow our convention.  Maybe we are moving to this model.  I'll defer to mjs, since I'm kind of confused now.


Comment 5 Darin Adler 2007-10-04 09:13:25 PDT
Comment on attachment 16487 [details]
First draft

This patch would be easier to review if you did an "svn move" of ResourceResponse.cpp to ResourceResponseBase.cpp -- the patch would then show only diffs, rather than showing the entire file as changed and we also wouldn't lose history on the files. svn-create-patch does a good job of handling cases like that.

+    void doUpdateResourceResponse() {
+        notImplemented();
+    }

We put braces on the second line, not the first.

+    const_cast<ResourceResponse&>(asResourceResponse()).doUpdateResourceResponse();

Why use const_cast here? Could we instead make the relevant members all be mutable? I'm always uncomfortable with the "do" prefix in cases like this. Perhaps we could come up with a more descriptive name for the function that does the actual work.

+    //Used when response is initialized from a platform representation

We normally put a space after the "//".

We normally don't put a blank line after "protected:" etc.

I'm going to mark this review- because I'd like to instead see a version of the patch that does "svn move".
Comment 6 Darin Adler 2007-10-04 09:14:15 PDT
Oh, and also we need someone with Macintosh to do the Xcode project updates too; can't do review+ until the patch has that. So someone will have to help Julien.
Comment 7 Julien Chaffraix 2007-10-17 14:16:59 PDT
Created attachment 16707 [details]
Patch updated with Darin's comment

The new patch has been generated with "svn move" and "svn-create-patch". Thanks for the tip.

Again the patch has been tested only on linux.

>+
>const_cast<ResourceResponse&>(asResourceResponse()).doUpdateResourceResponse();

> Why use const_cast here? Could we instead make the relevant members all be
> mutable?

After a quick look at the code, adding mutable to the members of  ResourceResponseBase would leave only one member non-mutable so I do not think that is worth it.

I agree that the 2 casts are not really beautiful. I have tried a lot of alternatives and the conclusion is that we need the 2 casts.

> I'm always uncomfortable with the "do" prefix in cases like this.
> Perhaps we could come up with a more descriptive name for the function that
> does the actual work.

I could not find a better name. Maybe someone has a better idea.
Comment 8 Darin Adler 2007-10-17 21:02:50 PDT
Comment on attachment 16707 [details]
Patch updated with Darin's comment

Looks fine, r=me.
Comment 9 Julien Chaffraix 2007-10-24 16:51:26 PDT
Comment on attachment 16707 [details]
Patch updated with Darin's comment

Forgot to remove the review+ flag. The patch should include Xcode information and be tested on mac.
Comment 10 Julien Chaffraix 2007-11-10 06:08:39 PST
Created attachment 17172 [details]
Patch updated with XCode information and tested on Mac

Finally manage to complete the Mac part. I had to change some part of it so set the review flag to ? again. Tested on Mac & Linux (both platform).
Comment 11 Darin Adler 2007-11-10 12:15:56 PST
Comment on attachment 17172 [details]
Patch updated with XCode information and tested on Mac

r=me
Comment 12 Mark Rowe (bdash) 2007-11-12 02:36:46 PST
Landed in r27714.