Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/core/page/EventSourceParser.h

Issue 1642563002: Introduce EventSourceParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@event-source-retry-fix
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef EventSourceParser_h
6 #define EventSourceParser_h
7
8 #include "core/CoreExport.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/Vector.h"
11 #include "wtf/text/AtomicString.h"
12 #include "wtf/text/WTFString.h"
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:43 Forward.h is enough?
yhirano 2016/01/28 08:45:36 I keep the header because I've just added |fromUTF
13
14 namespace blink {
15
16 class CORE_EXPORT EventSourceParser final : public GarbageCollectedFinalized<Eve ntSourceParser> {
17 public:
18 class Client : public GarbageCollectedMixin {
19 public:
20 virtual ~Client() {}
21 virtual void onMessageEvent(const AtomicString& type, const String& data , const AtomicString& lastEventId) = 0;
22 virtual void onReconnectionTimeSet(unsigned long long reconnectionTime) = 0;
23 DEFINE_INLINE_VIRTUAL_TRACE() {}
24 };
25
26 EventSourceParser(const AtomicString& lastEventId, Client* client)
27 : m_id(lastEventId)
28 , m_lastEventId(lastEventId)
29 , m_client(client)
30 {
31 }
32 void addBytes(const char*, size_t);
33 const AtomicString& lastEventId() const { return m_lastEventId; }
34 // Stop parsing. This can be called from Client::onMessageEvent.
35 void stop() { m_isStopped = true; }
36 DECLARE_TRACE();
37
38 private:
39 void parseLine();
40
41 Vector<char> m_line;
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:43 blank line here
yhirano 2016/01/28 08:45:36 Done.
42 AtomicString m_event;
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:43 how about m_eventType?
yhirano 2016/01/28 08:45:36 Done.
43 Vector<char> m_data;
44 // This is used to store the currently processed ID field value.
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:43 as you've chosen not to reset m_id unlike the code
yhirano 2016/01/28 08:45:36 Updated the comment.
45 AtomicString m_id;
46 // This is used to store the last dispatched ID field value.
47 AtomicString m_lastEventId;
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:43 blank line here
yhirano 2016/01/28 08:45:36 Done.
48 Member<Client> m_client;
tyoshino (SeeGerritForStatus) 2016/01/28 07:31:44 blank line here
yhirano 2016/01/28 08:45:36 Done.
49 bool m_isRecognizingCRLF = false;
50 bool m_isRecognizingBOM = true;
51 bool m_isStopped = false;
52 };
53
54 } // namespace blink
55
56 #endif // EventSourceParser_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698