1 // Copyright 2019 The Chromium Authors
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 NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_SYSTEM_EVENT_LOOP_IMPL_H_
6 #define NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_SYSTEM_EVENT_LOOP_IMPL_H_
7 
8 #include "base/at_exit.h"
9 #include "base/message_loop/message_pump_type.h"
10 #include "base/run_loop.h"
11 #include "base/task/single_thread_task_executor.h"
12 #include "base/task/thread_pool/thread_pool_instance.h"
13 
14 namespace quiche {
15 
QuicheRunSystemEventLoopIterationImpl()16 inline void QuicheRunSystemEventLoopIterationImpl() {
17   base::RunLoop().RunUntilIdle();
18 }
19 
20 class QuicheSystemEventLoopImpl {
21  public:
QuicheSystemEventLoopImpl(std::string context_name)22   explicit QuicheSystemEventLoopImpl(std::string context_name) {
23     base::ThreadPoolInstance::CreateAndStartWithDefaultParams(context_name);
24   }
25 
26  private:
27   base::SingleThreadTaskExecutor io_task_executor_{base::MessagePumpType::IO};
28   base::AtExitManager exit_manager_;
29 };
30 
31 }  // namespace quiche
32 
33 #endif  // NET_THIRD_PARTY_QUICHE_OVERRIDES_QUICHE_PLATFORM_IMPL_QUICHE_SYSTEM_EVENT_LOOP_IMPL_H_
34