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" |
30 #include "wtf/StdLibExtras.h" | 31 #include "wtf/StdLibExtras.h" |
| 32 #include <memory> |
31 | 33 |
32 namespace blink { | 34 namespace blink { |
33 | 35 |
34 ResourceResponse::ResourceResponse() | 36 ResourceResponse::ResourceResponse() |
35 : m_expectedContentLength(0) | 37 : m_expectedContentLength(0) |
36 , m_httpStatusCode(0) | 38 , m_httpStatusCode(0) |
37 , m_lastModifiedDate(0) | 39 , m_lastModifiedDate(0) |
38 , m_wasCached(false) | 40 , m_wasCached(false) |
39 , m_connectionID(0) | 41 , m_connectionID(0) |
40 , m_connectionReused(false) | 42 , m_connectionReused(false) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 m_responseTime = data->m_responseTime; | 143 m_responseTime = data->m_responseTime; |
142 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress); | 144 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress); |
143 m_remotePort = data->m_remotePort; | 145 m_remotePort = data->m_remotePort; |
144 m_downloadedFilePath = data->m_downloadedFilePath; | 146 m_downloadedFilePath = data->m_downloadedFilePath; |
145 m_downloadedFileHandle = data->m_downloadedFileHandle; | 147 m_downloadedFileHandle = data->m_downloadedFileHandle; |
146 | 148 |
147 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support | 149 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support |
148 // whatever values may be present in the opaque m_extraData structure. | 150 // whatever values may be present in the opaque m_extraData structure. |
149 } | 151 } |
150 | 152 |
151 PassOwnPtr<CrossThreadResourceResponseData> ResourceResponse::copyData() const | 153 std::unique_ptr<CrossThreadResourceResponseData> ResourceResponse::copyData() co
nst |
152 { | 154 { |
153 OwnPtr<CrossThreadResourceResponseData> data = adoptPtr(new CrossThreadResou
rceResponseData); | 155 std::unique_ptr<CrossThreadResourceResponseData> data = wrapUnique(new Cross
ThreadResourceResponseData); |
154 data->m_url = url().copy(); | 156 data->m_url = url().copy(); |
155 data->m_mimeType = mimeType().getString().isolatedCopy(); | 157 data->m_mimeType = mimeType().getString().isolatedCopy(); |
156 data->m_expectedContentLength = expectedContentLength(); | 158 data->m_expectedContentLength = expectedContentLength(); |
157 data->m_textEncodingName = textEncodingName().getString().isolatedCopy(); | 159 data->m_textEncodingName = textEncodingName().getString().isolatedCopy(); |
158 data->m_suggestedFilename = suggestedFilename().isolatedCopy(); | 160 data->m_suggestedFilename = suggestedFilename().isolatedCopy(); |
159 data->m_httpStatusCode = httpStatusCode(); | 161 data->m_httpStatusCode = httpStatusCode(); |
160 data->m_httpStatusText = httpStatusText().getString().isolatedCopy(); | 162 data->m_httpStatusText = httpStatusText().getString().isolatedCopy(); |
161 data->m_httpHeaders = httpHeaderFields().copyData(); | 163 data->m_httpHeaders = httpHeaderFields().copyData(); |
162 data->m_lastModifiedDate = lastModifiedDate(); | 164 data->m_lastModifiedDate = lastModifiedDate(); |
163 if (m_resourceLoadTiming) | 165 if (m_resourceLoadTiming) |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 m_resourceLoadInfo = loadInfo; | 537 m_resourceLoadInfo = loadInfo; |
536 } | 538 } |
537 | 539 |
538 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) | 540 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) |
539 { | 541 { |
540 m_downloadedFilePath = downloadedFilePath; | 542 m_downloadedFilePath = downloadedFilePath; |
541 if (m_downloadedFilePath.isEmpty()) { | 543 if (m_downloadedFilePath.isEmpty()) { |
542 m_downloadedFileHandle.clear(); | 544 m_downloadedFileHandle.clear(); |
543 return; | 545 return; |
544 } | 546 } |
545 OwnPtr<BlobData> blobData = BlobData::create(); | 547 std::unique_ptr<BlobData> blobData = BlobData::create(); |
546 blobData->appendFile(m_downloadedFilePath); | 548 blobData->appendFile(m_downloadedFilePath); |
547 blobData->detachFromCurrentThread(); | 549 blobData->detachFromCurrentThread(); |
548 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1); | 550 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1); |
549 } | 551 } |
550 | 552 |
551 bool ResourceResponse::compare(const ResourceResponse& a, const ResourceResponse
& b) | 553 bool ResourceResponse::compare(const ResourceResponse& a, const ResourceResponse
& b) |
552 { | 554 { |
553 if (a.isNull() != b.isNull()) | 555 if (a.isNull() != b.isNull()) |
554 return false; | 556 return false; |
555 if (a.url() != b.url()) | 557 if (a.url() != b.url()) |
(...skipping 13 matching lines...) Expand all Loading... |
569 if (a.httpHeaderFields() != b.httpHeaderFields()) | 571 if (a.httpHeaderFields() != b.httpHeaderFields()) |
570 return false; | 572 return false; |
571 if (a.resourceLoadTiming() && b.resourceLoadTiming() && *a.resourceLoadTimin
g() == *b.resourceLoadTiming()) | 573 if (a.resourceLoadTiming() && b.resourceLoadTiming() && *a.resourceLoadTimin
g() == *b.resourceLoadTiming()) |
572 return true; | 574 return true; |
573 if (a.resourceLoadTiming() != b.resourceLoadTiming()) | 575 if (a.resourceLoadTiming() != b.resourceLoadTiming()) |
574 return false; | 576 return false; |
575 return true; | 577 return true; |
576 } | 578 } |
577 | 579 |
578 } // namespace blink | 580 } // namespace blink |
OLD | NEW |