diff options
Diffstat (limited to 'WebCore/platform/network')
-rw-r--r-- | WebCore/platform/network/ResourceLoadTiming.h | 110 | ||||
-rw-r--r-- | WebCore/platform/network/ResourceResponseBase.cpp | 21 | ||||
-rw-r--r-- | WebCore/platform/network/ResourceResponseBase.h | 7 | ||||
-rw-r--r-- | WebCore/platform/network/qt/QNetworkReplyHandler.cpp | 10 | ||||
-rw-r--r-- | WebCore/platform/network/qt/QNetworkReplyHandler.h | 1 |
5 files changed, 148 insertions, 1 deletions
diff --git a/WebCore/platform/network/ResourceLoadTiming.h b/WebCore/platform/network/ResourceLoadTiming.h new file mode 100644 index 0000000..55ff181 --- /dev/null +++ b/WebCore/platform/network/ResourceLoadTiming.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2010 Google, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * 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. + */ + +#ifndef ResourceLoadTiming_h +#define ResourceLoadTiming_h + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class ResourceLoadTiming : public RefCounted<ResourceLoadTiming> { +public: + PassRefPtr<ResourceLoadTiming> create() + { + return adoptRef(new ResourceLoadTiming); + } + + PassRefPtr<ResourceLoadTiming> deepCopy() + { + RefPtr<ResourceLoadTiming> timing = create(); + timing->redirectStart = redirectStart; + timing->redirectEnd = redirectEnd; + timing->redirectCount = redirectCount; + timing->domainLookupStart = domainLookupStart; + timing->domainLookupEnd = domainLookupEnd; + timing->connectStart = connectStart; + timing->connectEnd = connectEnd; + timing->requestStart = requestStart; + timing->requestEnd = requestEnd; + timing->responseStart = responseStart; + timing->responseEnd = responseEnd; + return timing.release(); + } + + bool operator==(const ResourceLoadTiming& other) const + { + return redirectStart == other.redirectStart + && redirectEnd == other.redirectEnd + && redirectCount == other.redirectCount + && domainLookupStart == other.domainLookupStart + && domainLookupEnd == other.domainLookupEnd + && connectStart == other.connectStart + && connectEnd == other.connectEnd + && requestStart == other.requestStart + && requestEnd == other.requestEnd + && responseStart == other.responseStart + && responseEnd == other.responseEnd; + } + + bool operator!=(const ResourceLoadTiming& other) const + { + return !(*this == other); + } + + double redirectStart; + double redirectEnd; + unsigned short redirectCount; + double domainLookupStart; + double domainLookupEnd; + double connectStart; + double connectEnd; + double requestStart; + double requestEnd; + double responseStart; + double responseEnd; + +private: + ResourceLoadTiming() + : redirectStart(0.0) + , redirectEnd(0.0) + , redirectCount(0) + , domainLookupStart(0.0) + , domainLookupEnd(0.0) + , connectStart(0.0) + , connectEnd(0.0) + , requestStart(0.0) + , requestEnd(0.0) + , responseStart(0.0) + , responseEnd(0.0) + { + } +}; + +} + +#endif diff --git a/WebCore/platform/network/ResourceResponseBase.cpp b/WebCore/platform/network/ResourceResponseBase.cpp index 3192a18..607cd7f 100644 --- a/WebCore/platform/network/ResourceResponseBase.cpp +++ b/WebCore/platform/network/ResourceResponseBase.cpp @@ -100,6 +100,7 @@ PassOwnPtr<ResourceResponse> ResourceResponseBase::adopt(PassOwnPtr<CrossThreadR response->lazyInit(); response->m_httpHeaderFields.adopt(data->m_httpHeaders.release()); response->setLastModifiedDate(data->m_lastModifiedDate); + response->setResourceLoadTiming(data->m_resourceLoadTiming.release()); return response.release(); } @@ -116,6 +117,8 @@ PassOwnPtr<CrossThreadResourceResponseData> ResourceResponseBase::copyData() con data->m_httpStatusText = httpStatusText().crossThreadString(); data->m_httpHeaders = httpHeaderFields().copyData(); data->m_lastModifiedDate = lastModifiedDate(); + if (m_resourceLoadTiming) + data->m_resourceLoadTiming = m_resourceLoadTiming->deepCopy(); return data.release(); } @@ -452,6 +455,20 @@ time_t ResourceResponseBase::lastModifiedDate() const return m_lastModifiedDate; } +ResourceLoadTiming* ResourceResponseBase::resourceLoadTiming() const +{ + lazyInit(); + + return m_resourceLoadTiming.get(); +} + +void ResourceResponseBase::setResourceLoadTiming(PassRefPtr<ResourceLoadTiming> resourceLoadTiming) +{ + lazyInit(); + + m_resourceLoadTiming = resourceLoadTiming; +} + void ResourceResponseBase::lazyInit() const { const_cast<ResourceResponse*>(static_cast<const ResourceResponse*>(this))->platformLazyInit(); @@ -477,6 +494,10 @@ 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); } diff --git a/WebCore/platform/network/ResourceResponseBase.h b/WebCore/platform/network/ResourceResponseBase.h index 74e23a4..697a84c 100644 --- a/WebCore/platform/network/ResourceResponseBase.h +++ b/WebCore/platform/network/ResourceResponseBase.h @@ -29,8 +29,10 @@ #include "HTTPHeaderMap.h" #include "KURL.h" +#include "ResourceLoadTiming.h" #include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> namespace WebCore { @@ -95,6 +97,9 @@ public: double expires() const; double lastModified() const; + ResourceLoadTiming* resourceLoadTiming() const; + void setResourceLoadTiming(PassRefPtr<ResourceLoadTiming>); + // The ResourceResponse subclass may "shadow" this method to provide platform-specific memory usage information unsigned memoryUsage() const { @@ -125,6 +130,7 @@ protected: String m_httpStatusText; HTTPHeaderMap m_httpHeaderFields; time_t m_lastModifiedDate; + RefPtr<ResourceLoadTiming> m_resourceLoadTiming; bool m_isNull : 1; @@ -161,6 +167,7 @@ struct CrossThreadResourceResponseData : Noncopyable { String m_httpStatusText; OwnPtr<CrossThreadHTTPHeaderMapData> m_httpHeaders; time_t m_lastModifiedDate; + RefPtr<ResourceLoadTiming> m_resourceLoadTiming; }; } // namespace WebCore diff --git a/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index e52dd1d..1ae24ff 100644 --- a/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -60,6 +60,9 @@ FormDataIODevice::FormDataIODevice(FormData* data) , m_currentDelta(0) { setOpenMode(FormDataIODevice::ReadOnly); + + if (!m_formElements.isEmpty() && m_formElements[0].m_type == FormDataElement::encodedFile) + openFileForCurrentElement(); } FormDataIODevice::~FormDataIODevice() @@ -78,6 +81,11 @@ void FormDataIODevice::moveToNextElement() if (m_formElements.isEmpty() || m_formElements[0].m_type == FormDataElement::data) return; + openFileForCurrentElement(); +} + +void FormDataIODevice::openFileForCurrentElement() +{ if (!m_currentFile) m_currentFile = new QFile; @@ -353,7 +361,7 @@ void QNetworkReplyHandler::sendResponseIfNeeded() ResourceRequest newRequest = m_resourceHandle->request(); newRequest.setURL(newUrl); - if (((statusCode >= 301 && statusCode <= 303) || statusCode == 307) && m_method == QNetworkAccessManager::PostOperation) { + if (((statusCode >= 301 && statusCode <= 303) || statusCode == 307) && newRequest.httpMethod() == "POST") { m_method = QNetworkAccessManager::GetOperation; newRequest.setHTTPMethod("GET"); } diff --git a/WebCore/platform/network/qt/QNetworkReplyHandler.h b/WebCore/platform/network/qt/QNetworkReplyHandler.h index 9f8217d..f6b2358 100644 --- a/WebCore/platform/network/qt/QNetworkReplyHandler.h +++ b/WebCore/platform/network/qt/QNetworkReplyHandler.h @@ -104,6 +104,7 @@ protected: private: void moveToNextElement(); + void openFileForCurrentElement(); private: Vector<FormDataElement> m_formElements; |