Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceResponse.cpp

Issue 2316573002: PlzNavigate: Support ResourceTiming API (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 m_wasFetchedViaSPDY(false), 90 m_wasFetchedViaSPDY(false),
91 m_wasNpnNegotiated(false), 91 m_wasNpnNegotiated(false),
92 m_wasAlternateProtocolAvailable(false), 92 m_wasAlternateProtocolAvailable(false),
93 m_wasFetchedViaProxy(false), 93 m_wasFetchedViaProxy(false),
94 m_wasFetchedViaServiceWorker(false), 94 m_wasFetchedViaServiceWorker(false),
95 m_wasFetchedViaForeignFetch(false), 95 m_wasFetchedViaForeignFetch(false),
96 m_wasFallbackRequiredByServiceWorker(false), 96 m_wasFallbackRequiredByServiceWorker(false),
97 m_serviceWorkerResponseType(WebServiceWorkerResponseTypeDefault), 97 m_serviceWorkerResponseType(WebServiceWorkerResponseTypeDefault),
98 m_responseTime(0), 98 m_responseTime(0),
99 m_remotePort(0), 99 m_remotePort(0),
100 m_encodedDataLength(0),
100 m_encodedBodyLength(0), 101 m_encodedBodyLength(0),
101 m_decodedBodyLength(0) {} 102 m_decodedBodyLength(0) {}
102 103
103 ResourceResponse::ResourceResponse(const KURL& url, 104 ResourceResponse::ResourceResponse(const KURL& url,
104 const AtomicString& mimeType, 105 const AtomicString& mimeType,
105 long long expectedLength, 106 long long expectedLength,
106 const AtomicString& textEncodingName, 107 const AtomicString& textEncodingName,
107 const String& filename) 108 const String& filename)
108 : m_url(url), 109 : m_url(url),
109 m_mimeType(mimeType), 110 m_mimeType(mimeType),
(...skipping 21 matching lines...) Expand all
131 m_wasFetchedViaSPDY(false), 132 m_wasFetchedViaSPDY(false),
132 m_wasNpnNegotiated(false), 133 m_wasNpnNegotiated(false),
133 m_wasAlternateProtocolAvailable(false), 134 m_wasAlternateProtocolAvailable(false),
134 m_wasFetchedViaProxy(false), 135 m_wasFetchedViaProxy(false),
135 m_wasFetchedViaServiceWorker(false), 136 m_wasFetchedViaServiceWorker(false),
136 m_wasFetchedViaForeignFetch(false), 137 m_wasFetchedViaForeignFetch(false),
137 m_wasFallbackRequiredByServiceWorker(false), 138 m_wasFallbackRequiredByServiceWorker(false),
138 m_serviceWorkerResponseType(WebServiceWorkerResponseTypeDefault), 139 m_serviceWorkerResponseType(WebServiceWorkerResponseTypeDefault),
139 m_responseTime(0), 140 m_responseTime(0),
140 m_remotePort(0), 141 m_remotePort(0),
142 m_encodedDataLength(0),
141 m_encodedBodyLength(0), 143 m_encodedBodyLength(0),
142 m_decodedBodyLength(0) {} 144 m_decodedBodyLength(0) {}
143 145
144 ResourceResponse::ResourceResponse(CrossThreadResourceResponseData* data) 146 ResourceResponse::ResourceResponse(CrossThreadResourceResponseData* data)
145 : ResourceResponse() { 147 : ResourceResponse() {
146 setURL(data->m_url); 148 setURL(data->m_url);
147 setMimeType(AtomicString(data->m_mimeType)); 149 setMimeType(AtomicString(data->m_mimeType));
148 setExpectedContentLength(data->m_expectedContentLength); 150 setExpectedContentLength(data->m_expectedContentLength);
149 setTextEncodingName(AtomicString(data->m_textEncodingName)); 151 setTextEncodingName(AtomicString(data->m_textEncodingName));
150 setSuggestedFilename(data->m_suggestedFilename); 152 setSuggestedFilename(data->m_suggestedFilename);
(...skipping 30 matching lines...) Expand all
181 m_wasFetchedViaServiceWorker = data->m_wasFetchedViaServiceWorker; 183 m_wasFetchedViaServiceWorker = data->m_wasFetchedViaServiceWorker;
182 m_wasFetchedViaForeignFetch = data->m_wasFetchedViaForeignFetch; 184 m_wasFetchedViaForeignFetch = data->m_wasFetchedViaForeignFetch;
183 m_wasFallbackRequiredByServiceWorker = 185 m_wasFallbackRequiredByServiceWorker =
184 data->m_wasFallbackRequiredByServiceWorker; 186 data->m_wasFallbackRequiredByServiceWorker;
185 m_serviceWorkerResponseType = data->m_serviceWorkerResponseType; 187 m_serviceWorkerResponseType = data->m_serviceWorkerResponseType;
186 m_originalURLViaServiceWorker = data->m_originalURLViaServiceWorker; 188 m_originalURLViaServiceWorker = data->m_originalURLViaServiceWorker;
187 m_cacheStorageCacheName = data->m_cacheStorageCacheName; 189 m_cacheStorageCacheName = data->m_cacheStorageCacheName;
188 m_responseTime = data->m_responseTime; 190 m_responseTime = data->m_responseTime;
189 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress); 191 m_remoteIPAddress = AtomicString(data->m_remoteIPAddress);
190 m_remotePort = data->m_remotePort; 192 m_remotePort = data->m_remotePort;
193 m_encodedDataLength = data->m_encodedDataLength;
191 m_encodedBodyLength = data->m_encodedBodyLength; 194 m_encodedBodyLength = data->m_encodedBodyLength;
192 m_decodedBodyLength = data->m_decodedBodyLength; 195 m_decodedBodyLength = data->m_decodedBodyLength;
193 m_downloadedFilePath = data->m_downloadedFilePath; 196 m_downloadedFilePath = data->m_downloadedFilePath;
194 m_downloadedFileHandle = data->m_downloadedFileHandle; 197 m_downloadedFileHandle = data->m_downloadedFileHandle;
195 198
196 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support 199 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support
197 // whatever values may be present in the opaque m_extraData structure. 200 // whatever values may be present in the opaque m_extraData structure.
198 } 201 }
199 202
200 ResourceResponse::ResourceResponse(const ResourceResponse&) = default; 203 ResourceResponse::ResourceResponse(const ResourceResponse&) = default;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 data->m_wasFetchedViaServiceWorker = m_wasFetchedViaServiceWorker; 248 data->m_wasFetchedViaServiceWorker = m_wasFetchedViaServiceWorker;
246 data->m_wasFetchedViaForeignFetch = m_wasFetchedViaForeignFetch; 249 data->m_wasFetchedViaForeignFetch = m_wasFetchedViaForeignFetch;
247 data->m_wasFallbackRequiredByServiceWorker = 250 data->m_wasFallbackRequiredByServiceWorker =
248 m_wasFallbackRequiredByServiceWorker; 251 m_wasFallbackRequiredByServiceWorker;
249 data->m_serviceWorkerResponseType = m_serviceWorkerResponseType; 252 data->m_serviceWorkerResponseType = m_serviceWorkerResponseType;
250 data->m_originalURLViaServiceWorker = m_originalURLViaServiceWorker.copy(); 253 data->m_originalURLViaServiceWorker = m_originalURLViaServiceWorker.copy();
251 data->m_cacheStorageCacheName = cacheStorageCacheName().isolatedCopy(); 254 data->m_cacheStorageCacheName = cacheStorageCacheName().isolatedCopy();
252 data->m_responseTime = m_responseTime; 255 data->m_responseTime = m_responseTime;
253 data->m_remoteIPAddress = m_remoteIPAddress.getString().isolatedCopy(); 256 data->m_remoteIPAddress = m_remoteIPAddress.getString().isolatedCopy();
254 data->m_remotePort = m_remotePort; 257 data->m_remotePort = m_remotePort;
258 data->m_encodedDataLength = m_encodedDataLength;
255 data->m_encodedBodyLength = m_encodedBodyLength; 259 data->m_encodedBodyLength = m_encodedBodyLength;
256 data->m_decodedBodyLength = m_decodedBodyLength; 260 data->m_decodedBodyLength = m_decodedBodyLength;
257 data->m_downloadedFilePath = m_downloadedFilePath.isolatedCopy(); 261 data->m_downloadedFilePath = m_downloadedFilePath.isolatedCopy();
258 data->m_downloadedFileHandle = m_downloadedFileHandle; 262 data->m_downloadedFileHandle = m_downloadedFileHandle;
259 263
260 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support 264 // Bug https://bugs.webkit.org/show_bug.cgi?id=60397 this doesn't support
261 // whatever values may be present in the opaque m_extraData structure. 265 // whatever values may be present in the opaque m_extraData structure.
262 266
263 return data; 267 return data;
264 } 268 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 592
589 PassRefPtr<ResourceLoadInfo> ResourceResponse::resourceLoadInfo() const { 593 PassRefPtr<ResourceLoadInfo> ResourceResponse::resourceLoadInfo() const {
590 return m_resourceLoadInfo.get(); 594 return m_resourceLoadInfo.get();
591 } 595 }
592 596
593 void ResourceResponse::setResourceLoadInfo( 597 void ResourceResponse::setResourceLoadInfo(
594 PassRefPtr<ResourceLoadInfo> loadInfo) { 598 PassRefPtr<ResourceLoadInfo> loadInfo) {
595 m_resourceLoadInfo = loadInfo; 599 m_resourceLoadInfo = loadInfo;
596 } 600 }
597 601
598 void ResourceResponse::addToEncodedBodyLength(int value) { 602 void ResourceResponse::addToEncodedDataLength(long long value) {
603 m_encodedDataLength += value;
604 }
605
606 void ResourceResponse::addToEncodedBodyLength(long long value) {
599 m_encodedBodyLength += value; 607 m_encodedBodyLength += value;
600 } 608 }
601 609
602 void ResourceResponse::addToDecodedBodyLength(int value) { 610 void ResourceResponse::addToDecodedBodyLength(long long value) {
603 m_decodedBodyLength += value; 611 m_decodedBodyLength += value;
604 } 612 }
605 613
606 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) { 614 void ResourceResponse::setDownloadedFilePath(const String& downloadedFilePath) {
607 m_downloadedFilePath = downloadedFilePath; 615 m_downloadedFilePath = downloadedFilePath;
608 if (m_downloadedFilePath.isEmpty()) { 616 if (m_downloadedFilePath.isEmpty()) {
609 m_downloadedFileHandle.clear(); 617 m_downloadedFileHandle.clear();
610 return; 618 return;
611 } 619 }
612 std::unique_ptr<BlobData> blobData = BlobData::create(); 620 std::unique_ptr<BlobData> blobData = BlobData::create();
613 blobData->appendFile(m_downloadedFilePath); 621 blobData->appendFile(m_downloadedFilePath);
614 blobData->detachFromCurrentThread(); 622 blobData->detachFromCurrentThread();
615 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1); 623 m_downloadedFileHandle = BlobDataHandle::create(std::move(blobData), -1);
616 } 624 }
617 625
626 void ResourceResponse::appendRedirectResponse(
627 const ResourceResponse& response) {
628 m_redirectResponses.append(response);
629 }
630
618 bool ResourceResponse::compare(const ResourceResponse& a, 631 bool ResourceResponse::compare(const ResourceResponse& a,
619 const ResourceResponse& b) { 632 const ResourceResponse& b) {
620 if (a.isNull() != b.isNull()) 633 if (a.isNull() != b.isNull())
621 return false; 634 return false;
622 if (a.url() != b.url()) 635 if (a.url() != b.url())
623 return false; 636 return false;
624 if (a.mimeType() != b.mimeType()) 637 if (a.mimeType() != b.mimeType())
625 return false; 638 return false;
626 if (a.expectedContentLength() != b.expectedContentLength()) 639 if (a.expectedContentLength() != b.expectedContentLength())
627 return false; 640 return false;
(...skipping 13 matching lines...) Expand all
641 if (a.resourceLoadTiming() != b.resourceLoadTiming()) 654 if (a.resourceLoadTiming() != b.resourceLoadTiming())
642 return false; 655 return false;
643 if (a.encodedBodyLength() != b.encodedBodyLength()) 656 if (a.encodedBodyLength() != b.encodedBodyLength())
644 return false; 657 return false;
645 if (a.decodedBodyLength() != b.decodedBodyLength()) 658 if (a.decodedBodyLength() != b.decodedBodyLength())
646 return false; 659 return false;
647 return true; 660 return true;
648 } 661 }
649 662
650 } // namespace blink 663 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698