blob: ea0837171b1934a79d2fe020b559ba14f40e691d [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;
Daniel Erat7cba9db2015-10-16 09:04:33 -060041 uid_t GetCallingUid() override;
42 pid_t GetCallingPid() override;
Daniel Eratbe43a392015-09-08 13:20:02 -060043
44 private:
45 class DeathRecipient;
46
47 // Map from binder handle to object that should be notified of the binder's
48 // death.
49 std::map<sp<IBinder>, sp<DeathRecipient>> death_recipients_;
50
51 DISALLOW_COPY_AND_ASSIGN(RealBinderWrapper);
52};
53
54} // namespace android
55
56#endif // SYSTEM_CORE_LIBBINDER_WRAPPER_REAL_BINDER_WRAPPER_H_