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

Unified Diff: Source/core/page/EventSource.cpp

Issue 60493003: Assertion hit / crash in EventSource::abortConnectionAttempt() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/page/EventSource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventSource.cpp
diff --git a/Source/core/page/EventSource.cpp b/Source/core/page/EventSource.cpp
index 061c4d5d64ccbaa7c9693d62d554114a4796413e..1fd93f6406fc8ecc69fb91c5f6d7250bc258c05e 100644
--- a/Source/core/page/EventSource.cpp
+++ b/Source/core/page/EventSource.cpp
@@ -63,7 +63,7 @@ inline EventSource::EventSource(ExecutionContext* context, const KURL& url, cons
, m_withCredentials(false)
, m_state(CONNECTING)
, m_decoder(TextResourceDecoder::create("text/plain", "UTF-8"))
- , m_reconnectTimer(this, &EventSource::reconnectTimerFired)
+ , m_connectTimer(this, &EventSource::connectTimerFired)
, m_discardTrailingNewline(false)
, m_requestInFlight(false)
, m_reconnectDelay(defaultReconnectDelay)
@@ -100,7 +100,7 @@ PassRefPtr<EventSource> EventSource::create(ExecutionContext* context, const Str
RefPtr<EventSource> source = adoptRef(new EventSource(context, fullURL, eventSourceInit));
source->setPendingActivity(source.get());
- source->connect();
+ source->scheduleInitialConnect();
source->suspendIfNeeded();
return source.release();
@@ -112,6 +112,14 @@ EventSource::~EventSource()
ASSERT(!m_requestInFlight);
}
+void EventSource::scheduleInitialConnect()
+{
+ ASSERT(m_state == CONNECTING);
+ ASSERT(!m_requestInFlight);
+
+ m_connectTimer.startOneShot(0);
+}
+
void EventSource::connect()
{
ASSERT(m_state == CONNECTING);
@@ -159,11 +167,11 @@ void EventSource::networkRequestEnded()
void EventSource::scheduleReconnect()
{
m_state = CONNECTING;
- m_reconnectTimer.startOneShot(m_reconnectDelay / 1000.0);
+ m_connectTimer.startOneShot(m_reconnectDelay / 1000.0);
dispatchEvent(Event::create(EventTypeNames::error));
}
-void EventSource::reconnectTimerFired(Timer<EventSource>*)
+void EventSource::connectTimerFired(Timer<EventSource>*)
{
connect();
}
@@ -191,8 +199,8 @@ void EventSource::close()
}
// Stop trying to reconnect if EventSource was explicitly closed or if ActiveDOMObject::stop() was called.
- if (m_reconnectTimer.isActive()) {
- m_reconnectTimer.stop();
+ if (m_connectTimer.isActive()) {
+ m_connectTimer.stop();
unsetPendingActivity(this);
}
@@ -306,9 +314,13 @@ void EventSource::didFailRedirectCheck()
void EventSource::abortConnectionAttempt()
{
ASSERT(m_state == CONNECTING);
- ASSERT(m_requestInFlight);
- m_loader->cancel();
+ if (m_requestInFlight) {
+ m_loader->cancel();
+ } else {
+ m_state = CLOSED;
+ unsetPendingActivity(this);
+ }
ASSERT(m_state == CLOSED);
dispatchEvent(Event::create(EventTypeNames::error));
« no previous file with comments | « Source/core/page/EventSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698