blob: b8884fb49eae807f579bee3773e4ae32d5359d56 [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shill/dbus/upstart_proxy.h"
#include <base/bind.h>
#include "shill/logging.h"
namespace shill {
const char UpstartProxy::kUpstartServiceName[] = "com.ubuntu.Upstart";
UpstartProxy::UpstartProxy(const scoped_refptr<dbus::Bus>& bus)
: shill_event_proxy_(
new com::ubuntu::Upstart0_6::JobProxy(bus, kUpstartServiceName)) {}
void UpstartProxy::EmitEvent(const std::string& name,
const std::vector<std::string>& env,
bool wait) {
std::vector<std::string> start_job_env = env;
start_job_env.push_back("EVENT_NAME=" + name);
shill_event_proxy_->StartAsync(
start_job_env, wait, base::Bind([](const dbus::ObjectPath& path) {
VLOG(2) << "Event emitted successful";
}),
base::Bind([](brillo::Error* error) {
LOG(ERROR) << "Failed to emit event: " << error->GetCode() << " "
<< error->GetMessage();
}));
}
} // namespace shill