• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string>
20 #include <unordered_map>
21 
22 #include "common/bidi_queue.h"
23 #include "common/bind.h"
24 #include "l2cap/cid.h"
25 #include "l2cap/internal/channel_impl.h"
26 #include "l2cap/internal/scheduler.h"
27 #include "l2cap/internal/sender.h"
28 #include "os/handler.h"
29 #include "os/queue.h"
30 
31 namespace bluetooth {
32 namespace l2cap {
33 namespace internal {
34 class DataPipelineManager;
35 
36 class Fifo : public Scheduler {
37  public:
38   Fifo(DataPipelineManager* data_pipeline_manager, LowerQueueUpEnd* link_queue_up_end, os::Handler* handler);
39   ~Fifo() override;
40   void OnPacketsReady(Cid cid, int number_packets) override;
41 
42  private:
43   DataPipelineManager* data_pipeline_manager_;
44   LowerQueueUpEnd* link_queue_up_end_;
45   os::Handler* handler_;
46   std::queue<std::pair<Cid, int>> next_to_dequeue_and_num_packets;
47   bool link_queue_enqueue_registered_ = false;
48 
49   void try_register_link_queue_enqueue();
50   std::unique_ptr<LowerEnqueue> link_queue_enqueue_callback();
51 };
52 
53 }  // namespace internal
54 }  // namespace l2cap
55 }  // namespace bluetooth
56