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

Side by Side Diff: Source/core/inspector/NetworkResourcesData.cpp

Issue 94893003: Support for json media types as (non-image) mime types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test via synthetic NetworkRequest Created 7 years 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
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 * 10 *
(...skipping 13 matching lines...) Expand all
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/inspector/NetworkResourcesData.h" 30 #include "core/inspector/NetworkResourcesData.h"
31 31
32 #include "core/dom/DOMImplementation.h" 32 #include "core/dom/DOMImplementation.h"
33 #include "core/fetch/Resource.h" 33 #include "core/fetch/Resource.h"
34 #include "platform/MIMETypeRegistry.h"
34 #include "platform/SharedBuffer.h" 35 #include "platform/SharedBuffer.h"
35 #include "platform/network/ResourceResponse.h" 36 #include "platform/network/ResourceResponse.h"
36 37
37 namespace { 38 namespace {
38 // 100MB 39 // 100MB
39 static size_t maximumResourcesContentSize = 100 * 1000 * 1000; 40 static size_t maximumResourcesContentSize = 100 * 1000 * 1000;
40 41
41 // 10MB 42 // 10MB
42 static size_t maximumSingleResourceContentSize = 10 * 1000 * 1000; 43 static size_t maximumSingleResourceContentSize = 10 * 1000 * 1000;
43 } 44 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 void NetworkResourcesData::resourceCreated(const String& requestId, const String & loaderId) 152 void NetworkResourcesData::resourceCreated(const String& requestId, const String & loaderId)
152 { 153 {
153 ensureNoDataForRequestId(requestId); 154 ensureNoDataForRequestId(requestId);
154 m_requestIdToResourceDataMap.set(requestId, new ResourceData(requestId, load erId)); 155 m_requestIdToResourceDataMap.set(requestId, new ResourceData(requestId, load erId));
155 } 156 }
156 157
157 static PassOwnPtr<TextResourceDecoder> createOtherResourceTextDecoder(const Stri ng& mimeType, const String& textEncodingName) 158 static PassOwnPtr<TextResourceDecoder> createOtherResourceTextDecoder(const Stri ng& mimeType, const String& textEncodingName)
158 { 159 {
159 OwnPtr<TextResourceDecoder> decoder; 160 OwnPtr<TextResourceDecoder> decoder;
160 if (!textEncodingName.isEmpty()) 161 if (!textEncodingName.isEmpty()) {
161 decoder = TextResourceDecoder::create("text/plain", textEncodingName); 162 decoder = TextResourceDecoder::create("text/plain", textEncodingName);
162 else if (DOMImplementation::isXMLMIMEType(mimeType.lower())) { 163 } else {
163 decoder = TextResourceDecoder::create("application/xml"); 164 String mimeTypeLower = mimeType.lower();
164 decoder->useLenientXMLDecoding(); 165 if (DOMImplementation::isXMLMIMEType(mimeTypeLower)) {
165 } else if (equalIgnoringCase(mimeType, "text/html")) 166 decoder = TextResourceDecoder::create("application/xml");
166 decoder = TextResourceDecoder::create("text/html", "UTF-8"); 167 decoder->useLenientXMLDecoding();
167 else if (mimeType == "text/plain") 168 } else if (equalIgnoringCase(mimeType, "text/html")) {
168 decoder = TextResourceDecoder::create("text/plain", "ISO-8859-1"); 169 decoder = TextResourceDecoder::create("text/html", "UTF-8");
170 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeTypeLower ) || DOMImplementation::isJSONMIMEType(mimeTypeLower)) {
171 decoder = TextResourceDecoder::create("text/plain", "UTF-8");
172 } else if (DOMImplementation::isTextMIMEType(mimeTypeLower)) {
173 decoder = TextResourceDecoder::create("text/plain", "ISO-8859-1");
174 }
175 }
169 return decoder.release(); 176 return decoder.release();
170 } 177 }
171 178
172 void NetworkResourcesData::responseReceived(const String& requestId, const Strin g& frameId, const ResourceResponse& response) 179 void NetworkResourcesData::responseReceived(const String& requestId, const Strin g& frameId, const ResourceResponse& response)
173 { 180 {
174 ResourceData* resourceData = resourceDataForRequestId(requestId); 181 ResourceData* resourceData = resourceDataForRequestId(requestId);
175 if (!resourceData) 182 if (!resourceData)
176 return; 183 return;
177 resourceData->setFrameId(frameId); 184 resourceData->setFrameId(frameId);
178 resourceData->setUrl(response.url()); 185 resourceData->setUrl(response.url());
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 String requestId = m_requestIdsDeque.takeFirst(); 395 String requestId = m_requestIdsDeque.takeFirst();
389 ResourceData* resourceData = resourceDataForRequestId(requestId); 396 ResourceData* resourceData = resourceDataForRequestId(requestId);
390 if (resourceData) 397 if (resourceData)
391 m_contentSize -= resourceData->evictContent(); 398 m_contentSize -= resourceData->evictContent();
392 } 399 }
393 return true; 400 return true;
394 } 401 }
395 402
396 } // namespace WebCore 403 } // namespace WebCore
397 404
OLDNEW
« no previous file with comments | « Source/core/dom/DOMImplementationTest.cpp ('k') | Source/devtools/front_end/RequestPreviewView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698