| 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/SuspendableObject.h" | 36 #include "core/dom/ContextLifecycleObserver.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 | 54 class MODULES_EXPORT EventSource final |
| 55 : public EventTargetWithInlineData, | 55 : public EventTargetWithInlineData, |
| 56 private ThreadableLoaderClient, | 56 private ThreadableLoaderClient, |
| 57 public ActiveScriptWrappable<EventSource>, | 57 public ActiveScriptWrappable<EventSource>, |
| 58 public SuspendableObject, | 58 public ContextLifecycleObserver, |
| 59 public EventSourceParser::Client { | 59 public EventSourceParser::Client { |
| 60 DEFINE_WRAPPERTYPEINFO(); | 60 DEFINE_WRAPPERTYPEINFO(); |
| 61 USING_GARBAGE_COLLECTED_MIXIN(EventSource); | 61 USING_GARBAGE_COLLECTED_MIXIN(EventSource); |
| 62 | 62 |
| 63 public: | 63 public: |
| 64 static EventSource* create(ExecutionContext*, | 64 static EventSource* create(ExecutionContext*, |
| 65 const String& url, | 65 const String& url, |
| 66 const EventSourceInit&, | 66 const EventSourceInit&, |
| 67 ExceptionState&); | 67 ExceptionState&); |
| 68 ~EventSource() override; | 68 ~EventSource() override; |
| 69 | 69 |
| 70 static const unsigned long long defaultReconnectDelay; | 70 static const unsigned long long defaultReconnectDelay; |
| 71 | 71 |
| 72 String url() const; | 72 String url() const; |
| 73 bool withCredentials() const; | 73 bool withCredentials() const; |
| 74 | 74 |
| 75 enum State : short { kConnecting = 0, kOpen = 1, kClosed = 2 }; | 75 enum State : short { kConnecting = 0, kOpen = 1, kClosed = 2 }; |
| 76 | 76 |
| 77 State readyState() const; | 77 State readyState() const; |
| 78 | 78 |
| 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); | 79 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); |
| 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 80 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 81 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 81 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 82 | 82 |
| 83 void close(); | 83 void close(); |
| 84 | 84 |
| 85 const AtomicString& interfaceName() const override; | 85 const AtomicString& interfaceName() const override; |
| 86 ExecutionContext* getExecutionContext() const override; | 86 ExecutionContext* getExecutionContext() const override; |
| 87 | 87 |
| 88 // SuspendableObject | 88 // ContextLifecycleObserver |
| 89 // | 89 // |
| 90 // Note: suspend() is noop since ScopedPageLoadDeferrer calls | 90 // Note: We don't need to inherit from SuspendableObject since |
| 91 // Page::setDefersLoading() and it defers delivery of events from the | 91 // ScopedPageLoadDeferrer calls Page::setDefersLoading() and |
| 92 // loader, and therefore the methods of this class for receiving | 92 // it defers delivery of events from the loader, and therefore |
| 93 // asynchronous events from the loader won't be invoked. | 93 // the methods of this class for receiving asynchronous events |
| 94 // from the loader won't be invoked. |
| 94 void contextDestroyed() override; | 95 void contextDestroyed() override; |
| 95 | 96 |
| 96 // ScriptWrappable | 97 // ScriptWrappable |
| 97 bool hasPendingActivity() const final; | 98 bool hasPendingActivity() const final; |
| 98 | 99 |
| 99 DECLARE_VIRTUAL_TRACE(); | 100 DECLARE_VIRTUAL_TRACE(); |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); | 103 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); |
| 103 | 104 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Member<ThreadableLoader> m_loader; | 136 Member<ThreadableLoader> m_loader; |
| 136 Timer<EventSource> m_connectTimer; | 137 Timer<EventSource> m_connectTimer; |
| 137 | 138 |
| 138 unsigned long long m_reconnectDelay; | 139 unsigned long long m_reconnectDelay; |
| 139 String m_eventStreamOrigin; | 140 String m_eventStreamOrigin; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace blink | 143 } // namespace blink |
| 143 | 144 |
| 144 #endif // EventSource_h | 145 #endif // EventSource_h |
| OLD | NEW |