Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 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" |
Hansong Zhang | f68f5f8 | 2019-11-14 13:01:51 -0800 | [diff] [blame] | 25 | #include "l2cap/internal/channel_impl.h" |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 26 | #include "l2cap/internal/scheduler.h" |
Hansong Zhang | b096076 | 2019-11-14 17:57:10 -0800 | [diff] [blame] | 27 | #include "l2cap/internal/sender.h" |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 28 | #include "os/handler.h" |
| 29 | #include "os/queue.h" |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 30 | |
| 31 | namespace bluetooth { |
| 32 | namespace l2cap { |
| 33 | namespace internal { |
Hansong Zhang | 90603b3 | 2019-11-22 15:11:12 -0800 | [diff] [blame] | 34 | class DataPipelineManager; |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 35 | |
| 36 | class Fifo : public Scheduler { |
| 37 | public: |
Hansong Zhang | 90603b3 | 2019-11-22 15:11:12 -0800 | [diff] [blame] | 38 | Fifo(DataPipelineManager* data_pipeline_manager, LowerQueueUpEnd* link_queue_up_end, os::Handler* handler); |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 39 | ~Fifo() override; |
Hansong Zhang | b096076 | 2019-11-14 17:57:10 -0800 | [diff] [blame] | 40 | void OnPacketsReady(Cid cid, int number_packets) override; |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 41 | |
| 42 | private: |
Hansong Zhang | 90603b3 | 2019-11-22 15:11:12 -0800 | [diff] [blame] | 43 | DataPipelineManager* data_pipeline_manager_; |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 44 | LowerQueueUpEnd* link_queue_up_end_; |
| 45 | os::Handler* handler_; |
Hansong Zhang | 5659d08 | 2019-11-13 18:29:42 -0800 | [diff] [blame] | 46 | std::queue<std::pair<Cid, int>> next_to_dequeue_and_num_packets; |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 47 | bool link_queue_enqueue_registered_ = false; |
Hansong Zhang | 90603b3 | 2019-11-22 15:11:12 -0800 | [diff] [blame] | 48 | |
Hansong Zhang | 2ea2e8d | 2019-08-16 15:07:30 -0700 | [diff] [blame] | 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 |