RESOLVED FIXED132846
ResourceLoadTiming should use reference instead of pointer
https://bugs.webkit.org/show_bug.cgi?id=132846
Summary ResourceLoadTiming should use reference instead of pointer
Alex Christensen
Reported 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.
Attachments
Patch (33.72 KB, patch)
2014-05-12 17:10 PDT, Alex Christensen
no flags
Patch (35.11 KB, patch)
2014-05-13 08:28 PDT, Alex Christensen
no flags
Patch (35.30 KB, patch)
2014-05-13 09:24 PDT, Alex Christensen
no flags
Patch (35.44 KB, patch)
2014-05-13 12:58 PDT, Alex Christensen
no flags
Patch (35.34 KB, patch)
2014-05-13 14:10 PDT, Alex Christensen
ap: review+
Alex Christensen
Comment 1 2014-05-12 17:10:51 PDT
Alex Christensen
Comment 2 2014-05-13 08:28:50 PDT
Alex Christensen
Comment 3 2014-05-13 09:24:03 PDT
Alex Christensen
Comment 4 2014-05-13 12:58:03 PDT
Alex Christensen
Comment 5 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.
Anders Carlsson
Comment 6 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?
Alex Christensen
Comment 7 2014-05-13 14:10:30 PDT
Alexey Proskuryakov
Comment 8 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.
Alexey Proskuryakov
Comment 9 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?
Alex Christensen
Comment 10 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.
Alex Christensen
Comment 11 2014-05-14 10:45:56 PDT
Note You need to log in before you can comment on or make changes to this bug.