Use references instead of pointers with ResourceLoadTiming.
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 17:44:18 +0000 (17:44 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2014 17:44:18 +0000 (17:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132846

Reviewed by Alexey Proskuryakov.

Source/WebCore:
* WebCore.exp.in:
Removed ResourceResponseBase::setResourceLoadTiming linker symbol.
* inspector/InspectorResourceAgent.cpp:
(WebCore::buildObjectForResourceResponse):
* page/PerformanceResourceTiming.cpp:
(WebCore::PerformanceResourceTiming::domainLookupStart):
(WebCore::PerformanceResourceTiming::domainLookupEnd):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
(WebCore::PerformanceResourceTiming::secureConnectionStart):
(WebCore::PerformanceResourceTiming::requestStart):
Use references instead of pointers.
* page/PerformanceResourceTiming.h:
Make an instance instead of a RefPtr.
* page/PerformanceTiming.cpp:
(WebCore::PerformanceTiming::domainLookupStart):
(WebCore::PerformanceTiming::domainLookupEnd):
(WebCore::PerformanceTiming::connectStart):
(WebCore::PerformanceTiming::connectEnd):
(WebCore::PerformanceTiming::secureConnectionStart):
(WebCore::PerformanceTiming::requestStart):
(WebCore::PerformanceTiming::responseStart):
Check to see if the loader exists, then use ResourceLoadTiming reference.
(WebCore::PerformanceTiming::resourceLoadTiming): Deleted.
* page/PerformanceTiming.h:
Removed resourceLoadTiming declaration.
* platform/network/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::ResourceLoadTiming):
(WebCore::ResourceLoadTiming::operator=):
Replaced reference counting with copy constructors.
(WebCore::ResourceLoadTiming::create): Deleted.
(WebCore::ResourceLoadTiming::deepCopy): Deleted.
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::adopt):
(WebCore::ResourceResponseBase::copyData):
(WebCore::ResourceResponseBase::resourceLoadTiming):
(WebCore::ResourceResponseBase::setResourceLoadTiming):
(WebCore::ResourceResponseBase::compare):
* platform/network/ResourceResponseBase.h:
* platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
(-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]):
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::ResourceHandle::didStartRequest):
(WebCore::networkEventCallback):
Use references instead of pointers.

Source/WebKit2:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceResponse>::encode):
(IPC::ArgumentCoder<ResourceResponse>::decode):
Use references instead of pointers and null checks.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168845 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/page/PerformanceResourceTiming.cpp
Source/WebCore/page/PerformanceResourceTiming.h
Source/WebCore/page/PerformanceTiming.cpp
Source/WebCore/page/PerformanceTiming.h
Source/WebCore/platform/network/ResourceLoadTiming.h
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm
Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

index 6001c3c..874860c 100644 (file)
@@ -1,3 +1,58 @@
+2014-05-14  Alex Christensen  <achristensen@webkit.org>
+
+        Use references instead of pointers with ResourceLoadTiming.
+        https://bugs.webkit.org/show_bug.cgi?id=132846
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebCore.exp.in:
+        Removed ResourceResponseBase::setResourceLoadTiming linker symbol.
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::buildObjectForResourceResponse):
+        * page/PerformanceResourceTiming.cpp:
+        (WebCore::PerformanceResourceTiming::domainLookupStart):
+        (WebCore::PerformanceResourceTiming::domainLookupEnd):
+        (WebCore::PerformanceResourceTiming::connectStart):
+        (WebCore::PerformanceResourceTiming::connectEnd):
+        (WebCore::PerformanceResourceTiming::secureConnectionStart):
+        (WebCore::PerformanceResourceTiming::requestStart):
+        Use references instead of pointers.
+        * page/PerformanceResourceTiming.h:
+        Make an instance instead of a RefPtr.
+        * page/PerformanceTiming.cpp:
+        (WebCore::PerformanceTiming::domainLookupStart):
+        (WebCore::PerformanceTiming::domainLookupEnd):
+        (WebCore::PerformanceTiming::connectStart):
+        (WebCore::PerformanceTiming::connectEnd):
+        (WebCore::PerformanceTiming::secureConnectionStart):
+        (WebCore::PerformanceTiming::requestStart):
+        (WebCore::PerformanceTiming::responseStart):
+        Check to see if the loader exists, then use ResourceLoadTiming reference.
+        (WebCore::PerformanceTiming::resourceLoadTiming): Deleted.
+        * page/PerformanceTiming.h:
+        Removed resourceLoadTiming declaration.
+        * platform/network/ResourceLoadTiming.h:
+        (WebCore::ResourceLoadTiming::ResourceLoadTiming):
+        (WebCore::ResourceLoadTiming::operator=):
+        Replaced reference counting with copy constructors.
+        (WebCore::ResourceLoadTiming::create): Deleted.
+        (WebCore::ResourceLoadTiming::deepCopy): Deleted.
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::adopt):
+        (WebCore::ResourceResponseBase::copyData):
+        (WebCore::ResourceResponseBase::resourceLoadTiming):
+        (WebCore::ResourceResponseBase::setResourceLoadTiming):
+        (WebCore::ResourceResponseBase::compare):
+        * platform/network/ResourceResponseBase.h:
+        * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+        (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]):
+        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
+        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        (WebCore::ResourceHandle::didStartRequest):
+        (WebCore::networkEventCallback):
+        Use references instead of pointers.
+
 2014-05-14  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r168837.
index 41a10e2..0888cf3 100644 (file)
@@ -3366,6 +3366,5 @@ __ZN7WebCore4Page11setViewModeENS0_8ViewModeE
 #endif
 
 #if ENABLE(WEB_TIMING)
-__ZN7WebCore20ResourceResponseBase21setResourceLoadTimingEN3WTF10PassRefPtrINS_18ResourceLoadTimingEEE
 __ZNK7WebCore20ResourceResponseBase18resourceLoadTimingEv
 #endif
index 1432b46..046ff05 100644 (file)
@@ -243,8 +243,7 @@ static PassRefPtr<Inspector::TypeBuilder::Network::Response> buildObjectForResou
         .setConnectionId(response.connectionID());
 
     responseObject->setFromDiskCache(response.wasCached());
-    if (response.resourceLoadTiming())
-        responseObject->setTiming(buildObjectForTiming(*response.resourceLoadTiming(), loader));
+    responseObject->setTiming(buildObjectForTiming(response.resourceLoadTiming(), loader));
 
     return responseObject;
 }
index 8600a0a..b3784e6 100644 (file)
@@ -120,10 +120,10 @@ double PerformanceResourceTiming::domainLookupStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    if (!m_timing || m_timing->domainLookupStart < 0)
+    if (m_timing.domainLookupStart < 0)
         return fetchStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing->domainLookupStart);
+    return resourceTimeToDocumentMilliseconds(m_timing.domainLookupStart);
 }
 
 double PerformanceResourceTiming::domainLookupEnd() const
@@ -131,10 +131,10 @@ double PerformanceResourceTiming::domainLookupEnd() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    if (!m_timing || m_timing->domainLookupEnd < 0)
+    if (m_timing.domainLookupEnd < 0)
         return domainLookupStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing->domainLookupEnd);
+    return resourceTimeToDocumentMilliseconds(m_timing.domainLookupEnd);
 }
 
 double PerformanceResourceTiming::connectStart() const
@@ -143,13 +143,13 @@ double PerformanceResourceTiming::connectStart() const
         return 0.0;
 
     // connectStart will be -1 when a network request is not made.
-    if (!m_timing || m_timing->connectStart < 0 || m_didReuseConnection)
+    if (m_timing.connectStart < 0 || m_didReuseConnection)
         return domainLookupEnd();
 
     // connectStart includes any DNS time, so we may need to trim that off.
-    int connectStart = m_timing->connectStart;
-    if (m_timing->domainLookupEnd >= 0)
-        connectStart = m_timing->domainLookupEnd;
+    int connectStart = m_timing.connectStart;
+    if (m_timing.domainLookupEnd >= 0)
+        connectStart = m_timing.domainLookupEnd;
 
     return resourceTimeToDocumentMilliseconds(connectStart);
 }
@@ -160,10 +160,10 @@ double PerformanceResourceTiming::connectEnd() const
         return 0.0;
 
     // connectStart will be -1 when a network request is not made.
-    if (!m_timing || m_timing->connectEnd < 0 || m_didReuseConnection)
+    if (m_timing.connectEnd < 0 || m_didReuseConnection)
         return connectStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing->connectEnd);
+    return resourceTimeToDocumentMilliseconds(m_timing.connectEnd);
 }
 
 double PerformanceResourceTiming::secureConnectionStart() const
@@ -171,10 +171,10 @@ double PerformanceResourceTiming::secureConnectionStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    if (!m_timing || m_timing->secureConnectionStart < 0) // Secure connection not negotiated.
+    if (m_timing.secureConnectionStart < 0) // Secure connection not negotiated.
         return 0.0;
 
-    return resourceTimeToDocumentMilliseconds(m_timing->secureConnectionStart);
+    return resourceTimeToDocumentMilliseconds(m_timing.secureConnectionStart);
 }
 
 double PerformanceResourceTiming::requestStart() const
@@ -182,10 +182,7 @@ double PerformanceResourceTiming::requestStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    if (!m_timing)
-        return connectEnd();
-
-    return resourceTimeToDocumentMilliseconds(m_timing->requestStart);
+    return resourceTimeToDocumentMilliseconds(m_timing.requestStart);
 }
 
 double PerformanceResourceTiming::responseEnd() const
index a9ab2bb..a92cf79 100644 (file)
@@ -35,6 +35,7 @@
 #if ENABLE(RESOURCE_TIMING)
 
 #include "PerformanceEntry.h"
+#include "ResourceLoadTiming.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
@@ -76,7 +77,7 @@ private:
     double resourceTimeToDocumentMilliseconds(int deltaMilliseconds) const;
 
     AtomicString m_initiatorType;
-    RefPtr<ResourceLoadTiming> m_timing;
+    ResourceLoadTiming m_timing;
     double m_finishTime;
     bool m_didReuseConnection;
     bool m_shouldReportDetails;
index 2e480cd..bd7540a 100644 (file)
@@ -124,32 +124,34 @@ unsigned long long PerformanceTiming::fetchStart() const
 
 unsigned long long PerformanceTiming::domainLookupStart() const
 {
-    ResourceLoadTiming* timing = resourceLoadTiming();
-    if (!timing)
+    DocumentLoader* loader = documentLoader();
+    if (!loader)
         return fetchStart();
-
+    
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
     // This will be -1 when a DNS request is not performed.
     // Rather than exposing a special value that indicates no DNS, we "backfill" with fetchStart.
-    int domainLookupStart = timing->domainLookupStart;
-    if (domainLookupStart < 0)
+    if (timing.domainLookupStart < 0)
         return fetchStart();
 
-    return resourceLoadTimeRelativeToAbsolute(domainLookupStart);
+    return resourceLoadTimeRelativeToAbsolute(timing.domainLookupStart);
 }
 
 unsigned long long PerformanceTiming::domainLookupEnd() const
 {
-    ResourceLoadTiming* timing = resourceLoadTiming();
-    if (!timing)
+    DocumentLoader* loader = documentLoader();
+    if (!loader)
         return domainLookupStart();
-
+    
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
     // This will be -1 when a DNS request is not performed.
     // Rather than exposing a special value that indicates no DNS, we "backfill" with domainLookupStart.
-    int domainLookupEnd = timing->domainLookupEnd;
-    if (domainLookupEnd < 0)
+    if (timing.domainLookupEnd < 0)
         return domainLookupStart();
 
-    return resourceLoadTimeRelativeToAbsolute(domainLookupEnd);
+    return resourceLoadTimeRelativeToAbsolute(timing.domainLookupEnd);
 }
 
 unsigned long long PerformanceTiming::connectStart() const
@@ -158,20 +160,18 @@ unsigned long long PerformanceTiming::connectStart() const
     if (!loader)
         return domainLookupEnd();
 
-    ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
-    if (!timing)
-        return domainLookupEnd();
-
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
     // connectStart will be -1 when a network request is not made.
     // Rather than exposing a special value that indicates no new connection, we "backfill" with domainLookupEnd.
-    int connectStart = timing->connectStart;
+    int connectStart = timing.connectStart;
     if (connectStart < 0 || loader->response().connectionReused())
         return domainLookupEnd();
 
     // ResourceLoadTiming's connect phase includes DNS, however Navigation Timing's
     // connect phase should not. So if there is DNS time, trim it from the start.
-    if (timing->domainLookupEnd >= 0 && timing->domainLookupEnd > connectStart)
-        connectStart = timing->domainLookupEnd;
+    if (timing.domainLookupEnd >= 0 && timing.domainLookupEnd > connectStart)
+        connectStart = timing.domainLookupEnd;
 
     return resourceLoadTimeRelativeToAbsolute(connectStart);
 }
@@ -182,17 +182,14 @@ unsigned long long PerformanceTiming::connectEnd() const
     if (!loader)
         return connectStart();
 
-    ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
-    if (!timing)
-        return connectStart();
-
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
     // connectEnd will be -1 when a network request is not made.
     // Rather than exposing a special value that indicates no new connection, we "backfill" with connectStart.
-    int connectEnd = timing->connectEnd;
-    if (connectEnd < 0 || loader->response().connectionReused())
+    if (timing.connectEnd < 0 || loader->response().connectionReused())
         return connectStart();
 
-    return resourceLoadTimeRelativeToAbsolute(connectEnd);
+    return resourceLoadTimeRelativeToAbsolute(timing.connectEnd);
 }
 
 unsigned long long PerformanceTiming::secureConnectionStart() const
@@ -201,35 +198,36 @@ unsigned long long PerformanceTiming::secureConnectionStart() const
     if (!loader)
         return 0;
 
-    ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
-    if (!timing)
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
+    if (timing.secureConnectionStart < 0)
         return 0;
 
-    int secureConnectionStart = timing->secureConnectionStart;
-    if (secureConnectionStart < 0)
-        return 0;
-
-    return resourceLoadTimeRelativeToAbsolute(secureConnectionStart);
+    return resourceLoadTimeRelativeToAbsolute(timing.secureConnectionStart);
 }
 
 unsigned long long PerformanceTiming::requestStart() const
 {
-    ResourceLoadTiming* timing = resourceLoadTiming();
-    if (!timing)
+    DocumentLoader* loader = documentLoader();
+    if (!loader)
         return connectEnd();
-
-    ASSERT(timing->requestStart >= 0);
-    return resourceLoadTimeRelativeToAbsolute(timing->requestStart);
+    
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
+    ASSERT(timing.requestStart >= 0);
+    return resourceLoadTimeRelativeToAbsolute(timing.requestStart);
 }
 
 unsigned long long PerformanceTiming::responseStart() const
 {
-    ResourceLoadTiming* timing = resourceLoadTiming();
-    if (!timing)
+    DocumentLoader* loader = documentLoader();
+    if (!loader)
         return requestStart();
 
-    ASSERT(timing->responseStart >= 0);
-    return resourceLoadTimeRelativeToAbsolute(timing->responseStart);
+    const ResourceLoadTiming& timing = loader->response().resourceLoadTiming();
+    
+    ASSERT(timing.responseStart >= 0);
+    return resourceLoadTimeRelativeToAbsolute(timing.responseStart);
 }
 
 unsigned long long PerformanceTiming::responseEnd() const
@@ -333,15 +331,6 @@ DocumentLoadTiming* PerformanceTiming::documentLoadTiming() const
     return loader->timing();
 }
 
-ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const
-{
-    DocumentLoader* loader = documentLoader();
-    if (!loader)
-        return 0;
-
-    return loader->response().resourceLoadTiming();
-}
-
 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int relativeMilliseconds) const
 {
     ASSERT(relativeMilliseconds >= 0);
index 30b80b9..b614f13 100644 (file)
@@ -77,7 +77,6 @@ private:
     const DocumentTiming* documentTiming() const;
     DocumentLoader* documentLoader() const;
     DocumentLoadTiming* documentLoadTiming() const;
-    ResourceLoadTiming* resourceLoadTiming() const;
     unsigned long long resourceLoadTimeRelativeToAbsolute(int) const;
     unsigned long long monotonicTimeToIntegerMilliseconds(double) const;
 };
index 01e9f50..0322252 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ * Copyright (C) 2014 Apple, Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifndef ResourceLoadTiming_h
 #define ResourceLoadTiming_h
 
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
 namespace WebCore {
-
-class DocumentLoadTiming;
-
-class ResourceLoadTiming : public RefCounted<ResourceLoadTiming> {
+    
+class ResourceLoadTiming {
 public:
-    static PassRefPtr<ResourceLoadTiming> create()
+    ResourceLoadTiming()
+        : domainLookupStart(-1)
+        , domainLookupEnd(-1)
+        , connectStart(-1)
+        , connectEnd(-1)
+        , requestStart(0)
+        , responseStart(0)
+        , secureConnectionStart(-1)
     {
-        return adoptRef(new ResourceLoadTiming);
     }
-
-    PassRefPtr<ResourceLoadTiming> deepCopy()
+    
+    ResourceLoadTiming(const ResourceLoadTiming& other)
+        : domainLookupStart(other.domainLookupStart)
+        , domainLookupEnd(other.domainLookupEnd)
+        , connectStart(other.connectStart)
+        , connectEnd(other.connectEnd)
+        , requestStart(other.requestStart)
+        , responseStart(other.responseStart)
+        , secureConnectionStart(other.secureConnectionStart)
     {
-        RefPtr<ResourceLoadTiming> timing = create();
-        timing->domainLookupStart = domainLookupStart;
-        timing->domainLookupEnd = domainLookupEnd;
-        timing->connectStart = connectStart;
-        timing->connectEnd = connectEnd;
-        timing->requestStart = requestStart;
-        timing->responseStart = responseStart;
-        timing->secureConnectionStart = secureConnectionStart;
-        return timing.release();
     }
-
+    
+    ResourceLoadTiming& 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;
+        return *this;
+    }
+    
     bool operator==(const ResourceLoadTiming& other) const
     {
         return domainLookupStart == other.domainLookupStart
@@ -78,18 +89,6 @@ public:
     int requestStart;
     int responseStart;
     int secureConnectionStart;
-    
-private:
-    ResourceLoadTiming()
-        : domainLookupStart(-1)
-        , domainLookupEnd(-1)
-        , connectStart(-1)
-        , connectEnd(-1)
-        , requestStart(0)
-        , responseStart(0)
-        , secureConnectionStart(-1)
-    {
-    }
 };
 
 }
index 76fcbed..36ffc01 100644 (file)
@@ -106,7 +106,7 @@ PassOwnPtr<ResourceResponse> ResourceResponseBase::adopt(PassOwnPtr<CrossThreadR
 
     response->lazyInit(CommonAndUncommonFields);
     response->m_httpHeaderFields.adopt(data->m_httpHeaders.release());
-    response->setResourceLoadTiming(data->m_resourceLoadTiming.release());
+    response->setResourceLoadTiming(data->m_resourceLoadTiming);
     response->doPlatformAdopt(data);
     return response.release();
 }
@@ -122,8 +122,7 @@ PassOwnPtr<CrossThreadResourceResponseData> ResourceResponseBase::copyData() con
     data->m_httpStatusCode = httpStatusCode();
     data->m_httpStatusText = httpStatusText().isolatedCopy();
     data->m_httpHeaders = httpHeaderFields().copyData();
-    if (m_resourceLoadTiming)
-        data->m_resourceLoadTiming = m_resourceLoadTiming->deepCopy();
+    data->m_resourceLoadTiming = m_resourceLoadTiming;
     return asResourceResponse().doPlatformCopyData(data.release());
 }
 
@@ -551,14 +550,14 @@ void ResourceResponseBase::setConnectionID(unsigned connectionID)
     m_connectionID = connectionID;
 }
 
-ResourceLoadTiming* ResourceResponseBase::resourceLoadTiming() const
+ResourceLoadTiming& ResourceResponseBase::resourceLoadTiming() const
 {
     lazyInit(CommonAndUncommonFields);
 
-    return m_resourceLoadTiming.get();
+    return m_resourceLoadTiming;
 }
 
-void ResourceResponseBase::setResourceLoadTiming(PassRefPtr<ResourceLoadTiming> resourceLoadTiming)
+void ResourceResponseBase::setResourceLoadTiming(const ResourceLoadTiming& resourceLoadTiming)
 {
     lazyInit(CommonAndUncommonFields);
 
@@ -590,8 +589,6 @@ bool ResourceResponseBase::compare(const ResourceResponse& a, const ResourceResp
         return false;
     if (a.httpHeaderFields() != b.httpHeaderFields())
         return false;
-    if (a.resourceLoadTiming() && b.resourceLoadTiming() && *a.resourceLoadTiming() == *b.resourceLoadTiming())
-        return ResourceResponse::platformCompare(a, b);
     if (a.resourceLoadTiming() != b.resourceLoadTiming())
         return false;
     return ResourceResponse::platformCompare(a, b);
index eece650..c1f3e43 100644 (file)
@@ -109,8 +109,8 @@ public:
     bool wasCached() const;
     void setWasCached(bool);
 
-    ResourceLoadTiming* resourceLoadTiming() const;
-    void setResourceLoadTiming(PassRefPtr<ResourceLoadTiming>);
+    ResourceLoadTiming& resourceLoadTiming() const;
+    void setResourceLoadTiming(const ResourceLoadTiming&);
 
     // The ResourceResponse subclass may "shadow" this method to provide platform-specific memory usage information
     unsigned memoryUsage() const
@@ -147,7 +147,7 @@ protected:
     String m_suggestedFilename;
     AtomicString m_httpStatusText;
     HTTPHeaderMap m_httpHeaderFields;
-    RefPtr<ResourceLoadTiming> m_resourceLoadTiming;
+    mutable ResourceLoadTiming m_resourceLoadTiming;
 
     int m_httpStatusCode;
     unsigned m_connectionID;
@@ -196,7 +196,7 @@ public:
     int m_httpStatusCode;
     String m_httpStatusText;
     OwnPtr<CrossThreadHTTPHeaderMapData> m_httpHeaders;
-    RefPtr<ResourceLoadTiming> m_resourceLoadTiming;
+    ResourceLoadTiming m_resourceLoadTiming;
 };
 
 } // namespace WebCore
index 09f4fdc..bb77329 100644 (file)
@@ -181,9 +181,6 @@ using namespace WebCore;
     ResourceResponse resourceResponse(r);
 #if ENABLE(WEB_TIMING)
     if (NSDictionary *timingData = [connection _timingData]) {
-        resourceResponse.setResourceLoadTiming(ResourceLoadTiming::create());
-        ResourceLoadTiming* timing = resourceResponse.resourceLoadTiming();
-        
         // This is not the navigationStart time in monotonic time, but the other times are relative to this time
         // and only the differences between times are stored.
         double referenceStart = [[timingData valueForKey:@"_kCFNTimingDataTimingDataInit"] doubleValue];
@@ -196,15 +193,14 @@ using namespace WebCore;
         double requestStart = [[timingData valueForKey:@"_kCFNTimingDataRequestStart"] doubleValue];
         double responseStart = [[timingData valueForKey:@"_kCFNTimingDataResponseStart"] doubleValue];
         
-        if (timing) {
-            timing->domainLookupStart = domainLookupStart <= 0.0 ? -1 : (domainLookupStart - referenceStart) * 1000;
-            timing->domainLookupEnd = domainLookupEnd <= 0.0 ? -1 : (domainLookupEnd - referenceStart) * 1000;
-            timing->connectStart = connectStart <= 0.0 ? -1 : (connectStart - referenceStart) * 1000;
-            timing->secureConnectionStart = secureConnectionStart <= 0.0 ? -1 : (secureConnectionStart - referenceStart) * 1000;
-            timing->connectEnd = connectEnd <= 0.0 ? -1 : (connectEnd - referenceStart) * 1000;
-            timing->requestStart = requestStart <= 0.0 ? -1 : (requestStart - referenceStart) * 1000;
-            timing->responseStart = responseStart <= 0.0 ? -1 : (responseStart - referenceStart) * 1000;
-        }
+        ResourceLoadTiming& timing = resourceResponse.resourceLoadTiming();
+        timing.domainLookupStart = domainLookupStart <= 0.0 ? -1 : (domainLookupStart - referenceStart) * 1000;
+        timing.domainLookupEnd = domainLookupEnd <= 0.0 ? -1 : (domainLookupEnd - referenceStart) * 1000;
+        timing.connectStart = connectStart <= 0.0 ? -1 : (connectStart - referenceStart) * 1000;
+        timing.secureConnectionStart = secureConnectionStart <= 0.0 ? -1 : (secureConnectionStart - referenceStart) * 1000;
+        timing.connectEnd = connectEnd <= 0.0 ? -1 : (connectEnd - referenceStart) * 1000;
+        timing.requestStart = requestStart <= 0.0 ? -1 : (requestStart - referenceStart) * 1000;
+        timing.responseStart = responseStart <= 0.0 ? -1 : (responseStart - referenceStart) * 1000;
     }
 #else
     UNUSED_PARAM(connection);
index 3518803..63150f7 100644 (file)
@@ -223,9 +223,6 @@ using namespace WebCore;
         ResourceResponse resourceResponse(r);
 #if ENABLE(WEB_TIMING)
         if (NSDictionary *timingData = [connection _timingData]) {
-            resourceResponse.setResourceLoadTiming(ResourceLoadTiming::create());
-            ResourceLoadTiming* timing = resourceResponse.resourceLoadTiming();
-            
             // This is not the navigationStart time in monotonic time, but the other times are relative to this time
             // and only the differences between times are stored.
             double referenceStart = [[timingData valueForKey:@"_kCFNTimingDataTimingDataInit"] doubleValue];
@@ -238,15 +235,14 @@ using namespace WebCore;
             double requestStart = [[timingData valueForKey:@"_kCFNTimingDataRequestStart"] doubleValue];
             double responseStart = [[timingData valueForKey:@"_kCFNTimingDataResponseStart"] doubleValue];
             
-            if (timing) {
-                timing->domainLookupStart = domainLookupStart <= 0.0 ? -1 : (domainLookupStart - referenceStart) * 1000;
-                timing->domainLookupEnd = domainLookupEnd <= 0.0 ? -1 : (domainLookupEnd - referenceStart) * 1000;
-                timing->connectStart = connectStart <= 0.0 ? -1 : (connectStart - referenceStart) * 1000;
-                timing->secureConnectionStart = secureConnectionStart <= 0.0 ? -1 : (secureConnectionStart - referenceStart) * 1000;
-                timing->connectEnd = connectEnd <= 0.0 ? -1 : (connectEnd - referenceStart) * 1000;
-                timing->requestStart = requestStart <= 0.0 ? -1 : (requestStart - referenceStart) * 1000;
-                timing->responseStart = responseStart <= 0.0 ? -1 : (responseStart - referenceStart) * 1000;
-            }
+            ResourceLoadTiming& timing = resourceResponse.resourceLoadTiming();
+            timing.domainLookupStart = domainLookupStart <= 0.0 ? -1 : (domainLookupStart - referenceStart) * 1000;
+            timing.domainLookupEnd = domainLookupEnd <= 0.0 ? -1 : (domainLookupEnd - referenceStart) * 1000;
+            timing.connectStart = connectStart <= 0.0 ? -1 : (connectStart - referenceStart) * 1000;
+            timing.secureConnectionStart = secureConnectionStart <= 0.0 ? -1 : (secureConnectionStart - referenceStart) * 1000;
+            timing.connectEnd = connectEnd <= 0.0 ? -1 : (connectEnd - referenceStart) * 1000;
+            timing.requestStart = requestStart <= 0.0 ? -1 : (requestStart - referenceStart) * 1000;
+            timing.responseStart = responseStart <= 0.0 ? -1 : (responseStart - referenceStart) * 1000;
         }
 #else
         UNUSED_PARAM(connection);
index be695cc..1f9cb6c 100644 (file)
@@ -382,9 +382,6 @@ static void restartedCallback(SoupMessage*, gpointer data)
     if (!handle || handle->cancelledOrClientless())
         return;
 
-    ResourceHandleInternal* d = handle->getInternal();
-    ResourceResponse& redirectResponse = d->m_response;
-    redirectResponse.setResourceLoadTiming(ResourceLoadTiming::create());
     handle->m_requestTime = monotonicallyIncreasingTime();
 }
 #endif
@@ -835,11 +832,7 @@ static int milisecondsSinceRequest(double requestTime)
 
 void ResourceHandle::didStartRequest()
 {
-    ResourceHandleInternal* d = getInternal();
-    if (!d->m_response.resourceLoadTiming())
-        return;
-
-    d->m_response.resourceLoadTiming()->requestStart = milisecondsSinceRequest(m_requestTime);
+    getInternal()->m_response.resourceLoadTiming().requestStart = milisecondsSinceRequest(m_requestTime);
 }
 
 static void networkEventCallback(SoupMessage*, GSocketClientEvent event, GIOStream*, gpointer data)
@@ -855,21 +848,21 @@ static void networkEventCallback(SoupMessage*, GSocketClientEvent event, GIOStre
     int deltaTime = milisecondsSinceRequest(handle->m_requestTime);
     switch (event) {
     case G_SOCKET_CLIENT_RESOLVING:
-        d->m_response.resourceLoadTiming()->domainLookupStart = deltaTime;
+        d->m_response.resourceLoadTiming().domainLookupStart = deltaTime;
         break;
     case G_SOCKET_CLIENT_RESOLVED:
-        d->m_response.resourceLoadTiming()->domainLookupEnd = deltaTime;
+        d->m_response.resourceLoadTiming().domainLookupEnd = deltaTime;
         break;
     case G_SOCKET_CLIENT_CONNECTING:
-        d->m_response.resourceLoadTiming()->connectStart = deltaTime;
-        if (d->m_response.resourceLoadTiming()->domainLookupStart != -1) {
+        d->m_response.resourceLoadTiming().connectStart = deltaTime;
+        if (d->m_response.resourceLoadTiming().domainLookupStart != -1) {
             // WebCore/inspector/front-end/RequestTimingView.js assumes
             // that DNS time is included in connection time so must
             // substract here the DNS delta that will be added later (see
             // WebInspector.RequestTimingView.createTimingTable in the
             // file above for more details).
-            d->m_response.resourceLoadTiming()->connectStart -=
-                d->m_response.resourceLoadTiming()->domainLookupEnd - d->m_response.resourceLoadTiming()->domainLookupStart;
+            d->m_response.resourceLoadTiming().connectStart -=
+                d->m_response.resourceLoadTiming().domainLookupEnd - d->m_response.resourceLoadTiming().domainLookupStart;
         }
         break;
     case G_SOCKET_CLIENT_CONNECTED:
@@ -881,12 +874,12 @@ static void networkEventCallback(SoupMessage*, GSocketClientEvent event, GIOStre
     case G_SOCKET_CLIENT_PROXY_NEGOTIATED:
         break;
     case G_SOCKET_CLIENT_TLS_HANDSHAKING:
-        d->m_response.resourceLoadTiming()->secureConnectionStart = deltaTime;
+        d->m_response.resourceLoadTiming().secureConnectionStart = deltaTime;
         break;
     case G_SOCKET_CLIENT_TLS_HANDSHAKED:
         break;
     case G_SOCKET_CLIENT_COMPLETE:
-        d->m_response.resourceLoadTiming()->connectEnd = deltaTime;
+        d->m_response.resourceLoadTiming().connectEnd = deltaTime;
         break;
     default:
         ASSERT_NOT_REACHED();
@@ -942,7 +935,6 @@ static bool createSoupMessageForHandleAndRequest(ResourceHandle* handle, const R
     soup_message_set_flags(d->m_soupMessage.get(), static_cast<SoupMessageFlags>(soup_message_get_flags(d->m_soupMessage.get()) | SOUP_MESSAGE_NO_REDIRECT));
 
 #if ENABLE(WEB_TIMING)
-    d->m_response.setResourceLoadTiming(ResourceLoadTiming::create());
     g_signal_connect(d->m_soupMessage.get(), "network-event", G_CALLBACK(networkEventCallback), handle);
     g_signal_connect(d->m_soupMessage.get(), "restarted", G_CALLBACK(restartedCallback), handle);
 #endif
@@ -1017,8 +1009,7 @@ bool ResourceHandle::start()
 void ResourceHandle::sendPendingRequest()
 {
 #if ENABLE(WEB_TIMING)
-    if (d->m_response.resourceLoadTiming())
-        m_requestTime = monotonicallyIncreasingTime();
+    m_requestTime = monotonicallyIncreasingTime();
 #endif
 
     if (d->m_firstRequest.timeoutInterval() > 0) {
index 547fd1f..ce7a241 100644 (file)
@@ -1,3 +1,15 @@
+2014-05-14  Alex Christensen  <achristensen@webkit.org>
+
+        Use references instead of pointers with ResourceLoadTiming.
+        https://bugs.webkit.org/show_bug.cgi?id=132846
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ResourceResponse>::encode):
+        (IPC::ArgumentCoder<ResourceResponse>::decode):
+        Use references instead of pointers and null checks.
+
 2014-05-14  Tibor Meszaros  <tmeszaros.u-szeged@partner.samsung.com>
 
         Remove CSS_STICKY_POSITION guards
index 1609637..fcbda9d 100644 (file)
@@ -690,18 +690,14 @@ void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const Res
     }
     
 #if ENABLE(WEB_TIMING)
-    ResourceLoadTiming* timing = resourceResponse.resourceLoadTiming();
-    bool hasResourceLoadTiming = timing;
-    encoder << hasResourceLoadTiming;
-    if (hasResourceLoadTiming) {
-        encoder << timing->domainLookupStart;
-        encoder << timing->domainLookupEnd;
-        encoder << timing->connectStart;
-        encoder << timing->connectEnd;
-        encoder << timing->requestStart;
-        encoder << timing->responseStart;
-        encoder << timing->secureConnectionStart;
-    }
+    const ResourceLoadTiming& timing = resourceResponse.resourceLoadTiming();
+    encoder << timing.domainLookupStart;
+    encoder << timing.domainLookupEnd;
+    encoder << timing.connectStart;
+    encoder << timing.connectEnd;
+    encoder << timing.requestStart;
+    encoder << timing.responseStart;
+    encoder << timing.secureConnectionStart;
 #endif
 }
 
@@ -772,21 +768,15 @@ bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceR
     }
     
 #if ENABLE(WEB_TIMING)
-    bool hasResourceLoadTiming;
-    if (!decoder.decode(hasResourceLoadTiming))
-        return false;
-    if (hasResourceLoadTiming) {
-        response.setResourceLoadTiming(ResourceLoadTiming::create());
-        ResourceLoadTiming* timing = response.resourceLoadTiming();
-        if (!decoder.decode(timing->domainLookupStart)
-            || !decoder.decode(timing->domainLookupEnd)
-            || !decoder.decode(timing->connectStart)
-            || !decoder.decode(timing->connectEnd)
-            || !decoder.decode(timing->requestStart)
-            || !decoder.decode(timing->responseStart)
-            || !decoder.decode(timing->secureConnectionStart))
-            return false;
-    }
+    ResourceLoadTiming& timing = response.resourceLoadTiming();
+    if (!decoder.decode(timing.domainLookupStart)
+        || !decoder.decode(timing.domainLookupEnd)
+        || !decoder.decode(timing.connectStart)
+        || !decoder.decode(timing.connectEnd)
+        || !decoder.decode(timing.requestStart)
+        || !decoder.decode(timing.responseStart)
+        || !decoder.decode(timing.secureConnectionStart))
+        return false;
 #endif
 
     resourceResponse = response;