Home | History | Annotate | Download | only in libbinderwrapper
      1 /*
      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 
     23 namespace android {
     24 
     25 class IBinder;
     26 
     27 // Real implementation of BinderWrapper.
     28 class 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   uid_t GetCallingUid() override;
     42   pid_t GetCallingPid() override;
     43 
     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_
     57