1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <atomic> 20 #include <string> 21 #include <unordered_map> 22 23 #include "common/bidi_queue.h" 24 #include "common/bind.h" 25 #include "l2cap/cid.h" 26 #include "l2cap/internal/channel_impl.h" 27 #include "l2cap/internal/scheduler.h" 28 #include "l2cap/internal/sender.h" 29 #include "os/handler.h" 30 #include "os/queue.h" 31 32 namespace bluetooth { 33 namespace l2cap { 34 namespace internal { 35 class DataPipelineManager; 36 37 class Fifo : public Scheduler { 38 public: 39 Fifo(DataPipelineManager* data_pipeline_manager, LowerQueueUpEnd* link_queue_up_end, os::Handler* handler); 40 ~Fifo() override; 41 void OnPacketsReady(Cid cid, int number_packets) override; 42 43 private: 44 DataPipelineManager* data_pipeline_manager_; 45 LowerQueueUpEnd* link_queue_up_end_; 46 os::Handler* handler_; 47 std::queue<std::pair<Cid, int>> next_to_dequeue_and_num_packets; 48 std::atomic_bool link_queue_enqueue_registered_ = false; 49 50 void try_register_link_queue_enqueue(); 51 std::unique_ptr<LowerEnqueue> link_queue_enqueue_callback(); 52 }; 53 54 } // namespace internal 55 } // namespace l2cap 56 } // namespace bluetooth 57