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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class ResourceResponse; | 49 class ResourceResponse; |
50 class TextResourceDecoder; | 50 class TextResourceDecoder; |
51 class ThreadableLoader; | 51 class ThreadableLoader; |
52 | 52 |
53 class EventSource final : public RefCountedGarbageCollectedEventTargetWithInline
Data<EventSource>, private ThreadableLoaderClient, public ActiveDOMObject { | 53 class EventSource final : public RefCountedGarbageCollectedEventTargetWithInline
Data<EventSource>, private ThreadableLoaderClient, public ActiveDOMObject { |
54 DEFINE_WRAPPERTYPEINFO(); | 54 DEFINE_WRAPPERTYPEINFO(); |
55 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(EventSource); | 55 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(EventSource); |
56 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(EventSource); | 56 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(EventSource); |
57 public: | 57 public: |
58 static EventSource* create(ExecutionContext*, const String& url, const Event
SourceInit&, ExceptionState&); | 58 static EventSource* create(ExecutionContext*, const String& url, const Event
SourceInit&, ExceptionState&); |
59 virtual ~EventSource(); | 59 ~EventSource() override; |
60 | 60 |
61 static const unsigned long long defaultReconnectDelay; | 61 static const unsigned long long defaultReconnectDelay; |
62 | 62 |
63 String url() const; | 63 String url() const; |
64 bool withCredentials() const; | 64 bool withCredentials() const; |
65 | 65 |
66 typedef short State; | 66 typedef short State; |
67 static const State CONNECTING = 0; | 67 static const State CONNECTING = 0; |
68 static const State OPEN = 1; | 68 static const State OPEN = 1; |
69 static const State CLOSED = 2; | 69 static const State CLOSED = 2; |
70 | 70 |
71 State readyState() const; | 71 State readyState() const; |
72 | 72 |
73 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); | 73 DEFINE_ATTRIBUTE_EVENT_LISTENER(open); |
74 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 74 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
75 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
76 | 76 |
77 void close(); | 77 void close(); |
78 | 78 |
79 virtual const AtomicString& interfaceName() const override; | 79 const AtomicString& interfaceName() const override; |
80 virtual ExecutionContext* executionContext() const override; | 80 ExecutionContext* executionContext() const override; |
81 | 81 |
82 // ActiveDOMObject | 82 // ActiveDOMObject |
83 // | 83 // |
84 // Note: suspend() is noop since ScopedPageLoadDeferrer calls | 84 // Note: suspend() is noop since ScopedPageLoadDeferrer calls |
85 // Page::setDefersLoading() and it defers delivery of events from the | 85 // Page::setDefersLoading() and it defers delivery of events from the |
86 // loader, and therefore the methods of this class for receiving | 86 // loader, and therefore the methods of this class for receiving |
87 // asynchronous events from the loader won't be invoked. | 87 // asynchronous events from the loader won't be invoked. |
88 virtual void stop() override; | 88 void stop() override; |
89 | 89 |
90 virtual bool hasPendingActivity() const override; | 90 bool hasPendingActivity() const override; |
91 | 91 |
92 DECLARE_VIRTUAL_TRACE(); | 92 DECLARE_VIRTUAL_TRACE(); |
93 | 93 |
94 private: | 94 private: |
95 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); | 95 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); |
96 | 96 |
97 virtual void didReceiveResponse(unsigned long, const ResourceResponse&, Pass
OwnPtr<WebDataConsumerHandle>) override; | 97 void didReceiveResponse(unsigned long, const ResourceResponse&, PassOwnPtr<W
ebDataConsumerHandle>) override; |
98 virtual void didReceiveData(const char*, unsigned) override; | 98 void didReceiveData(const char*, unsigned) override; |
99 virtual void didFinishLoading(unsigned long, double) override; | 99 void didFinishLoading(unsigned long, double) override; |
100 virtual void didFail(const ResourceError&) override; | 100 void didFail(const ResourceError&) override; |
101 virtual void didFailAccessControlCheck(const ResourceError&) override; | 101 void didFailAccessControlCheck(const ResourceError&) override; |
102 virtual void didFailRedirectCheck() override; | 102 void didFailRedirectCheck() override; |
103 | 103 |
104 void scheduleInitialConnect(); | 104 void scheduleInitialConnect(); |
105 void connect(); | 105 void connect(); |
106 void networkRequestEnded(); | 106 void networkRequestEnded(); |
107 void scheduleReconnect(); | 107 void scheduleReconnect(); |
108 void connectTimerFired(Timer<EventSource>*); | 108 void connectTimerFired(Timer<EventSource>*); |
109 void abortConnectionAttempt(); | 109 void abortConnectionAttempt(); |
110 void parseEventStream(); | 110 void parseEventStream(); |
111 void parseEventStreamLine(unsigned pos, int fieldLength, int lineLength); | 111 void parseEventStreamLine(unsigned pos, int fieldLength, int lineLength); |
112 PassRefPtrWillBeRawPtr<MessageEvent> createMessageEvent(); | 112 PassRefPtrWillBeRawPtr<MessageEvent> createMessageEvent(); |
(...skipping 13 matching lines...) Expand all Loading... |
126 Vector<UChar> m_data; | 126 Vector<UChar> m_data; |
127 AtomicString m_currentlyParsedEventId; | 127 AtomicString m_currentlyParsedEventId; |
128 AtomicString m_lastEventId; | 128 AtomicString m_lastEventId; |
129 unsigned long long m_reconnectDelay; | 129 unsigned long long m_reconnectDelay; |
130 String m_eventStreamOrigin; | 130 String m_eventStreamOrigin; |
131 }; | 131 }; |
132 | 132 |
133 } // namespace blink | 133 } // namespace blink |
134 | 134 |
135 #endif // EventSource_h | 135 #endif // EventSource_h |
OLD | NEW |