• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2016 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 SHILL_BINDER_BINDER_ADAPTOR_H_
18 #define SHILL_BINDER_BINDER_ADAPTOR_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <base/macros.h>
24 #include <utils/StrongPointer.h>
25 
26 namespace android {
27 namespace system {
28 namespace connectivity {
29 namespace shill {
30 class IPropertyChangedCallback;
31 }  // shill
32 }  // connectivity
33 }  // system
34 }  // android
35 
36 namespace shill {
37 
38 // Superclass for all Binder-backed Adaptor objects.
39 class BinderAdaptor {
40  public:
41   explicit BinderAdaptor(const std::string& id);
42   ~BinderAdaptor() = default;
43 
44  protected:
45   // Add a IPropertyChangedCallback binder to |property_changed_callbacks_|.
46   // This binder's OnPropertyChanged() method will be invoked when shill
47   // properties change.
48   void AddPropertyChangedSignalHandler(
49       const android::sp<
50           android::system::connectivity::shill::IPropertyChangedCallback>&
51           property_changed_callback);
52 
53   // Signals all registered listeners the shill property |name| has changed by
54   // calling the OnPropertyChanged() method of all IPropertyChangedCallback
55   // binders in |property_changed_callbacks_|.
56   void SendPropertyChangedSignal(const std::string& name);
57 
id()58   const std::string& id() { return id_; }
59 
60  private:
61   // Used to uniquely identify this Binder adaptor.
62   std::string id_;
63 
64   std::vector<android::sp<
65       android::system::connectivity::shill::IPropertyChangedCallback>>
66       property_changed_callbacks_;
67 
68   DISALLOW_COPY_AND_ASSIGN(BinderAdaptor);
69 };
70 
71 }  // namespace shill
72 
73 #endif  // SHILL_BINDER_BINDER_ADAPTOR_H_
74