proxygen
FizzBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
11 #include <fizz/protocol/Params.h>
12 #include <folly/Overload.h>
13 
14 namespace fizz {
15 
25 template <typename Derived, typename ActionMoveVisitor, typename StateMachine>
26 class FizzBase {
27  public:
29  const typename StateMachine::StateType& state,
30  folly::IOBufQueue& transportReadBuf,
31  ActionMoveVisitor& visitor,
33  : state_(state),
34  transportReadBuf_(transportReadBuf),
35  visitor_(visitor),
36  owner_(owner) {}
37 
42 
47 
51  void earlyAppWrite(EarlyAppWrite appWrite);
52 
56  void appClose();
57 
63  void waitForData();
64 
68  void newTransportData();
69 
77 
81  bool inErrorState() const;
82 
87  bool actionProcessing() const;
88 
94  const;
95 
96  protected:
97  void processActions(typename StateMachine::CompletedActions actions);
98 
99  void addProcessingActions(typename StateMachine::ProcessingActions actions);
100 
101  StateMachine machine_;
102  const typename StateMachine::StateType& state_;
104 
105  private:
106  void processPendingEvents();
107 
108  ActionMoveVisitor& visitor_;
110 
111  using PendingEvent =
112  boost::variant<AppWrite, EarlyAppWrite, AppClose, WriteNewSessionTicket>;
113  std::deque<PendingEvent> pendingEvents_;
114  bool waitForData_{true};
117  bool inErrorState_{false};
118 };
119 } // namespace fizz
120 
boost::variant< AppWrite, EarlyAppWrite, AppClose, WriteNewSessionTicket > PendingEvent
Definition: FizzBase.h:112
FizzBase(const typename StateMachine::StateType &state, folly::IOBufQueue &transportReadBuf, ActionMoveVisitor &visitor, folly::DelayedDestructionBase *owner)
Definition: FizzBase.h:28
bool waitForData_
Definition: FizzBase.h:114
context
Definition: CMakeCache.txt:563
void processActions(typename StateMachine::CompletedActions actions)
Definition: FizzBase-inl.h:87
void moveToErrorState(const folly::AsyncSocketException &ex)
Definition: FizzBase-inl.h:51
ActionMoveVisitor & visitor_
Definition: FizzBase.h:108
void earlyAppWrite(EarlyAppWrite appWrite)
Definition: FizzBase-inl.h:27
Buf getEkm(folly::StringPiece label, const Buf &context, uint16_t length) const
Definition: FizzBase-inl.h:159
folly::DelayedDestructionBase * owner_
Definition: FizzBase.h:109
void processPendingEvents()
Definition: FizzBase-inl.h:115
bool inErrorState() const
Definition: FizzBase-inl.h:76
Definition: Actions.h:16
void waitForData()
Definition: FizzBase-inl.h:40
const StateMachine::StateType & state_
Definition: FizzBase.h:102
std::deque< PendingEvent > pendingEvents_
Definition: FizzBase.h:113
Actions actions(Args &&...act)
Definition: Actions.h:86
void newTransportData()
Definition: FizzBase-inl.h:45
folly::IOBufQueue & transportReadBuf_
Definition: FizzBase.h:103
void addProcessingActions(typename StateMachine::ProcessingActions actions)
Definition: FizzBase-inl.h:102
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
bool inProcessPendingEvents_
Definition: FizzBase.h:116
void appWrite(AppWrite appWrite)
Definition: FizzBase-inl.h:21
StateMachine machine_
Definition: FizzBase.h:101
folly::Optional< folly::DelayedDestruction::DestructorGuard > actionGuard_
Definition: FizzBase.h:115
void writeNewSessionTicket(WriteNewSessionTicket writeNewSessionTicket)
Definition: FizzBase-inl.h:14
bool inErrorState_
Definition: FizzBase.h:117
bool actionProcessing() const
Definition: FizzBase-inl.h:81
state
Definition: http_parser.c:272
StringPiece label