| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "platform/network/ResourceResponse.h" | 27 #include "platform/network/ResourceResponse.h" |
| 28 | 28 |
| 29 #include "wtf/CurrentTime.h" | 29 #include "wtf/CurrentTime.h" |
| 30 #include "wtf/PtrUtil.h" | |
| 31 #include "wtf/StdLibExtras.h" | 30 #include "wtf/StdLibExtras.h" |
| 32 #include <memory> | |
| 33 | 31 |
| 34 namespace blink { | 32 namespace blink { |
| 35 | 33 |
| 36 ResourceResponse::ResourceResponse() | 34 ResourceResponse::ResourceResponse() |
| 37 : m_expectedContentLength(0) | 35 : m_expectedContentLength(0) |
| 38 , m_httpStatusCode(0) | 36 , m_httpStatusCode(0) |
| 39 , m_lastModifiedDate(0) | 37 , m_lastModifiedDate(0) |
| 40 , m_wasCached(false) | 38 , m_wasCached(false) |
| 41 , m_connectionID(0) | 39 , m_connectionID(0) |
| 42 , m_connectionReused(false) | 40 , m_connectionReused(false) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 m_responseTime = data->m_responseTime; | 141 m_responseTime = data->m_responseTime; |
| 144 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress); | 142 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress); |
| 145 m_remotePort = data->m_remotePort; | 143 m_remotePort = data->m_remotePort; |
| 146 m_downloadedFilePath = data->m_downloadedFilePath; | 144 m_downloadedFilePath = data->m_downloadedFilePath; |
| 147 m_downloadedFileHandle = data->m_downloadedFileHandle; | 145 m_downloadedFileHandle = data->m_downloadedFileHandle; |
| 148 | 146 |
| 149 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support | 147 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support |
| 150 // whatever values may be present in the opaque m_extraData structure. | 148 // whatever values may be present in the opaque m_extraData structure. |
| 151 } | 149 } |
| 152 | 150 |
| 153 std::unique_ptr<CrossThreadResourceResponseData> ResourceResponse::copyData() co
nst | 151 PassOwnPtr<CrossThreadResourceResponseData> ResourceResponse::copyData() const |
| 154 { | 152 { |
| 155 std::unique_ptr<CrossThreadResourceResponseData> data = wrapUnique(new Cross
ThreadResourceResponseData); | 153 OwnPtr<CrossThreadResourceResponseData> data = adoptPtr(new CrossThreadResou
rceResponseData); |
| 156 data->m_url = url().copy(); | 154 data->m_url = url().copy(); |
| 157 data->m_mimeType = mimeType().getString().isolatedCopy(); | 155 data->m_mimeType = mimeType().getString().isolatedCopy(); |
| 158 data->m_expectedContentLength = expectedContentLength(); | 156 data->m_expectedContentLength = expectedContentLength(); |
| 159 data->m_textEncodingName = textEncodingName().getString().isolatedCopy(); | 157 data->m_textEncodingName = textEncodingName().getString().isolatedCopy(); |
| 160 data->m_suggestedFilename = suggestedFilename().isolatedCopy(); | 158 data->m_suggestedFilename = suggestedFilename().isolatedCopy(); |
| 161 data->m_httpStatusCode = httpStatusCode(); | 159 data->m_httpStatusCode = httpStatusCode(); |
| 162 data->m_httpStatusText = httpStatusText().getString().isolatedCopy(); | 160 data->m_httpStatusText = httpStatusText().getString().isolatedCopy(); |
| 163 data->m_httpHeaders = httpHeaderFields().copyData(); | 161 data->m_httpHeaders = httpHeaderFields().copyData(); |
| 164 data->m_lastModifiedDate = lastModifiedDate(); | 162 data->m_lastModifiedDate = lastModifiedDate(); |
| 165 if (m_resourceLoadTiming) | 163 if (m_resourceLoadTiming) |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 m_resourceLoadInfo = loadInfo; | 535 m_resourceLoadInfo = loadInfo; |
| 538 } | 536 } |
| 539 | 537 |
| 540 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) | 538 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) |
| 541 { | 539 { |
| 542 m_downloadedFilePath = downloadedFilePath; | 540 m_downloadedFilePath = downloadedFilePath; |
| 543 if (m_downloadedFilePath.isEmpty()) { | 541 if (m_downloadedFilePath.isEmpty()) { |
| 544 m_downloadedFileHandle.clear(); | 542 m_downloadedFileHandle.clear(); |
| 545 return; | 543 return; |
| 546 } | 544 } |
| 547 std::unique_ptr<BlobData> blobData = BlobData::create(); | 545 OwnPtr<BlobData> blobData = BlobData::create(); |
| 548 blobData->appendFile(m_downloadedFilePath); | 546 blobData->appendFile(m_downloadedFilePath); |
| 549 blobData->detachFromCurrentThread(); | 547 blobData->detachFromCurrentThread(); |
| 550 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1); | 548 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1); |
| 551 } | 549 } |
| 552 | 550 |
| 553 bool ResourceResponse::compare(const ResourceResponse& a, const ResourceResponse
& b) | 551 bool ResourceResponse::compare(const ResourceResponse& a, const ResourceResponse
& b) |
| 554 { | 552 { |
| 555 if (a.isNull() != b.isNull()) | 553 if (a.isNull() != b.isNull()) |
| 556 return false; | 554 return false; |
| 557 if (a.url() != b.url()) | 555 if (a.url() != b.url()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 571 if (a.httpHeaderFields() != b.httpHeaderFields()) | 569 if (a.httpHeaderFields() != b.httpHeaderFields()) |
| 572 return false; | 570 return false; |
| 573 if (a.resourceLoadTiming() && b.resourceLoadTiming() && *a.resourceLoadTimin
g() == *b.resourceLoadTiming()) | 571 if (a.resourceLoadTiming() && b.resourceLoadTiming() && *a.resourceLoadTimin
g() == *b.resourceLoadTiming()) |
| 574 return true; | 572 return true; |
| 575 if (a.resourceLoadTiming() != b.resourceLoadTiming()) | 573 if (a.resourceLoadTiming() != b.resourceLoadTiming()) |
| 576 return false; | 574 return false; |
| 577 return true; | 575 return true; |
| 578 } | 576 } |
| 579 | 577 |
| 580 } // namespace blink | 578 } // namespace blink |
| OLD | NEW |