| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/eventsource/EventSourceParser.h" | 5 #include "modules/eventsource/EventSourceParser.h" |
| 6 | 6 |
| 7 #include "modules/eventsource/EventSource.h" | 7 #include "modules/eventsource/EventSource.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "wtf/text/CharacterNames.h" | 9 #include "wtf/text/CharacterNames.h" |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 USING_GARBAGE_COLLECTED_MIXIN(Client); | 39 USING_GARBAGE_COLLECTED_MIXIN(Client); |
| 40 | 40 |
| 41 public: | 41 public: |
| 42 ~Client() override {} | 42 ~Client() override {} |
| 43 const Vector<EventOrReconnectionTimeSetting>& events() const { | 43 const Vector<EventOrReconnectionTimeSetting>& events() const { |
| 44 return m_events; | 44 return m_events; |
| 45 } | 45 } |
| 46 void onMessageEvent(const AtomicString& event, | 46 void onMessageEvent(const AtomicString& event, |
| 47 const String& data, | 47 const String& data, |
| 48 const AtomicString& id) override { | 48 const AtomicString& id) override { |
| 49 m_events.append(EventOrReconnectionTimeSetting(event, data, id)); | 49 m_events.push_back(EventOrReconnectionTimeSetting(event, data, id)); |
| 50 } | 50 } |
| 51 void onReconnectionTimeSet(unsigned long long reconnectionTime) override { | 51 void onReconnectionTimeSet(unsigned long long reconnectionTime) override { |
| 52 m_events.append(EventOrReconnectionTimeSetting(reconnectionTime)); | 52 m_events.push_back(EventOrReconnectionTimeSetting(reconnectionTime)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 Vector<EventOrReconnectionTimeSetting> m_events; | 56 Vector<EventOrReconnectionTimeSetting> m_events; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class StoppingClient : public GarbageCollectedFinalized<StoppingClient>, | 59 class StoppingClient : public GarbageCollectedFinalized<StoppingClient>, |
| 60 public EventSourceParser::Client { | 60 public EventSourceParser::Client { |
| 61 USING_GARBAGE_COLLECTED_MIXIN(StoppingClient); | 61 USING_GARBAGE_COLLECTED_MIXIN(StoppingClient); |
| 62 | 62 |
| 63 public: | 63 public: |
| 64 ~StoppingClient() override {} | 64 ~StoppingClient() override {} |
| 65 const Vector<EventOrReconnectionTimeSetting>& events() const { | 65 const Vector<EventOrReconnectionTimeSetting>& events() const { |
| 66 return m_events; | 66 return m_events; |
| 67 } | 67 } |
| 68 void setParser(EventSourceParser* parser) { m_parser = parser; } | 68 void setParser(EventSourceParser* parser) { m_parser = parser; } |
| 69 void onMessageEvent(const AtomicString& event, | 69 void onMessageEvent(const AtomicString& event, |
| 70 const String& data, | 70 const String& data, |
| 71 const AtomicString& id) override { | 71 const AtomicString& id) override { |
| 72 m_parser->stop(); | 72 m_parser->stop(); |
| 73 m_events.append(EventOrReconnectionTimeSetting(event, data, id)); | 73 m_events.push_back(EventOrReconnectionTimeSetting(event, data, id)); |
| 74 } | 74 } |
| 75 void onReconnectionTimeSet(unsigned long long reconnectionTime) override { | 75 void onReconnectionTimeSet(unsigned long long reconnectionTime) override { |
| 76 m_events.append(EventOrReconnectionTimeSetting(reconnectionTime)); | 76 m_events.push_back(EventOrReconnectionTimeSetting(reconnectionTime)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 DEFINE_INLINE_VIRTUAL_TRACE() { | 79 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 80 visitor->trace(m_parser); | 80 visitor->trace(m_parser); |
| 81 EventSourceParser::Client::trace(visitor); | 81 EventSourceParser::Client::trace(visitor); |
| 82 } | 82 } |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 Member<EventSourceParser> m_parser; | 85 Member<EventSourceParser> m_parser; |
| 86 Vector<EventOrReconnectionTimeSetting> m_events; | 86 Vector<EventOrReconnectionTimeSetting> m_events; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ASSERT_EQ(1u, events.size()); | 384 ASSERT_EQ(1u, events.size()); |
| 385 ASSERT_EQ(EventOrReconnectionTimeSetting::Type::Event, events[0].type); | 385 ASSERT_EQ(EventOrReconnectionTimeSetting::Type::Event, events[0].type); |
| 386 EXPECT_EQ("message", events[0].event); | 386 EXPECT_EQ("message", events[0].event); |
| 387 EXPECT_EQ("hello", events[0].data); | 387 EXPECT_EQ("hello", events[0].data); |
| 388 EXPECT_EQ("99", parser->lastEventId()); | 388 EXPECT_EQ("99", parser->lastEventId()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace | 391 } // namespace |
| 392 | 392 |
| 393 } // namespace blink | 393 } // namespace blink |
| OLD | NEW |