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

Side by Side Diff: third_party/WebKit/Source/core/page/EventSource.cpp

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 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) 2009, 2012 Ericsson AB. All rights reserved. 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString(); 231 m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString();
232 int statusCode = response.httpStatusCode(); 232 int statusCode = response.httpStatusCode();
233 bool mimeTypeIsValid = response.mimeType() == "text/event-stream"; 233 bool mimeTypeIsValid = response.mimeType() == "text/event-stream";
234 bool responseIsValid = statusCode == 200 && mimeTypeIsValid; 234 bool responseIsValid = statusCode == 200 && mimeTypeIsValid;
235 if (responseIsValid) { 235 if (responseIsValid) {
236 const String& charset = response.textEncodingName(); 236 const String& charset = response.textEncodingName();
237 // If we have a charset, the only allowed value is UTF-8 (case-insensiti ve). 237 // If we have a charset, the only allowed value is UTF-8 (case-insensiti ve).
238 responseIsValid = charset.isEmpty() || equalIgnoringCase(charset, "UTF-8 "); 238 responseIsValid = charset.isEmpty() || equalIgnoringCase(charset, "UTF-8 ");
239 if (!responseIsValid) { 239 if (!responseIsValid) {
240 StringBuilder message; 240 StringBuilder message;
241 message.appendLiteral("EventSource's response has a charset (\""); 241 message.append("EventSource's response has a charset (\"");
242 message.append(charset); 242 message.append(charset);
243 message.appendLiteral("\") that is not UTF-8. Aborting the connectio n."); 243 message.append("\") that is not UTF-8. Aborting the connection.");
244 // FIXME: We are missing the source line. 244 // FIXME: We are missing the source line.
245 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMe ssageSource, ErrorMessageLevel, message.toString())); 245 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMe ssageSource, ErrorMessageLevel, message.toString()));
246 } 246 }
247 } else { 247 } else {
248 // To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type. 248 // To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type.
249 if (statusCode == 200 && !mimeTypeIsValid) { 249 if (statusCode == 200 && !mimeTypeIsValid) {
250 StringBuilder message; 250 StringBuilder message;
251 message.appendLiteral("EventSource's response has a MIME type (\""); 251 message.append("EventSource's response has a MIME type (\"");
252 message.append(response.mimeType()); 252 message.append(response.mimeType());
253 message.appendLiteral("\") that is not \"text/event-stream\". Aborti ng the connection."); 253 message.append("\") that is not \"text/event-stream\". Aborting the connection.");
254 // FIXME: We are missing the source line. 254 // FIXME: We are missing the source line.
255 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMe ssageSource, ErrorMessageLevel, message.toString())); 255 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMe ssageSource, ErrorMessageLevel, message.toString()));
256 } 256 }
257 } 257 }
258 258
259 if (responseIsValid) { 259 if (responseIsValid) {
260 m_state = OPEN; 260 m_state = OPEN;
261 AtomicString lastEventId; 261 AtomicString lastEventId;
262 if (m_parser) { 262 if (m_parser) {
263 // The new parser takes over the event ID. 263 // The new parser takes over the event ID.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 DEFINE_TRACE(EventSource) 353 DEFINE_TRACE(EventSource)
354 { 354 {
355 visitor->trace(m_parser); 355 visitor->trace(m_parser);
356 EventTargetWithInlineData::trace(visitor); 356 EventTargetWithInlineData::trace(visitor);
357 ActiveDOMObject::trace(visitor); 357 ActiveDOMObject::trace(visitor);
358 EventSourceParser::Client::trace(visitor); 358 EventSourceParser::Client::trace(visitor);
359 } 359 }
360 360
361 } // namespace blink 361 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp ('k') | third_party/WebKit/Source/core/page/FrameTree.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698