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