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 24 matching lines...) Expand all Loading... |
35 #include "bindings/core/v8/ActiveScriptWrappable.h" | 35 #include "bindings/core/v8/ActiveScriptWrappable.h" |
36 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/ActiveDOMObject.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 "core/page/EventSourceParser.h" | 40 #include "core/page/EventSourceParser.h" |
41 #include "platform/Timer.h" | 41 #include "platform/Timer.h" |
42 #include "platform/heap/Handle.h" | 42 #include "platform/heap/Handle.h" |
43 #include "platform/weborigin/KURL.h" | 43 #include "platform/weborigin/KURL.h" |
44 #include "wtf/Forward.h" | 44 #include "wtf/Forward.h" |
45 #include "wtf/OwnPtr.h" | 45 #include <memory> |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 class EventSourceInit; | 49 class EventSourceInit; |
50 class ExceptionState; | 50 class ExceptionState; |
51 class ResourceResponse; | 51 class ResourceResponse; |
52 | 52 |
53 class CORE_EXPORT EventSource final : public EventTargetWithInlineData, private
ThreadableLoaderClient, public ActiveScriptWrappable, public ActiveDOMObject, pu
blic EventSourceParser::Client { | 53 class CORE_EXPORT EventSource final : public EventTargetWithInlineData, private
ThreadableLoaderClient, public ActiveScriptWrappable, public ActiveDOMObject, pu
blic EventSourceParser::Client { |
54 DEFINE_WRAPPERTYPEINFO(); | 54 DEFINE_WRAPPERTYPEINFO(); |
55 USING_GARBAGE_COLLECTED_MIXIN(EventSource); | 55 USING_GARBAGE_COLLECTED_MIXIN(EventSource); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void stop() override; | 88 void stop() override; |
89 | 89 |
90 // ActiveScriptWrappable | 90 // ActiveScriptWrappable |
91 bool hasPendingActivity() const final; | 91 bool hasPendingActivity() const final; |
92 | 92 |
93 DECLARE_VIRTUAL_TRACE(); | 93 DECLARE_VIRTUAL_TRACE(); |
94 | 94 |
95 private: | 95 private: |
96 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); | 96 EventSource(ExecutionContext*, const KURL&, const EventSourceInit&); |
97 | 97 |
98 void didReceiveResponse(unsigned long, const ResourceResponse&, PassOwnPtr<W
ebDataConsumerHandle>) override; | 98 void didReceiveResponse(unsigned long, const ResourceResponse&, std::unique_
ptr<WebDataConsumerHandle>) override; |
99 void didReceiveData(const char*, unsigned) override; | 99 void didReceiveData(const char*, unsigned) override; |
100 void didFinishLoading(unsigned long, double) override; | 100 void didFinishLoading(unsigned long, double) override; |
101 void didFail(const ResourceError&) override; | 101 void didFail(const ResourceError&) override; |
102 void didFailAccessControlCheck(const ResourceError&) override; | 102 void didFailAccessControlCheck(const ResourceError&) override; |
103 void didFailRedirectCheck() override; | 103 void didFailRedirectCheck() override; |
104 | 104 |
105 void onMessageEvent(const AtomicString& event, const String& data, const Ato
micString& id) override; | 105 void onMessageEvent(const AtomicString& event, const String& data, const Ato
micString& id) override; |
106 void onReconnectionTimeSet(unsigned long long reconnectionTime) override; | 106 void onReconnectionTimeSet(unsigned long long reconnectionTime) override; |
107 | 107 |
108 void scheduleInitialConnect(); | 108 void scheduleInitialConnect(); |
109 void connect(); | 109 void connect(); |
110 void networkRequestEnded(); | 110 void networkRequestEnded(); |
111 void scheduleReconnect(); | 111 void scheduleReconnect(); |
112 void connectTimerFired(Timer<EventSource>*); | 112 void connectTimerFired(Timer<EventSource>*); |
113 void abortConnectionAttempt(); | 113 void abortConnectionAttempt(); |
114 | 114 |
115 // The original URL specified when constructing EventSource instance. Used | 115 // The original URL specified when constructing EventSource instance. Used |
116 // for the 'url' attribute getter. | 116 // for the 'url' attribute getter. |
117 const KURL m_url; | 117 const KURL m_url; |
118 // The URL used to connect to the server, which may be different from | 118 // The URL used to connect to the server, which may be different from |
119 // |m_url| as it may be redirected. | 119 // |m_url| as it may be redirected. |
120 KURL m_currentURL; | 120 KURL m_currentURL; |
121 bool m_withCredentials; | 121 bool m_withCredentials; |
122 State m_state; | 122 State m_state; |
123 | 123 |
124 Member<EventSourceParser> m_parser; | 124 Member<EventSourceParser> m_parser; |
125 OwnPtr<ThreadableLoader> m_loader; | 125 std::unique_ptr<ThreadableLoader> m_loader; |
126 Timer<EventSource> m_connectTimer; | 126 Timer<EventSource> m_connectTimer; |
127 | 127 |
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 |