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 SHILL_DBUS_CHROMEOS_UPSTART_PROXY_H_
18#define SHILL_DBUS_CHROMEOS_UPSTART_PROXY_H_
19
20#include <string>
21#include <vector>
22
23#include <base/macros.h>
24#include <base/memory/ref_counted.h>
25#include <base/memory/weak_ptr.h>
26
27#include "shill/upstart/upstart_proxy_interface.h"
28#include "upstart/dbus-proxies.h"
29
30namespace shill {
31
32class ChromeosUpstartProxy : public UpstartProxyInterface {
33 public:
34  explicit ChromeosUpstartProxy(const scoped_refptr<dbus::Bus>& bus);
35  ~ChromeosUpstartProxy() override = default;
36
37  // Inherited from UpstartProxyInterface.
38  void EmitEvent(const std::string& name,
39                 const std::vector<std::string>& env,
40                 bool wait) override;
41
42 private:
43  // Service path is provided in the xml file and will be populated by the
44  // generator.
45  static const char kServiceName[];
46
47  // Callback for async call to EmitEvent.
48  void OnEmitEventSuccess();
49  void OnEmitEventFailure(brillo::Error* error);
50
51  std::unique_ptr<com::ubuntu::Upstart0_6Proxy> upstart_proxy_;
52
53  base::WeakPtrFactory<ChromeosUpstartProxy> weak_factory_{this};
54  DISALLOW_COPY_AND_ASSIGN(ChromeosUpstartProxy);
55};
56
57}  // namespace shill
58
59#endif  // SHILL_DBUS_CHROMEOS_UPSTART_PROXY_H_
60