Index: third_party/WebKit/Source/core/page/EventSource.cpp |
diff --git a/third_party/WebKit/Source/core/page/EventSource.cpp b/third_party/WebKit/Source/core/page/EventSource.cpp |
index ca424e3fb96a7440526b0889d0adf6e768bbb9e4..f02186712e5eddfb079d3f21ce1d42c1d8d8a0b2 100644 |
--- a/third_party/WebKit/Source/core/page/EventSource.cpp |
+++ b/third_party/WebKit/Source/core/page/EventSource.cpp |
@@ -69,7 +69,6 @@ inline EventSource::EventSource(ExecutionContext* context, const KURL& url, cons |
, m_decoder(TextResourceDecoder::create("text/plain", "UTF-8")) |
, m_connectTimer(this, &EventSource::connectTimerFired) |
, m_discardTrailingNewline(false) |
- , m_requestInFlight(false) |
, m_reconnectDelay(defaultReconnectDelay) |
{ |
} |
@@ -104,13 +103,13 @@ EventSource* EventSource::create(ExecutionContext* context, const String& url, c |
EventSource::~EventSource() |
{ |
ASSERT(m_state == CLOSED); |
- ASSERT(!m_requestInFlight); |
+ ASSERT(!m_loader); |
} |
void EventSource::scheduleInitialConnect() |
{ |
ASSERT(m_state == CONNECTING); |
- ASSERT(!m_requestInFlight); |
+ ASSERT(!m_loader); |
m_connectTimer.startOneShot(0, BLINK_FROM_HERE); |
} |
@@ -118,7 +117,7 @@ void EventSource::scheduleInitialConnect() |
void EventSource::connect() |
{ |
ASSERT(m_state == CONNECTING); |
- ASSERT(!m_requestInFlight); |
+ ASSERT(!m_loader); |
ASSERT(executionContext()); |
ExecutionContext& executionContext = *this->executionContext(); |
@@ -149,20 +148,15 @@ void EventSource::connect() |
InspectorInstrumentation::willSendEventSourceRequest(&executionContext, this); |
// InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient will be called synchronously. |
- m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions); |
- |
- if (m_loader) |
- m_requestInFlight = true; |
+ m_loader = ThreadableLoader::create(executionContext, this, options, resourceLoaderOptions); |
+ m_loader->start(request); |
} |
void EventSource::networkRequestEnded() |
{ |
- if (!m_requestInFlight) |
- return; |
- |
InspectorInstrumentation::didFinishEventSourceRequest(executionContext(), this); |
- m_requestInFlight = false; |
+ m_loader = nullptr; |
if (m_state != CLOSED) |
scheduleReconnect(); |
@@ -198,7 +192,7 @@ EventSource::State EventSource::readyState() const |
void EventSource::close() |
{ |
if (m_state == CLOSED) { |
- ASSERT(!m_requestInFlight); |
+ ASSERT(!m_loader); |
return; |
} |
@@ -207,8 +201,10 @@ void EventSource::close() |
m_connectTimer.stop(); |
} |
- if (m_requestInFlight) |
+ if (m_loader) { |
m_loader->cancel(); |
+ m_loader = nullptr; |
+ } |
m_state = CLOSED; |
} |
@@ -227,7 +223,7 @@ void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& resp |
{ |
ASSERT_UNUSED(handle, !handle); |
ASSERT(m_state == CONNECTING); |
- ASSERT(m_requestInFlight); |
+ ASSERT(m_loader); |
m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString(); |
int statusCode = response.httpStatusCode(); |
@@ -269,7 +265,7 @@ void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& resp |
void EventSource::didReceiveData(const char* data, unsigned length) |
{ |
ASSERT(m_state == OPEN); |
- ASSERT(m_requestInFlight); |
+ ASSERT(m_loader); |
append(m_receiveBuf, m_decoder->decode(data, length)); |
parseEventStream(); |
@@ -278,7 +274,7 @@ void EventSource::didReceiveData(const char* data, unsigned length) |
void EventSource::didFinishLoading(unsigned long, double) |
{ |
ASSERT(m_state == OPEN); |
- ASSERT(m_requestInFlight); |
+ ASSERT(m_loader); |
if (m_receiveBuf.size() > 0 || m_data.size() > 0) { |
parseEventStream(); |
@@ -295,7 +291,7 @@ void EventSource::didFinishLoading(unsigned long, double) |
void EventSource::didFail(const ResourceError& error) |
{ |
ASSERT(m_state != CLOSED); |
- ASSERT(m_requestInFlight); |
+ ASSERT(m_loader); |
if (error.isCancellation()) |
m_state = CLOSED; |
@@ -304,6 +300,8 @@ void EventSource::didFail(const ResourceError& error) |
void EventSource::didFailAccessControlCheck(const ResourceError& error) |
{ |
+ ASSERT(m_loader); |
+ |
String message = "EventSource cannot load " + error.failingURL() + ". " + error.localizedDescription(); |
executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
@@ -312,6 +310,8 @@ void EventSource::didFailAccessControlCheck(const ResourceError& error) |
void EventSource::didFailRedirectCheck() |
{ |
+ ASSERT(m_loader); |
+ |
abortConnectionAttempt(); |
} |
@@ -424,13 +424,6 @@ void EventSource::parseEventStreamLine(unsigned bufPos, int fieldLength, int lin |
void EventSource::stop() |
{ |
close(); |
- |
- // (Non)Oilpan: In order to make Worker shutdowns clean, |
- // deref the loader. This will in turn deref its |
- // RefPtr<WorkerGlobalScope>. |
- // |
- // Worth doing regardless, it is no longer of use. |
- m_loader = nullptr; |
hiroshige
2016/01/26 08:44:50
Why do we remove |m_loader = nullptr;|? Is it safe
tyoshino (SeeGerritForStatus)
2016/01/29 12:36:52
I've added this code to close().
|
} |
bool EventSource::hasPendingActivity() const |