| 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 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #ifndef EventSource_h | 32 #ifndef EventSource_h |
| 33 #define EventSource_h | 33 #define EventSource_h |
| 34 | 34 |
| 35 #include "bindings/core/v8/ActiveScriptWrappable.h" | 35 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 36 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/SuspendableObject.h" |
| 37 #include "core/events/EventTarget.h" | 37 #include "core/events/EventTarget.h" |
| 38 #include "core/loader/ThreadableLoader.h" | 38 #include "core/loader/ThreadableLoader.h" |
| 39 #include "core/loader/ThreadableLoaderClient.h" | 39 #include "core/loader/ThreadableLoaderClient.h" |
| 40 #include "modules/ModulesExport.h" | 40 #include "modules/ModulesExport.h" |
| 41 #include "modules/eventsource/EventSourceParser.h" | 41 #include "modules/eventsource/EventSourceParser.h" |
| 42 #include "platform/Timer.h" | 42 #include "platform/Timer.h" |
| 43 #include "platform/heap/Handle.h" | 43 #include "platform/heap/Handle.h" |
| 44 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
| 45 #include "wtf/Forward.h" | 45 #include "wtf/Forward.h" |
| 46 #include <memory> | 46 #include <memory> |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 class EventSourceInit; | 50 class EventSourceInit; |
| 51 class ExceptionState; | 51 class ExceptionState; |
| 52 class ResourceResponse; | 52 class ResourceResponse; |
| 53 | 53 |
| 54 class MODULES_EXPORT EventSource final : public EventTargetWithInlineData, | 54 class MODULES_EXPORT EventSource final : public EventTargetWithInlineData, |
| 55 private ThreadableLoaderClient, | 55 private ThreadableLoaderClient, |
| 56 public ActiveScriptWrappable, | 56 public ActiveScriptWrappable, |
| 57 public ActiveDOMObject, | 57 public SuspendableObject, |
| 58 public EventSourceParser::Client { | 58 public EventSourceParser::Client { |
| 59 DEFINE_WRAPPERTYPEINFO(); | 59 DEFINE_WRAPPERTYPEINFO(); |
| 60 USING_GARBAGE_COLLECTED_MIXIN(EventSource); | 60 USING_GARBAGE_COLLECTED_MIXIN(EventSource); |
| 61 | 61 |
| 62 public: | 62 public: |
| 63 static EventSource* create(ExecutionContext*, | 63 static EventSource* create(ExecutionContext*, |
| 64 const String& url, | 64 const String& url, |
| 65 const EventSourceInit&, | 65 const EventSourceInit&, |
| 66 ExceptionState&); | 66 ExceptionState&); |
| 67 ~EventSource() override; | 67 ~EventSource() override; |
| 68 | 68 |
| 69 static const unsigned long long defaultReconnectDelay; | 69 static const unsigned long long defaultReconnectDelay; |
| 70 | 70 |
| 71 String url() const; | 71 String url() const; |
| 72 bool withCredentials() const; | 72 bool withCredentials() const; |
| 73 | 73 |
| 74 enum State : short { kConnecting = 0, kOpen = 1, kClosed = 2 }; | 74 enum State : short { kConnecting = 0, kOpen = 1, kClosed = 2 }; |
| 75 | 75 |
| 76 State readyState() const; | 76 State readyState() const; |
| 77 | 77 |
| 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); | 78 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); |
| 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 81 | 81 |
| 82 void close(); | 82 void close(); |
| 83 | 83 |
| 84 const AtomicString& interfaceName() const override; | 84 const AtomicString& interfaceName() const override; |
| 85 ExecutionContext* getExecutionContext() const override; | 85 ExecutionContext* getExecutionContext() const override; |
| 86 | 86 |
| 87 // ActiveDOMObject | 87 // SuspendableObject |
| 88 // | 88 // |
| 89 // Note: suspend() is noop since ScopedPageLoadDeferrer calls | 89 // Note: suspend() is noop since ScopedPageLoadDeferrer calls |
| 90 // Page::setDefersLoading() and it defers delivery of events from the | 90 // Page::setDefersLoading() and it defers delivery of events from the |
| 91 // loader, and therefore the methods of this class for receiving | 91 // loader, and therefore the methods of this class for receiving |
| 92 // asynchronous events from the loader won't be invoked. | 92 // asynchronous events from the loader won't be invoked. |
| 93 void contextDestroyed() override; | 93 void contextDestroyed() override; |
| 94 | 94 |
| 95 // ScriptWrappable | 95 // ScriptWrappable |
| 96 bool hasPendingActivity() const final; | 96 bool hasPendingActivity() const final; |
| 97 | 97 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 Member<ThreadableLoader> m_loader; | 134 Member<ThreadableLoader> m_loader; |
| 135 Timer<EventSource> m_connectTimer; | 135 Timer<EventSource> m_connectTimer; |
| 136 | 136 |
| 137 unsigned long long m_reconnectDelay; | 137 unsigned long long m_reconnectDelay; |
| 138 String m_eventStreamOrigin; | 138 String m_eventStreamOrigin; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace blink | 141 } // namespace blink |
| 142 | 142 |
| 143 #endif // EventSource_h | 143 #endif // EventSource_h |
| OLD | NEW |