Bug 132846 - ResourceLoadTiming should use reference instead of pointer
Summary: ResourceLoadTiming should use reference instead of pointer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-12 16:57 PDT by Alex Christensen
Modified: 2014-05-14 10:45 PDT (History)
8 users (show)

See Also:


Attachments
Patch (33.72 KB, patch)
2014-05-12 17:10 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (35.11 KB, patch)
2014-05-13 08:28 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (35.30 KB, patch)
2014-05-13 09:24 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (35.44 KB, patch)
2014-05-13 12:58 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (35.34 KB, patch)
2014-05-13 14:10 PDT, Alex Christensen
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2014-05-12 16:57:57 PDT
As promised in https://bugs.webkit.org/show_bug.cgi?id=132574 I'm using references for ResourceLoadTiming, which is instanced in PerformanceResourceTiming and ResourceResponseBase.  This avoids unnecessary null checks and reference counting, and it makes the code nicer to read.
Comment 1 Alex Christensen 2014-05-12 17:10:51 PDT
Created attachment 231348 [details]
Patch
Comment 2 Alex Christensen 2014-05-13 08:28:50 PDT
Created attachment 231382 [details]
Patch
Comment 3 Alex Christensen 2014-05-13 09:24:03 PDT
Created attachment 231386 [details]
Patch
Comment 4 Alex Christensen 2014-05-13 12:58:03 PDT
Created attachment 231403 [details]
Patch
Comment 5 Alex Christensen 2014-05-13 13:47:13 PDT
The fourth patch tried to get rid of my use of mutable in ResourceResponseBase.h, but it doesn't work nicely with the way Soup uses ResourceLoadTiming.  I think the third patch is the way to go.  It uses mutable, but there are lots of mutable things in ResourceResponseBase.
Comment 6 Anders Carlsson 2014-05-13 13:58:07 PDT
Comment on attachment 231386 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231386&action=review

Is there a reason why you can't just have an std::unique_ptr reference to the ResourceLoadTiming object? Maybe it doesn't matter.
r- because of the assignment operator.

> Source/WebCore/platform/network/ResourceLoadTiming.h:65
> +    void operator=(const ResourceLoadTiming& other)
> +    {
> +        domainLookupStart = other.domainLookupStart;
> +        domainLookupEnd = other.domainLookupEnd;
> +        connectStart = other.connectStart;
> +        connectEnd = other.connectEnd;
> +        requestStart = other.requestStart;
> +        responseStart = other.responseStart;
> +        secureConnectionStart = other.secureConnectionStart;
> +    }

This is not a correct assignment operator, it needs to return *this.

> Source/WebCore/platform/network/ResourceResponseBase.cpp:555
>      lazyInit(CommonAndUncommonFields);

Do we need to call this now?
Comment 7 Alex Christensen 2014-05-13 14:10:30 PDT
Created attachment 231406 [details]
Patch
Comment 8 Alexey Proskuryakov 2014-05-14 10:04:10 PDT
> Is there a reason why you can't just have an std::unique_ptr reference to the ResourceLoadTiming object? 

It seems nice to avoid a separate allocation, given that nearly(?) all of the responses will have the timing data.
Comment 9 Alexey Proskuryakov 2014-05-14 10:09:12 PDT
Comment on attachment 231406 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=231406&action=review

And the downside is of course that touching ResourceTiming header will make half of WebCore rebuild, because half of WebCore indirectly includes ResourceResponse.h.

> Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm:197
> +        timing.domainLookupStart = domainLookupStart <= 0.0 ? -1 : (domainLookupStart - referenceStart) * 1000;

I don't think that we ever need to compare to 0.0, can it be simply 0?
Comment 10 Alex Christensen 2014-05-14 10:12:08 PDT
(In reply to comment #9)
> I don't think that we ever need to compare to 0.0, can it be simply 0?
I'll do this when I refactor the duplicate code.
Comment 11 Alex Christensen 2014-05-14 10:45:56 PDT
http://trac.webkit.org/changeset/168845