diff options
author | Alex Vakulenko <avakulenko@google.com> | 2016-01-04 12:22:05 -0800 |
---|---|---|
committer | Alex Vakulenko <avakulenko@google.com> | 2016-01-04 12:56:27 -0800 |
commit | 08c9891c9c850db7d7fdfcd77d694bcefe836884 (patch) | |
tree | 25b6d64db6b99b1207d0197ae35f17e7f8db9b46 /libbinderwrapper | |
parent | 5b7563a085ef118e19c0f8417d0750d29253dc4f (diff) | |
download | core-08c9891c9c850db7d7fdfcd77d694bcefe836884.tar.gz core-08c9891c9c850db7d7fdfcd77d694bcefe836884.tar.bz2 core-08c9891c9c850db7d7fdfcd77d694bcefe836884.zip |
libbinderwrapper: Add BinderWrapper::GetOrCreateInstance()
In libraries relying on binder it is useful to be able to obtain an
existing copy of BinderWrapper or create one if it doesn't exist.
This allows to abstract the actual RPC (binder) from clients who have
no other dependencies on this RPC.
BUG: 23782171
Change-Id: Ie775d3d8ab83d75e38abc7e1385eb39a363555ef
Diffstat (limited to 'libbinderwrapper')
-rw-r--r-- | libbinderwrapper/binder_wrapper.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libbinderwrapper/binder_wrapper.cc b/libbinderwrapper/binder_wrapper.cc index 0b5ff9612..ca9c1dfd9 100644 --- a/libbinderwrapper/binder_wrapper.cc +++ b/libbinderwrapper/binder_wrapper.cc @@ -50,4 +50,11 @@ BinderWrapper* BinderWrapper::Get() { return instance_; } +// static +BinderWrapper* BinderWrapper::GetOrCreateInstance() { + if (!instance_) + instance_ = new RealBinderWrapper(); + return instance_; +} + } // namespace android |