blob: f6fcf7f8c8e2bdbbb7b62a84c192f83c70e3b3cd [file] [log] [blame]
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -07001/*
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 Zhangf68f5f82019-11-14 13:01:51 -080025#include "l2cap/internal/channel_impl.h"
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070026#include "l2cap/internal/scheduler.h"
Hansong Zhangb0960762019-11-14 17:57:10 -080027#include "l2cap/internal/sender.h"
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070028#include "os/handler.h"
29#include "os/queue.h"
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070030
31namespace bluetooth {
32namespace l2cap {
33namespace internal {
Hansong Zhang90603b32019-11-22 15:11:12 -080034class DataPipelineManager;
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070035
36class Fifo : public Scheduler {
37 public:
Hansong Zhang90603b32019-11-22 15:11:12 -080038 Fifo(DataPipelineManager* data_pipeline_manager, LowerQueueUpEnd* link_queue_up_end, os::Handler* handler);
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070039 ~Fifo() override;
Hansong Zhangb0960762019-11-14 17:57:10 -080040 void OnPacketsReady(Cid cid, int number_packets) override;
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070041
42 private:
Hansong Zhang90603b32019-11-22 15:11:12 -080043 DataPipelineManager* data_pipeline_manager_;
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070044 LowerQueueUpEnd* link_queue_up_end_;
45 os::Handler* handler_;
Hansong Zhang5659d082019-11-13 18:29:42 -080046 std::queue<std::pair<Cid, int>> next_to_dequeue_and_num_packets;
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070047 bool link_queue_enqueue_registered_ = false;
Hansong Zhang90603b32019-11-22 15:11:12 -080048
Hansong Zhang2ea2e8d2019-08-16 15:07:30 -070049 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