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

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

Issue 74493002: Removed refcounting from TextResourceDecoder (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_step2
Patch Set: Compile fix Created 7 years, 1 month 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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 return true; 152 return true;
153 } 153 }
154 154
155 static bool hasTextContent(Resource* cachedResource) 155 static bool hasTextContent(Resource* cachedResource)
156 { 156 {
157 InspectorPageAgent::ResourceType type = InspectorPageAgent::cachedResourceTy pe(*cachedResource); 157 InspectorPageAgent::ResourceType type = InspectorPageAgent::cachedResourceTy pe(*cachedResource);
158 return type == InspectorPageAgent::DocumentResource || type == InspectorPage Agent::StylesheetResource || type == InspectorPageAgent::ScriptResource || type == InspectorPageAgent::XHRResource; 158 return type == InspectorPageAgent::DocumentResource || type == InspectorPage Agent::StylesheetResource || type == InspectorPageAgent::ScriptResource || type == InspectorPageAgent::XHRResource;
159 } 159 }
160 160
161 static PassRefPtr<TextResourceDecoder> createXHRTextDecoder(const String& mimeTy pe, const String& textEncodingName) 161 static PassOwnPtr<TextResourceDecoder> createXHRTextDecoder(const String& mimeTy pe, const String& textEncodingName)
162 { 162 {
163 if (!textEncodingName.isEmpty()) 163 if (!textEncodingName.isEmpty())
164 return TextResourceDecoder::create("text/plain", textEncodingName); 164 return TextResourceDecoder::create("text/plain", textEncodingName);
165 if (DOMImplementation::isXMLMIMEType(mimeType.lower())) { 165 if (DOMImplementation::isXMLMIMEType(mimeType.lower())) {
166 RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml"); 166 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml");
167 decoder->useLenientXMLDecoding(); 167 decoder->useLenientXMLDecoding();
168 return decoder; 168 return decoder.release();
169 } 169 }
170 if (equalIgnoringCase(mimeType, "text/html")) 170 if (equalIgnoringCase(mimeType, "text/html"))
171 return TextResourceDecoder::create("text/html", "UTF-8"); 171 return TextResourceDecoder::create("text/html", "UTF-8");
172 return TextResourceDecoder::create("text/plain", "UTF-8"); 172 return TextResourceDecoder::create("text/plain", "UTF-8");
173 } 173 }
174 174
175 bool InspectorPageAgent::cachedResourceContent(Resource* cachedResource, String* result, bool* base64Encoded) 175 bool InspectorPageAgent::cachedResourceContent(Resource* cachedResource, String* result, bool* base64Encoded)
176 { 176 {
177 bool hasZeroSize; 177 bool hasZeroSize;
178 bool prepared = prepareResourceBuffer(cachedResource, &hasZeroSize); 178 bool prepared = prepareResourceBuffer(cachedResource, &hasZeroSize);
(...skipping 23 matching lines...) Expand all
202 return true; 202 return true;
203 case Resource::Script: 203 case Resource::Script:
204 *result = static_cast<WebCore::ScriptResource*>(cachedResource)->scr ipt(); 204 *result = static_cast<WebCore::ScriptResource*>(cachedResource)->scr ipt();
205 return true; 205 return true;
206 case Resource::MainResource: 206 case Resource::MainResource:
207 return false; 207 return false;
208 case Resource::Raw: { 208 case Resource::Raw: {
209 SharedBuffer* buffer = cachedResource->resourceBuffer(); 209 SharedBuffer* buffer = cachedResource->resourceBuffer();
210 if (!buffer) 210 if (!buffer)
211 return false; 211 return false;
212 RefPtr<TextResourceDecoder> decoder = createXHRTextDecoder(cachedRes ource->response().mimeType(), cachedResource->response().textEncodingName()); 212 OwnPtr<TextResourceDecoder> decoder = createXHRTextDecoder(cachedRes ource->response().mimeType(), cachedResource->response().textEncodingName());
213 String content = decoder->decode(buffer->data(), buffer->size()); 213 String content = decoder->decode(buffer->data(), buffer->size());
214 *result = content + decoder->flush(); 214 *result = content + decoder->flush();
215 return true; 215 return true;
216 } 216 }
217 default: 217 default:
218 SharedBuffer* buffer = cachedResource->resourceBuffer(); 218 SharedBuffer* buffer = cachedResource->resourceBuffer();
219 return decodeBuffer(buffer ? buffer->data() : 0, buffer ? buffer->si ze() : 0, cachedResource->response().textEncodingName(), result); 219 return decodeBuffer(buffer ? buffer->data() : 0, buffer ? buffer->si ze() : 0, cachedResource->response().textEncodingName(), result);
220 } 220 }
221 } 221 }
222 return false; 222 return false;
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 } 1247 }
1248 1248
1249 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) 1249 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid)
1250 { 1250 {
1251 m_state->setBoolean(PageAgentState::showSizeOnResize, show); 1251 m_state->setBoolean(PageAgentState::showSizeOnResize, show);
1252 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; 1252 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ;
1253 } 1253 }
1254 1254
1255 } // namespace WebCore 1255 } // namespace WebCore
1256 1256
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorFileSystemAgent.cpp ('k') | Source/core/inspector/InspectorResourceAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698