blob: 8e281f2f8be166db2179ad89a56789b7c4403f03 [file] [log] [blame]
Daniel Eratbe43a392015-09-08 13:20:02 -06001/*
2 * Copyright (C) 2015 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#ifndef SYSTEM_CORE_LIBBINDERWRAPPER_REAL_BINDER_WRAPPER_H_
18#define SYSTEM_CORE_LIBBINDERWRAPPER_REAL_BINDER_WRAPPER_H_
19
20#include <base/macros.h>
21#include <binderwrapper/binder_wrapper.h>
22
23namespace android {
24
25class IBinder;
26
27// Real implementation of BinderWrapper.
28class RealBinderWrapper : public BinderWrapper {
29 public:
30 RealBinderWrapper();
31 ~RealBinderWrapper() override;
32
33 // BinderWrapper:
34 sp<IBinder> GetService(const std::string& service_name) override;
35 bool RegisterService(const std::string& service_name,
36 const sp<IBinder>& binder) override;
37 sp<BBinder> CreateLocalBinder() override;
38 bool RegisterForDeathNotifications(const sp<IBinder>& binder,
39 const base::Closure& callback) override;
40 bool UnregisterForDeathNotifications(const sp<IBinder>& binder) override;
41
42 private:
43 class DeathRecipient;
44
45 // Map from binder handle to object that should be notified of the binder's
46 // death.
47 std::map<sp<IBinder>, sp<DeathRecipient>> death_recipients_;
48
49 DISALLOW_COPY_AND_ASSIGN(RealBinderWrapper);
50};
51
52} // namespace android
53
54#endif // SYSTEM_CORE_LIBBINDER_WRAPPER_REAL_BINDER_WRAPPER_H_