<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200558] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200558">200558</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2016-05-08 11:46:53 -0700 (Sun, 08 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Change EventSource constructor to take an IDL dictionary instead of a WebCore::Dictionary
https://bugs.webkit.org/show_bug.cgi?id=157459
Reviewed by Chris Dumez.
Source/WebCore:
Patch also includes some updating of EventSource class to modern idioms.
* page/EventSource.cpp:
(WebCore::EventSource::EventSource): Initialize based on Init.
(WebCore::EventSource::create): Take/pass Init instead of Dictionary.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::serialize): Take a StringView instead of a string
so callers don't have to allocate a String just to use this.
(WebCore::SerializedScriptValue::create): Ditto.
* bindings/js/SerializedScriptValue.h: Ditto.
* page/EventSource.cpp: Changed defaultReconnectDelay to be a uint64_t
instead of an unsigned long long.
(WebCore::EventSource::EventSource): Changed constructor to take a struct
instead of a Dictionary for eventSourceInit. Also moved initialization of
data members to the header and used ASCIILiteral.
(WebCore::EventSource::create): Changed type to Init and streamlined code
a little bit using auto.
(WebCore::EventSource::connect): Used a reference instead of a pointer.
Also added a FIXME since I noticed that m_requestInFlight is probably not
needed, since it's basically the same thing as "is m_loader null".
(WebCore::EventSource::url): Moved to the header and made it inline.
(WebCore::EventSource::networkRequestEnded): Removed unneeded check that
is already done by all callers and turned it into an assertion.
(WebCore::EventSource::withCredentials): Ditto.
(WebCore::EventSource::readyState): Ditto.
(WebCore::EventSource::responseIsValid): Added. Helper function to make
the logic in didReceiveResponse easier to read. Fixed logic to compare
MIME type ignoring ASCII case, since that's how MIME types work.
(WebCore::EventSource::didReceiveResponse): Use the helper above, and also
move the m_eventStreamOrigin set up code into the valid response case,
since there is no point doing it if the response is not valid. Also use
the early return idiom.
(WebCore::EventSource::didReceiveData): Removed the unneeded explicit
conversion to StringView here. Also removed a FIXME that I fixed.
(WebCore::EventSource::didFinishLoading): Added code to flush the decoder
as mentioned in didReceiveData. Added FIXME about peculiar clearing code
that exists only here. Removed check for empty receive buffer and data
that is not needed since parseEventStream does sufficient checking.
(WebCore::EventSource::didFail): Added FIXME because of things that
didFinishLoading does that seem equally valuable here.
(WebCore::EventSource::parseEventStream): Tweaked types and names of local
variables, and changed to use Optional instead of magic number -1. Also
added a FIXME about how the buffer type is probably not right since we
keep moving the characters in the buffer as we consume the start of it.
(WebCore::EventSource::parseEventStreamLine): Refactor and reorganize so
this doesn't do so much string allocation and is easier to read
(WebCore::EventSource::canSuspendForDocumentSuspension): Tweaked comment.
(WebCore::EventSource::dispatchMessageEvent): Renamed this from
createMessageEvent, and moved more code in here. We now don't have to
allocate a temporary string just to pass it to SerializedScriptValue.
* page/EventSource.h: Updated for changes above. Use pragma once.
Define and use EventSource::Init struct. Other small cleanup.
* page/EventSource.idl: Define EventSourceInit dictionary and use it.
Other small cleanup.
* page/EventSource.idl: U
Source/WTF:
* wtf/text/WTFString.h: Export a symbol now used in WebCore.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringh">trunk/Source/WTF/wtf/text/WTFString.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsSerializedScriptValuecpp">trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsSerializedScriptValueh">trunk/Source/WebCore/bindings/js/SerializedScriptValue.h</a></li>
<li><a href="#trunkSourceWebCorepageEventSourcecpp">trunk/Source/WebCore/page/EventSource.cpp</a></li>
<li><a href="#trunkSourceWebCorepageEventSourceh">trunk/Source/WebCore/page/EventSource.h</a></li>
<li><a href="#trunkSourceWebCorepageEventSourceidl">trunk/Source/WebCore/page/EventSource.idl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WTF/ChangeLog        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-05-08 Darin Adler <darin@apple.com>
+
+ Change EventSource constructor to take an IDL dictionary instead of a WebCore::Dictionary
+ https://bugs.webkit.org/show_bug.cgi?id=157459
+
+ Reviewed by Chris Dumez.
+
+ * wtf/text/WTFString.h: Export a symbol now used in WebCore.
+
</ins><span class="cx"> 2016-05-02 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> On platforms that support it, use a SecTrustRef as the basis of CertificateInfo instead of a chain of SecCertificateRefs.
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.h (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.h        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WTF/wtf/text/WTFString.h        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx">
</span><span class="cx"> namespace WTF {
</span><span class="cx">
</span><ins>+class ASCIILiteral;
+
</ins><span class="cx"> // Declarations of string operations
</span><span class="cx">
</span><span class="cx"> WTF_EXPORT_STRING_API int charactersToIntStrict(const LChar*, size_t, bool* ok = 0, int base = 10);
</span><span class="lines">@@ -54,7 +56,7 @@
</span><span class="cx"> int64_t charactersToInt64(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
</span><span class="cx"> int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
</span><span class="cx"> uint64_t charactersToUInt64(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
</span><del>-uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
</del><ins>+WTF_EXPORT_STRING_API uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
</ins><span class="cx"> intptr_t charactersToIntPtr(const LChar*, size_t, bool* ok = 0); // ignores trailing garbage
</span><span class="cx"> intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
</span><span class="cx">
</span><span class="lines">@@ -68,16 +70,10 @@
</span><span class="cx"> WTF_EXPORT_STRING_API float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
</span><span class="cx"> WTF_EXPORT_STRING_API float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
</span><span class="cx">
</span><del>-class ASCIILiteral;
</del><ins>+template<bool isSpecialCharacter(UChar), typename CharacterType> bool isAllSpecialCharacters(const CharacterType*, size_t);
</ins><span class="cx">
</span><del>-enum TrailingZerosTruncatingPolicy {
- KeepTrailingZeros,
- TruncateTrailingZeros
-};
</del><ins>+enum TrailingZerosTruncatingPolicy { KeepTrailingZeros, TruncateTrailingZeros };
</ins><span class="cx">
</span><del>-template<bool isSpecialCharacter(UChar), typename CharacterType>
-bool isAllSpecialCharacters(const CharacterType*, size_t);
-
</del><span class="cx"> class String {
</span><span class="cx"> public:
</span><span class="cx"> // Construct a null string, distinguishable from an empty string.
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/ChangeLog        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -1,3 +1,71 @@
</span><ins>+2016-05-08 Darin Adler <darin@apple.com>
+
+ Change EventSource constructor to take an IDL dictionary instead of a WebCore::Dictionary
+ https://bugs.webkit.org/show_bug.cgi?id=157459
+
+ Reviewed by Chris Dumez.
+
+ Patch also includes some updating of EventSource class to modern idioms.
+
+ * page/EventSource.cpp:
+ (WebCore::EventSource::EventSource): Initialize based on Init.
+ (WebCore::EventSource::create): Take/pass Init instead of Dictionary.
+
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::CloneSerializer::serialize): Take a StringView instead of a string
+ so callers don't have to allocate a String just to use this.
+ (WebCore::SerializedScriptValue::create): Ditto.
+ * bindings/js/SerializedScriptValue.h: Ditto.
+
+ * page/EventSource.cpp: Changed defaultReconnectDelay to be a uint64_t
+ instead of an unsigned long long.
+ (WebCore::EventSource::EventSource): Changed constructor to take a struct
+ instead of a Dictionary for eventSourceInit. Also moved initialization of
+ data members to the header and used ASCIILiteral.
+ (WebCore::EventSource::create): Changed type to Init and streamlined code
+ a little bit using auto.
+ (WebCore::EventSource::connect): Used a reference instead of a pointer.
+ Also added a FIXME since I noticed that m_requestInFlight is probably not
+ needed, since it's basically the same thing as "is m_loader null".
+ (WebCore::EventSource::url): Moved to the header and made it inline.
+ (WebCore::EventSource::networkRequestEnded): Removed unneeded check that
+ is already done by all callers and turned it into an assertion.
+ (WebCore::EventSource::withCredentials): Ditto.
+ (WebCore::EventSource::readyState): Ditto.
+ (WebCore::EventSource::responseIsValid): Added. Helper function to make
+ the logic in didReceiveResponse easier to read. Fixed logic to compare
+ MIME type ignoring ASCII case, since that's how MIME types work.
+ (WebCore::EventSource::didReceiveResponse): Use the helper above, and also
+ move the m_eventStreamOrigin set up code into the valid response case,
+ since there is no point doing it if the response is not valid. Also use
+ the early return idiom.
+ (WebCore::EventSource::didReceiveData): Removed the unneeded explicit
+ conversion to StringView here. Also removed a FIXME that I fixed.
+ (WebCore::EventSource::didFinishLoading): Added code to flush the decoder
+ as mentioned in didReceiveData. Added FIXME about peculiar clearing code
+ that exists only here. Removed check for empty receive buffer and data
+ that is not needed since parseEventStream does sufficient checking.
+ (WebCore::EventSource::didFail): Added FIXME because of things that
+ didFinishLoading does that seem equally valuable here.
+ (WebCore::EventSource::parseEventStream): Tweaked types and names of local
+ variables, and changed to use Optional instead of magic number -1. Also
+ added a FIXME about how the buffer type is probably not right since we
+ keep moving the characters in the buffer as we consume the start of it.
+ (WebCore::EventSource::parseEventStreamLine): Refactor and reorganize so
+ this doesn't do so much string allocation and is easier to read
+ (WebCore::EventSource::canSuspendForDocumentSuspension): Tweaked comment.
+ (WebCore::EventSource::dispatchMessageEvent): Renamed this from
+ createMessageEvent, and moved more code in here. We now don't have to
+ allocate a temporary string just to pass it to SerializedScriptValue.
+
+ * page/EventSource.h: Updated for changes above. Use pragma once.
+ Define and use EventSource::Init struct. Other small cleanup.
+
+ * page/EventSource.idl: Define EventSourceInit dictionary and use it.
+ Other small cleanup.
+
+ * page/EventSource.idl: U
+
</ins><span class="cx"> 2016-05-07 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Change HTMLSlotElement::assignedNodes to take a IDL dictionary instead of a WebCore::Dictionary
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsSerializedScriptValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -478,20 +478,20 @@
</span><span class="cx"> return serializer.serialize(value);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- static bool serialize(const String& s, Vector<uint8_t>& out)
</del><ins>+ static bool serialize(StringView string, Vector<uint8_t>& out)
</ins><span class="cx"> {
</span><span class="cx"> writeLittleEndian(out, CurrentVersion);
</span><del>- if (s.isEmpty()) {
</del><ins>+ if (string.isEmpty()) {
</ins><span class="cx"> writeLittleEndian<uint8_t>(out, EmptyStringTag);
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx"> writeLittleEndian<uint8_t>(out, StringTag);
</span><del>- if (s.is8Bit()) {
- writeLittleEndian(out, s.length() | StringDataIs8BitFlag);
- return writeLittleEndian(out, s.characters8(), s.length());
</del><ins>+ if (string.is8Bit()) {
+ writeLittleEndian(out, string.length() | StringDataIs8BitFlag);
+ return writeLittleEndian(out, string.characters8(), string.length());
</ins><span class="cx"> }
</span><del>- writeLittleEndian(out, s.length());
- return writeLittleEndian(out, s.characters16(), s.length());
</del><ins>+ writeLittleEndian(out, string.length());
+ return writeLittleEndian(out, string.characters16(), string.length());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void serializeUndefined(Vector<uint8_t>& out)
</span><span class="lines">@@ -2687,7 +2687,7 @@
</span><span class="cx"> return adoptRef(*new SerializedScriptValue(WTFMove(buffer), blobURLs, WTFMove(arrayBufferContentsArray)));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& string)
</del><ins>+RefPtr<SerializedScriptValue> SerializedScriptValue::create(StringView string)
</ins><span class="cx"> {
</span><span class="cx"> Vector<uint8_t> buffer;
</span><span class="cx"> if (!CloneSerializer::serialize(string, buffer))
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsSerializedScriptValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.h (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.h        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.h        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> public:
</span><span class="cx"> WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing);
</span><span class="cx">
</span><del>- WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(const String&);
</del><ins>+ WEBCORE_EXPORT static RefPtr<SerializedScriptValue> create(StringView);
</ins><span class="cx"> static Ref<SerializedScriptValue> adopt(Vector<uint8_t>&& buffer)
</span><span class="cx"> {
</span><span class="cx"> return adoptRef(*new SerializedScriptValue(WTFMove(buffer)));
</span></span></pre></div>
<a id="trunkSourceWebCorepageEventSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventSource.cpp (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventSource.cpp        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/page/EventSource.cpp        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved.
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
</span><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -34,44 +34,29 @@
</span><span class="cx"> #include "EventSource.h"
</span><span class="cx">
</span><span class="cx"> #include "ContentSecurityPolicy.h"
</span><del>-#include "DOMWindow.h"
-#include "Dictionary.h"
-#include "Document.h"
-#include "Event.h"
</del><span class="cx"> #include "ExceptionCode.h"
</span><del>-#include "Frame.h"
-#include "HTTPHeaderNames.h"
-#include "MemoryCache.h"
</del><span class="cx"> #include "MessageEvent.h"
</span><span class="cx"> #include "ResourceError.h"
</span><del>-#include "ResourceRequest.h"
</del><span class="cx"> #include "ResourceResponse.h"
</span><del>-#include "ScriptController.h"
</del><span class="cx"> #include "ScriptExecutionContext.h"
</span><span class="cx"> #include "SecurityOrigin.h"
</span><del>-#include "SerializedScriptValue.h"
</del><span class="cx"> #include "TextResourceDecoder.h"
</span><span class="cx"> #include "ThreadableLoader.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-const unsigned long long EventSource::defaultReconnectDelay = 3000;
</del><ins>+const uint64_t EventSource::defaultReconnectDelay = 3000;
</ins><span class="cx">
</span><del>-inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url, const Dictionary& eventSourceInit)
</del><ins>+inline EventSource::EventSource(ScriptExecutionContext& context, const URL& url, const Init& eventSourceInit)
</ins><span class="cx"> : ActiveDOMObject(&context)
</span><span class="cx"> , m_url(url)
</span><del>- , m_withCredentials(false)
- , m_state(CONNECTING)
- , m_decoder(TextResourceDecoder::create("text/plain", "UTF-8"))
</del><ins>+ , m_withCredentials(eventSourceInit.withCredentials)
+ , m_decoder(TextResourceDecoder::create(ASCIILiteral("text/plain"), "UTF-8"))
</ins><span class="cx"> , m_connectTimer(*this, &EventSource::connect)
</span><del>- , m_discardTrailingNewline(false)
- , m_requestInFlight(false)
- , m_reconnectDelay(defaultReconnectDelay)
</del><span class="cx"> {
</span><del>- eventSourceInit.get("withCredentials", m_withCredentials);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Dictionary& eventSourceInit, ExceptionCode& ec)
</del><ins>+RefPtr<EventSource> EventSource::create(ScriptExecutionContext& context, const String& url, const Init& eventSourceInit, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> if (url.isEmpty()) {
</span><span class="cx"> ec = SYNTAX_ERR;
</span><span class="lines">@@ -91,13 +76,11 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<EventSource> source = adoptRef(new EventSource(context, fullURL, eventSourceInit));
-
- source->setPendingActivity(source.get());
</del><ins>+ auto source = adoptRef(*new EventSource(context, fullURL, eventSourceInit));
+ source->setPendingActivity(source.ptr());
</ins><span class="cx"> source->scheduleInitialConnect();
</span><span class="cx"> source->suspendIfNeeded();
</span><del>-
- return source.release();
</del><ins>+ return WTFMove(source);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> EventSource::~EventSource()
</span><span class="lines">@@ -111,36 +94,36 @@
</span><span class="cx"> ASSERT(m_state == CONNECTING);
</span><span class="cx"> ASSERT(!m_requestInFlight);
</span><span class="cx">
</span><del>- ResourceRequest request(m_url);
</del><ins>+ ResourceRequest request { m_url };
</ins><span class="cx"> request.setHTTPMethod("GET");
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::Accept, "text/event-stream");
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");
</span><span class="cx"> if (!m_lastEventId.isEmpty())
</span><span class="cx"> request.setHTTPHeaderField(HTTPHeaderName::LastEventID, m_lastEventId);
</span><span class="cx">
</span><del>- SecurityOrigin* origin = scriptExecutionContext()->securityOrigin();
</del><ins>+ SecurityOrigin& origin = *scriptExecutionContext()->securityOrigin();
</ins><span class="cx">
</span><span class="cx"> ThreadableLoaderOptions options;
</span><span class="cx"> options.setSendLoadCallbacks(SendCallbacks);
</span><span class="cx"> options.setSniffContent(DoNotSniffContent);
</span><del>- options.setAllowCredentials((origin->canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials);
</del><ins>+ options.setAllowCredentials((origin.canRequest(m_url) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials);
</ins><span class="cx"> options.setCredentialRequest(m_withCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials);
</span><span class="cx"> options.preflightPolicy = PreventPreflight;
</span><span class="cx"> options.crossOriginRequestPolicy = UseAccessControl;
</span><span class="cx"> options.setDataBufferingPolicy(DoNotBufferData);
</span><del>- options.securityOrigin = origin;
</del><ins>+ options.securityOrigin = &origin;
</ins><span class="cx"> options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective;
</span><span class="cx">
</span><span class="cx"> m_loader = ThreadableLoader::create(scriptExecutionContext(), this, request, options);
</span><span class="cx">
</span><ins>+ // FIXME: Can we just use m_loader for this, null it out when it's no longer in flight, and eliminate the m_requestInFlight member?
</ins><span class="cx"> if (m_loader)
</span><span class="cx"> m_requestInFlight = true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void EventSource::networkRequestEnded()
</span><span class="cx"> {
</span><del>- if (!m_requestInFlight)
- return;
</del><ins>+ ASSERT(m_requestInFlight);
</ins><span class="cx">
</span><span class="cx"> m_requestInFlight = false;
</span><span class="cx">
</span><span class="lines">@@ -165,21 +148,6 @@
</span><span class="cx"> dispatchEvent(Event::create(eventNames().errorEvent, false, false));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String EventSource::url() const
-{
- return m_url.string();
-}
-
-bool EventSource::withCredentials() const
-{
- return m_withCredentials;
-}
-
-EventSource::State EventSource::readyState() const
-{
- return m_state;
-}
-
</del><span class="cx"> void EventSource::close()
</span><span class="cx"> {
</span><span class="cx"> if (m_state == CLOSED) {
</span><span class="lines">@@ -199,40 +167,47 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool EventSource::responseIsValid(const ResourceResponse& response) const
+{
+ // Logs to the console as a side effect.
+
+ // To keep the signal-to-noise ratio low, we don't log anything if the status code is not 200.
+ if (response.httpStatusCode() != 200)
+ return false;
+
+ if (!equalLettersIgnoringASCIICase(response.mimeType(), "text/event-stream")) {
+ auto message = makeString("EventSource's response has a MIME type (\"", response.mimeType(), "\") that is not \"text/event-stream\". Aborting the connection.");
+ // FIXME: Console message would be better with a source code location; where would we get that?
+ scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, WTFMove(message));
+ return false;
+ }
+
+ // If we have a charset, the only allowed value is UTF-8 (case-insensitive).
+ auto& charset = response.textEncodingName();
+ if (!charset.isEmpty() && !equalLettersIgnoringASCIICase(charset, "utf-8")) {
+ auto message = makeString("EventSource's response has a charset (\"", charset, "\") that is not UTF-8. Aborting the connection.");
+ // FIXME: Console message would be better with a source code location; where would we get that?
+ scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, WTFMove(message));
+ return false;
+ }
+
+ return true;
+}
+
</ins><span class="cx"> void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& response)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_state == CONNECTING);
</span><span class="cx"> ASSERT(m_requestInFlight);
</span><span class="cx">
</span><del>- m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString();
- int statusCode = response.httpStatusCode();
- bool mimeTypeIsValid = response.mimeType() == "text/event-stream";
- bool responseIsValid = statusCode == 200 && mimeTypeIsValid;
- if (responseIsValid) {
- const String& charset = response.textEncodingName();
- // If we have a charset, the only allowed value is UTF-8 (case-insensitive).
- responseIsValid = charset.isEmpty() || equalLettersIgnoringASCIICase(charset, "utf-8");
- if (!responseIsValid) {
- String message = makeString("EventSource's response has a charset (\"", charset, "\") that is not UTF-8. Aborting the connection.");
- // FIXME: We are missing the source line.
- scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, message);
- }
- } else {
- // To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type.
- if (statusCode == 200 && !mimeTypeIsValid) {
- String message = makeString("EventSource's response has a MIME type (\"", response.mimeType(), "\") that is not \"text/event-stream\". Aborting the connection.");
- // FIXME: We are missing the source line.
- scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Error, message);
- }
- }
-
- if (responseIsValid) {
- m_state = OPEN;
- dispatchEvent(Event::create(eventNames().openEvent, false, false));
- } else {
</del><ins>+ if (!responseIsValid(response)) {
</ins><span class="cx"> m_loader->cancel();
</span><span class="cx"> dispatchEvent(Event::create(eventNames().errorEvent, false, false));
</span><ins>+ return;
</ins><span class="cx"> }
</span><ins>+
+ m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString();
+ m_state = OPEN;
+ dispatchEvent(Event::create(eventNames().openEvent, false, false));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void EventSource::didReceiveData(const char* data, int length)
</span><span class="lines">@@ -240,8 +215,7 @@
</span><span class="cx"> ASSERT(m_state == OPEN);
</span><span class="cx"> ASSERT(m_requestInFlight);
</span><span class="cx">
</span><del>- // FIXME: Need to call flush at some point.
- append(m_receiveBuf, StringView(m_decoder->decode(data, length)));
</del><ins>+ append(m_receiveBuffer, m_decoder->decode(data, length));
</ins><span class="cx"> parseEventStream();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -250,15 +224,17 @@
</span><span class="cx"> ASSERT(m_state == OPEN);
</span><span class="cx"> ASSERT(m_requestInFlight);
</span><span class="cx">
</span><del>- if (m_receiveBuf.size() > 0 || m_data.size() > 0) {
- parseEventStream();
</del><ins>+ append(m_receiveBuffer, m_decoder->flush());
+ parseEventStream();
</ins><span class="cx">
</span><del>- // Discard everything that has not been dispatched by now.
- m_receiveBuf.clear();
- m_data.clear();
- m_eventName = "";
- m_currentlyParsedEventId = String();
- }
</del><ins>+ // Discard everything that has not been dispatched by now.
+ // FIXME: Why does this need to be done?
+ // If this is important, why isn't it important to clear other data members: m_decoder, m_lastEventId, m_loader?
+ m_receiveBuffer.clear();
+ m_data.clear();
+ m_eventName = { };
+ m_currentlyParsedEventId = { };
+
</ins><span class="cx"> networkRequestEnded();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -269,6 +245,9 @@
</span><span class="cx">
</span><span class="cx"> if (error.isCancellation())
</span><span class="cx"> m_state = CLOSED;
</span><ins>+
+ // FIXME: Why don't we need to clear data members here as in didFinishLoading?
+
</ins><span class="cx"> networkRequestEnded();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -302,37 +281,37 @@
</span><span class="cx">
</span><span class="cx"> void EventSource::parseEventStream()
</span><span class="cx"> {
</span><del>- unsigned int bufPos = 0;
- unsigned int bufSize = m_receiveBuf.size();
- while (bufPos < bufSize) {
</del><ins>+ unsigned position = 0;
+ unsigned size = m_receiveBuffer.size();
+ while (position < size) {
</ins><span class="cx"> if (m_discardTrailingNewline) {
</span><del>- if (m_receiveBuf[bufPos] == '\n')
- bufPos++;
</del><ins>+ if (m_receiveBuffer[position] == '\n')
+ position++;
</ins><span class="cx"> m_discardTrailingNewline = false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- int lineLength = -1;
- int fieldLength = -1;
- for (unsigned int i = bufPos; lineLength < 0 && i < bufSize; i++) {
- switch (m_receiveBuf[i]) {
</del><ins>+ Optional<unsigned> lineLength;
+ Optional<unsigned> fieldLength;
+ for (unsigned i = position; !lineLength && i < size; i++) {
+ switch (m_receiveBuffer[i]) {
</ins><span class="cx"> case ':':
</span><del>- if (fieldLength < 0)
- fieldLength = i - bufPos;
</del><ins>+ if (!fieldLength)
+ fieldLength = i - position;
</ins><span class="cx"> break;
</span><span class="cx"> case '\r':
</span><span class="cx"> m_discardTrailingNewline = true;
</span><span class="cx"> FALLTHROUGH;
</span><span class="cx"> case '\n':
</span><del>- lineLength = i - bufPos;
</del><ins>+ lineLength = i - position;
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (lineLength < 0)
</del><ins>+ if (!lineLength)
</ins><span class="cx"> break;
</span><span class="cx">
</span><del>- parseEventStreamLine(bufPos, fieldLength, lineLength);
- bufPos += lineLength + 1;
</del><ins>+ parseEventStreamLine(position, fieldLength, lineLength.value());
+ position += lineLength.value() + 1;
</ins><span class="cx">
</span><span class="cx"> // EventSource.close() might've been called by one of the message event handlers.
</span><span class="cx"> // Per spec, no further messages should be fired after that.
</span><span class="lines">@@ -340,57 +319,55 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (bufPos == bufSize)
- m_receiveBuf.clear();
- else if (bufPos)
- m_receiveBuf.remove(0, bufPos);
</del><ins>+ // FIXME: The following operation makes it clear that m_receiveBuffer should be some other type,
+ // perhaps a Deque or a circular buffer of some sort.
+ if (position == size)
+ m_receiveBuffer.clear();
+ else if (position)
+ m_receiveBuffer.remove(0, position);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void EventSource::parseEventStreamLine(unsigned bufPos, int fieldLength, int lineLength)
</del><ins>+void EventSource::parseEventStreamLine(unsigned position, Optional<unsigned> fieldLength, unsigned lineLength)
</ins><span class="cx"> {
</span><span class="cx"> if (!lineLength) {
</span><del>- if (!m_data.isEmpty()) {
- m_data.removeLast();
- if (!m_currentlyParsedEventId.isNull()) {
- m_lastEventId.swap(m_currentlyParsedEventId);
- m_currentlyParsedEventId = String();
- }
- dispatchEvent(createMessageEvent());
- }
- if (!m_eventName.isEmpty())
- m_eventName = "";
- } else if (fieldLength) {
- bool noValue = fieldLength < 0;
</del><ins>+ if (!m_data.isEmpty())
+ dispatchMessageEvent();
+ m_eventName = { };
+ return;
+ }
</ins><span class="cx">
</span><del>- String field(&m_receiveBuf[bufPos], noValue ? lineLength : fieldLength);
- int step;
- if (noValue)
- step = lineLength;
- else if (m_receiveBuf[bufPos + fieldLength + 1] != ' ')
- step = fieldLength + 1;
- else
- step = fieldLength + 2;
- bufPos += step;
- int valueLength = lineLength - step;
</del><ins>+ if (fieldLength && !fieldLength.value())
+ return;
</ins><span class="cx">
</span><del>- if (field == "data") {
- if (valueLength)
- m_data.append(&m_receiveBuf[bufPos], valueLength);
- m_data.append('\n');
- } else if (field == "event")
- m_eventName = valueLength ? String(&m_receiveBuf[bufPos], valueLength) : "";
- else if (field == "id")
- m_currentlyParsedEventId = valueLength ? String(&m_receiveBuf[bufPos], valueLength) : "";
- else if (field == "retry") {
- if (!valueLength)
- m_reconnectDelay = defaultReconnectDelay;
- else {
- String value(&m_receiveBuf[bufPos], valueLength);
- bool ok;
- unsigned long long retry = value.toUInt64(&ok);
- if (ok)
- m_reconnectDelay = retry;
- }
</del><ins>+ StringView field { &m_receiveBuffer[position], fieldLength ? fieldLength.value() : lineLength };
+
+ unsigned step;
+ if (!fieldLength)
+ step = lineLength;
+ else if (m_receiveBuffer[position + fieldLength.value() + 1] != ' ')
+ step = fieldLength.value() + 1;
+ else
+ step = fieldLength.value() + 2;
+ position += step;
+ unsigned valueLength = lineLength - step;
+
+ if (field == "data") {
+ m_data.append(&m_receiveBuffer[position], valueLength);
+ m_data.append('\n');
+ } else if (field == "event")
+ m_eventName = { &m_receiveBuffer[position], valueLength };
+ else if (field == "id")
+ m_currentlyParsedEventId = { &m_receiveBuffer[position], valueLength };
+ else if (field == "retry") {
+ if (!valueLength)
+ m_reconnectDelay = defaultReconnectDelay;
+ else {
+ // FIXME: Do we really want to ignore trailing garbage here? Should we be using the strict version instead?
+ // FIXME: If we can't parse the value, should we leave m_reconnectDelay alone or set it to defaultReconnectDelay?
+ bool ok;
+ auto reconnectDelay = charactersToUInt64(&m_receiveBuffer[position], valueLength, &ok);
+ if (ok)
+ m_reconnectDelay = reconnectDelay;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -407,13 +384,24 @@
</span><span class="cx">
</span><span class="cx"> bool EventSource::canSuspendForDocumentSuspension() const
</span><span class="cx"> {
</span><del>- // FIXME: We should try and do better here.
</del><ins>+ // FIXME: We should return true here when we can because this object is not actually currently active.
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Ref<MessageEvent> EventSource::createMessageEvent()
</del><ins>+void EventSource::dispatchMessageEvent()
</ins><span class="cx"> {
</span><del>- return MessageEvent::create(m_eventName.isEmpty() ? eventNames().messageEvent : AtomicString(m_eventName), SerializedScriptValue::create(String::adopt(m_data)), m_eventStreamOrigin, m_lastEventId);
</del><ins>+ if (!m_currentlyParsedEventId.isNull())
+ m_lastEventId = WTFMove(m_currentlyParsedEventId);
+
+ auto& name = m_eventName.isEmpty() ? eventNames().messageEvent : m_eventName;
+
+ // Omit the trailing "\n" character.
+ ASSERT(!m_data.isEmpty());
+ unsigned size = m_data.size() - 1;
+ auto data = SerializedScriptValue::create(StringView { m_data.data(), size });
+ m_data = { };
+
+ dispatchEvent(MessageEvent::create(name, WTFMove(data), m_eventStreamOrigin, m_lastEventId));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageEventSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventSource.h (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventSource.h        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/page/EventSource.h        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -29,34 +29,31 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef EventSource_h
-#define EventSource_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #include "ActiveDOMObject.h"
</span><span class="cx"> #include "EventTarget.h"
</span><span class="cx"> #include "URL.h"
</span><span class="cx"> #include "ThreadableLoaderClient.h"
</span><span class="cx"> #include "Timer.h"
</span><del>-#include <wtf/RefPtr.h>
</del><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class Dictionary;
</del><span class="cx"> class MessageEvent;
</span><del>-class ResourceResponse;
</del><span class="cx"> class TextResourceDecoder;
</span><span class="cx"> class ThreadableLoader;
</span><span class="cx">
</span><span class="cx"> class EventSource final : public RefCounted<EventSource>, public EventTargetWithInlineData, private ThreadableLoaderClient, public ActiveDOMObject {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- static RefPtr<EventSource> create(ScriptExecutionContext&, const String& url, const Dictionary&, ExceptionCode&);
</del><ins>+ struct Init {
+ bool withCredentials;
+ };
+ static RefPtr<EventSource> create(ScriptExecutionContext&, const String& url, const Init&, ExceptionCode&);
</ins><span class="cx"> virtual ~EventSource();
</span><span class="cx">
</span><del>- static const unsigned long long defaultReconnectDelay;
-
- String url() const;
</del><ins>+ const String& url() const;
</ins><span class="cx"> bool withCredentials() const;
</span><span class="cx">
</span><span class="cx"> typedef short State;
</span><span class="lines">@@ -68,58 +65,74 @@
</span><span class="cx">
</span><span class="cx"> void close();
</span><span class="cx">
</span><del>- using RefCounted<EventSource>::ref;
- using RefCounted<EventSource>::deref;
</del><ins>+ using RefCounted::ref;
+ using RefCounted::deref;
</ins><span class="cx">
</span><del>- EventTargetInterface eventTargetInterface() const override { return EventSourceEventTargetInterfaceType; }
- ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
-
</del><span class="cx"> private:
</span><del>- EventSource(ScriptExecutionContext&, const URL&, const Dictionary&);
</del><ins>+ EventSource(ScriptExecutionContext&, const URL&, const Init&);
</ins><span class="cx">
</span><del>- void refEventTarget() override { ref(); }
- void derefEventTarget() override { deref(); }
</del><ins>+ EventTargetInterface eventTargetInterface() const final { return EventSourceEventTargetInterfaceType; }
+ ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
</ins><span class="cx">
</span><del>- void didReceiveResponse(unsigned long, const ResourceResponse&) override;
- void didReceiveData(const char*, int) override;
- void didFinishLoading(unsigned long, double) override;
- void didFail(const ResourceError&) override;
- void didFailAccessControlCheck(const ResourceError&) override;
- void didFailRedirectCheck() override;
</del><ins>+ void refEventTarget() final { ref(); }
+ void derefEventTarget() final { deref(); }
</ins><span class="cx">
</span><del>- // ActiveDOMObject API.
- void stop() override;
- const char* activeDOMObjectName() const override;
- bool canSuspendForDocumentSuspension() const override;
</del><ins>+ void didReceiveResponse(unsigned long, const ResourceResponse&) final;
+ void didReceiveData(const char*, int) final;
+ void didFinishLoading(unsigned long, double) final;
+ void didFail(const ResourceError&) final;
+ void didFailAccessControlCheck(const ResourceError&) final;
+ void didFailRedirectCheck() final;
</ins><span class="cx">
</span><ins>+ void stop() final;
+ const char* activeDOMObjectName() const final;
+ bool canSuspendForDocumentSuspension() const final;
+
</ins><span class="cx"> void connect();
</span><span class="cx"> void networkRequestEnded();
</span><span class="cx"> void scheduleInitialConnect();
</span><span class="cx"> void scheduleReconnect();
</span><span class="cx"> void abortConnectionAttempt();
</span><span class="cx"> void parseEventStream();
</span><del>- void parseEventStreamLine(unsigned pos, int fieldLength, int lineLength);
- Ref<MessageEvent> createMessageEvent();
</del><ins>+ void parseEventStreamLine(unsigned position, Optional<unsigned> fieldLength, unsigned lineLength);
+ void dispatchMessageEvent();
</ins><span class="cx">
</span><ins>+ bool responseIsValid(const ResourceResponse&) const;
+
+ static const uint64_t defaultReconnectDelay;
+
</ins><span class="cx"> URL m_url;
</span><span class="cx"> bool m_withCredentials;
</span><del>- State m_state;
</del><ins>+ State m_state { CONNECTING };
</ins><span class="cx">
</span><del>- RefPtr<TextResourceDecoder> m_decoder;
</del><ins>+ Ref<TextResourceDecoder> m_decoder;
</ins><span class="cx"> RefPtr<ThreadableLoader> m_loader;
</span><span class="cx"> Timer m_connectTimer;
</span><del>- Vector<UChar> m_receiveBuf;
- bool m_discardTrailingNewline;
- bool m_requestInFlight;
</del><ins>+ Vector<UChar> m_receiveBuffer;
+ bool m_discardTrailingNewline { false };
+ bool m_requestInFlight { false };
</ins><span class="cx">
</span><del>- String m_eventName;
</del><ins>+ AtomicString m_eventName;
</ins><span class="cx"> Vector<UChar> m_data;
</span><span class="cx"> String m_currentlyParsedEventId;
</span><span class="cx"> String m_lastEventId;
</span><del>- unsigned long long m_reconnectDelay;
</del><ins>+ uint64_t m_reconnectDelay { defaultReconnectDelay };
</ins><span class="cx"> String m_eventStreamOrigin;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+inline const String& EventSource::url() const
+{
+ return m_url.string();
+}
+
+inline bool EventSource::withCredentials() const
+{
+ return m_withCredentials;
+}
+
+inline EventSource::State EventSource::readyState() const
+{
+ return m_state;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><del>-
-#endif // EventSource_h
</del></span></pre></div>
<a id="trunkSourceWebCorepageEventSourceidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/EventSource.idl (200557 => 200558)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/EventSource.idl        2016-05-08 18:35:23 UTC (rev 200557)
+++ trunk/Source/WebCore/page/EventSource.idl        2016-05-08 18:46:53 UTC (rev 200558)
</span><span class="lines">@@ -32,11 +32,10 @@
</span><span class="cx"> [
</span><span class="cx"> Exposed=(Window,Worker),
</span><span class="cx"> ActiveDOMObject,
</span><del>- Constructor(DOMString url, optional Dictionary eventSourceInit),
</del><ins>+ Constructor(DOMString url, optional EventSourceInit eventSourceInitDict),
</ins><span class="cx"> ConstructorCallWith=ScriptExecutionContext,
</span><span class="cx"> ConstructorRaisesException,
</span><span class="cx"> ] interface EventSource : EventTarget {
</span><del>-
</del><span class="cx"> readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
</span><span class="cx"> readonly attribute DOMString url;
</span><span class="cx"> readonly attribute boolean withCredentials;
</span><span class="lines">@@ -53,3 +52,7 @@
</span><span class="cx"> attribute EventHandler onerror;
</span><span class="cx"> void close();
</span><span class="cx"> };
</span><ins>+
+dictionary EventSourceInit {
+ boolean withCredentials = false;
+};
</ins></span></pre>
</div>
</div>
</body>
</html>