Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40e78443 authored by Kelvin Zhang's avatar Kelvin Zhang
Browse files

Replace usage of base::Callback with std::function

base::Callback comes from libchrome which is undermaintained. Since
C++11 there's standard library support for function objects. Migrate to
a more well knowned solution for function objects.

Test: th
Change-Id: Id19bcd7e92691f57d97520f8f1f4909ca9c25b33
parent db15b6f9
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -26,13 +26,10 @@ cc_defaults {
        "-Werror",
        "-Wno-unused-parameter",

        // for libchrome
        "-Wno-sign-promo",
    ],
    export_include_dirs: ["include"],
    shared_libs: [
        "libbinder",
        "libchrome",
        "libutils",
    ],
}
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

#include <binderwrapper/binder_wrapper.h>

#include <base/logging.h>
#include <android-base/logging.h>

#include "real_binder_wrapper.h"

+1 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#ifndef SYSTEM_CORE_INCLUDE_BINDERWRAPPER_BINDER_TEST_BASE_H_
#define SYSTEM_CORE_INCLUDE_BINDERWRAPPER_BINDER_TEST_BASE_H_

#include <base/macros.h>
#include <gtest/gtest.h>

namespace android {
@@ -37,7 +36,7 @@ class BinderTestBase : public ::testing::Test {
  StubBinderWrapper* binder_wrapper_;  // Not owned.

 private:
  DISALLOW_COPY_AND_ASSIGN(BinderTestBase);
   BinderTestBase(const BinderTestBase&) = delete;
};

}  // namespace android
+3 −4
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@

#include <sys/types.h>

#include <functional>
#include <string>

#include <base/callback.h>
#include <utils/StrongPointer.h>

namespace android {
@@ -68,9 +68,8 @@ class BinderWrapper {

  // Registers |callback| to be invoked when |binder| dies. If another callback
  // is currently registered for |binder|, it will be replaced.
  virtual bool RegisterForDeathNotifications(
      const sp<IBinder>& binder,
      const ::base::Closure& callback) = 0;
  virtual bool RegisterForDeathNotifications(const sp<IBinder>& binder,
                                             const std::function<void()>&) = 0;

  // Unregisters the callback, if any, for |binder|.
  virtual bool UnregisterForDeathNotifications(const sp<IBinder>& binder) = 0;
+3 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <string>
#include <vector>

#include <base/macros.h>
#include <binder/Binder.h>
#include <binder/IBinder.h>
#include <binderwrapper/binder_wrapper.h>
@@ -98,7 +97,7 @@ class StubBinderWrapper : public BinderWrapper {
                       const sp<IBinder>& binder) override;
  sp<BBinder> CreateLocalBinder() override;
  bool RegisterForDeathNotifications(const sp<IBinder>& binder,
                                     const ::base::Closure& callback) override;
                                     const std::function<void()>& callback) override;
  bool UnregisterForDeathNotifications(const sp<IBinder>& binder) override;
  uid_t GetCallingUid() override;
  pid_t GetCallingPid() override;
@@ -119,13 +118,13 @@ class StubBinderWrapper : public BinderWrapper {

  // Map from binder handle to the callback that should be invoked on binder
  // death.
  std::map<sp<IBinder>, ::base::Closure> death_callbacks_;
  std::map<sp<IBinder>, std::function<void()>> death_callbacks_;

  // Values to return from GetCallingUid() and GetCallingPid();
  uid_t calling_uid_;
  pid_t calling_pid_;

  DISALLOW_COPY_AND_ASSIGN(StubBinderWrapper);
  StubBinderWrapper(const StubBinderWrapper&) = delete;
};

}  // namespace android
Loading