• 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 "l2cap/classic/fixed_channel.h"
20 #include "l2cap/classic/fixed_channel_manager.h"
21 #include "l2cap/classic/fixed_channel_service.h"
22 
23 namespace bluetooth {
24 namespace l2cap {
25 namespace classic {
26 namespace internal {
27 
28 class FixedChannelServiceImpl {
29  public:
30   virtual ~FixedChannelServiceImpl() = default;
31 
32   struct PendingRegistration {
33     os::Handler* user_handler_ = nullptr;
34     FixedChannelManager::OnRegistrationCompleteCallback on_registration_complete_callback_;
35     FixedChannelManager::OnConnectionOpenCallback on_connection_open_callback_;
36   };
37 
NotifyChannelCreation(std::unique_ptr<FixedChannel> channel)38   virtual void NotifyChannelCreation(std::unique_ptr<FixedChannel> channel) {
39     user_handler_->Post(common::BindOnce(on_connection_open_callback_, std::move(channel)));
40   }
41 
42   friend class FixedChannelServiceManagerImpl;
43 
44  protected:
45   // protected access for mocking
FixedChannelServiceImpl(os::Handler * user_handler,FixedChannelManager::OnConnectionOpenCallback on_connection_open_callback)46   FixedChannelServiceImpl(os::Handler* user_handler,
47                           FixedChannelManager::OnConnectionOpenCallback on_connection_open_callback)
48       : user_handler_(user_handler), on_connection_open_callback_(std::move(on_connection_open_callback)) {}
49 
50  private:
51   os::Handler* user_handler_ = nullptr;
52   FixedChannelManager::OnConnectionOpenCallback on_connection_open_callback_;
53 };
54 
55 }  // namespace internal
56 }  // namespace classic
57 }  // namespace l2cap
58 }  // namespace bluetooth
59