blob: 4709795fa9615e0203ac1f9baf2acd3ee1512489 [file] [log] [blame]
Peter Qiu326b6cf2015-09-02 11:11:42 -07001//
2// Copyright (C) 2014 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//
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080016
Peter Qiu2a6fb332015-09-17 22:19:17 -070017#ifndef APMANAGER_SHILL_MANAGER_H_
18#define APMANAGER_SHILL_MANAGER_H_
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080019
20#include <set>
21#include <string>
22
23#include <base/macros.h>
Peter Qiu37328b82015-09-18 09:28:18 -070024#include <base/memory/ref_counted.h>
25#include <base/memory/weak_ptr.h>
26#include <dbus/bus.h>
27
28#include "apmanager/shill_proxy_interface.h"
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080029
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080030namespace apmanager {
31
Peter Qiu2a6fb332015-09-17 22:19:17 -070032class ShillManager {
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080033 public:
Peter Qiu2a6fb332015-09-17 22:19:17 -070034 ShillManager();
35 virtual ~ShillManager();
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080036
Peter Qiuc9ce1f12014-12-05 11:14:29 -080037 void Init(const scoped_refptr<dbus::Bus>& bus);
38
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080039 // Claim the given interface |interface_name| from shill.
40 virtual void ClaimInterface(const std::string& interface_name);
41 // Release the given interface |interface_name| to shill.
42 virtual void ReleaseInterface(const std::string& interface_name);
43
44 private:
Peter Qiu37328b82015-09-18 09:28:18 -070045 void OnShillServiceAppeared();
46 void OnShillServiceVanished();
Peter Qiu267fff32014-12-10 14:01:58 -080047
Peter Qiu37328b82015-09-18 09:28:18 -070048 std::unique_ptr<ShillProxyInterface> shill_proxy_;
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080049 // List of interfaces apmanager have claimed.
50 std::set<std::string> claimed_interfaces_;
51
Peter Qiu37328b82015-09-18 09:28:18 -070052 base::WeakPtrFactory<ShillManager> weak_factory_{this};
Peter Qiu2a6fb332015-09-17 22:19:17 -070053 DISALLOW_COPY_AND_ASSIGN(ShillManager);
Peter Qiu7e0ffcf2014-12-02 12:53:27 -080054};
55
56} // namespace apmanager
57
Peter Qiu2a6fb332015-09-17 22:19:17 -070058#endif // APMANAGER_SHILL_MANAGER_H_