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 <unordered_map> 20 21 #include "l2cap/le/dynamic_channel_service.h" 22 #include "l2cap/le/internal/dynamic_channel_service_impl.h" 23 #include "l2cap/psm.h" 24 #include "os/handler.h" 25 26 namespace bluetooth { 27 namespace l2cap { 28 namespace le { 29 namespace internal { 30 31 class DynamicChannelServiceManagerImpl { 32 public: DynamicChannelServiceManagerImpl(os::Handler * l2cap_layer_handler)33 explicit DynamicChannelServiceManagerImpl(os::Handler* l2cap_layer_handler) 34 : l2cap_layer_handler_(l2cap_layer_handler) {} 35 36 virtual ~DynamicChannelServiceManagerImpl() = default; 37 // 38 // All APIs must be invoked in L2CAP layer handler 39 // 40 virtual void Register(Psm psm, DynamicChannelServiceImpl::PendingRegistration pending_registration); 41 virtual void Unregister(Psm psm, DynamicChannelService::OnUnregisteredCallback callback, os::Handler* handler); 42 virtual bool IsServiceRegistered(Psm psm) const; 43 virtual DynamicChannelServiceImpl* GetService(Psm psm); 44 45 virtual std::vector<std::pair<Psm, DynamicChannelServiceImpl*>> GetRegisteredServices(); 46 47 private: 48 os::Handler* l2cap_layer_handler_ = nullptr; 49 std::unordered_map<Psm, DynamicChannelServiceImpl> service_map_; 50 }; 51 } // namespace internal 52 } // namespace le 53 } // namespace l2cap 54 } // namespace bluetooth 55