| OLD | NEW |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 { | 110 { |
| 111 ASSERT(m_state == CLOSED); | 111 ASSERT(m_state == CLOSED); |
| 112 ASSERT(!m_requestInFlight); | 112 ASSERT(!m_requestInFlight); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void EventSource::scheduleInitialConnect() | 115 void EventSource::scheduleInitialConnect() |
| 116 { | 116 { |
| 117 ASSERT(m_state == CONNECTING); | 117 ASSERT(m_state == CONNECTING); |
| 118 ASSERT(!m_requestInFlight); | 118 ASSERT(!m_requestInFlight); |
| 119 | 119 |
| 120 m_connectTimer.startOneShot(0); | 120 m_connectTimer.startOneShot(0, FROM_HERE); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void EventSource::connect() | 123 void EventSource::connect() |
| 124 { | 124 { |
| 125 ASSERT(m_state == CONNECTING); | 125 ASSERT(m_state == CONNECTING); |
| 126 ASSERT(!m_requestInFlight); | 126 ASSERT(!m_requestInFlight); |
| 127 | 127 |
| 128 ResourceRequest request(m_url); | 128 ResourceRequest request(m_url); |
| 129 request.setHTTPMethod("GET"); | 129 request.setHTTPMethod("GET"); |
| 130 request.setHTTPHeaderField("Accept", "text/event-stream"); | 130 request.setHTTPHeaderField("Accept", "text/event-stream"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 159 | 159 |
| 160 if (m_state != CLOSED) | 160 if (m_state != CLOSED) |
| 161 scheduleReconnect(); | 161 scheduleReconnect(); |
| 162 else | 162 else |
| 163 unsetPendingActivity(this); | 163 unsetPendingActivity(this); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void EventSource::scheduleReconnect() | 166 void EventSource::scheduleReconnect() |
| 167 { | 167 { |
| 168 m_state = CONNECTING; | 168 m_state = CONNECTING; |
| 169 m_connectTimer.startOneShot(m_reconnectDelay / 1000.0); | 169 m_connectTimer.startOneShot(m_reconnectDelay / 1000.0, FROM_HERE); |
| 170 dispatchEvent(Event::create(EventTypeNames::error)); | 170 dispatchEvent(Event::create(EventTypeNames::error)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void EventSource::connectTimerFired(Timer<EventSource>*) | 173 void EventSource::connectTimerFired(Timer<EventSource>*) |
| 174 { | 174 { |
| 175 connect(); | 175 connect(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 String EventSource::url() const | 178 String EventSource::url() const |
| 179 { | 179 { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 426 |
| 427 PassRefPtr<MessageEvent> EventSource::createMessageEvent() | 427 PassRefPtr<MessageEvent> EventSource::createMessageEvent() |
| 428 { | 428 { |
| 429 RefPtr<MessageEvent> event = MessageEvent::create(); | 429 RefPtr<MessageEvent> event = MessageEvent::create(); |
| 430 event->initMessageEvent(m_eventName.isEmpty() ? EventTypeNames::message : m_
eventName, false, false, SerializedScriptValue::create(String(m_data)), m_eventS
treamOrigin, m_lastEventId, 0, nullptr); | 430 event->initMessageEvent(m_eventName.isEmpty() ? EventTypeNames::message : m_
eventName, false, false, SerializedScriptValue::create(String(m_data)), m_eventS
treamOrigin, m_lastEventId, 0, nullptr); |
| 431 m_data.clear(); | 431 m_data.clear(); |
| 432 return event.release(); | 432 return event.release(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace WebCore | 435 } // namespace WebCore |
| OLD | NEW |