Commit 0ff5362e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from chromeos/.

Also takes advantage of initializer_list for vectors.

Bug: 82078
Change-Id: Ic94d1971254f45fb6ec1925e30622e90f42224ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817414
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699039}
parent 678b92ff
This diff is collapsed.
......@@ -9,8 +9,6 @@
#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
using namespace vm_tools::plugin_dispatcher;
namespace chromeos {
FakeVmPluginDispatcherClient::FakeVmPluginDispatcherClient() = default;
......@@ -26,43 +24,48 @@ void FakeVmPluginDispatcherClient::RemoveObserver(Observer* observer) {
}
void FakeVmPluginDispatcherClient::StartVm(
const StartVmRequest& request,
DBusMethodCallback<StartVmResponse> callback) {
const vm_tools::plugin_dispatcher::StartVmRequest& request,
DBusMethodCallback<vm_tools::plugin_dispatcher::StartVmResponse> callback) {
start_vm_called_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), start_vm_response_));
}
void FakeVmPluginDispatcherClient::ListVms(
const ListVmRequest& request,
DBusMethodCallback<ListVmResponse> callback) {
const vm_tools::plugin_dispatcher::ListVmRequest& request,
DBusMethodCallback<vm_tools::plugin_dispatcher::ListVmResponse> callback) {
list_vms_called_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), list_vms_response_));
}
void FakeVmPluginDispatcherClient::StopVm(
const StopVmRequest& request,
DBusMethodCallback<StopVmResponse> callback) {
const vm_tools::plugin_dispatcher::StopVmRequest& request,
DBusMethodCallback<vm_tools::plugin_dispatcher::StopVmResponse> callback) {
stop_vm_called_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), StopVmResponse()));
FROM_HERE, base::BindOnce(std::move(callback),
vm_tools::plugin_dispatcher::StopVmResponse()));
}
void FakeVmPluginDispatcherClient::SuspendVm(
const SuspendVmRequest& request,
DBusMethodCallback<SuspendVmResponse> callback) {
const vm_tools::plugin_dispatcher::SuspendVmRequest& request,
DBusMethodCallback<vm_tools::plugin_dispatcher::SuspendVmResponse>
callback) {
suspend_vm_called_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), SuspendVmResponse()));
FROM_HERE,
base::BindOnce(std::move(callback),
vm_tools::plugin_dispatcher::SuspendVmResponse()));
}
void FakeVmPluginDispatcherClient::ShowVm(
const ShowVmRequest& request,
DBusMethodCallback<ShowVmResponse> callback) {
const vm_tools::plugin_dispatcher::ShowVmRequest& request,
DBusMethodCallback<vm_tools::plugin_dispatcher::ShowVmResponse> callback) {
show_vm_called_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), ShowVmResponse()));
FROM_HERE, base::BindOnce(std::move(callback),
vm_tools::plugin_dispatcher::ShowVmResponse()));
}
void FakeVmPluginDispatcherClient::WaitForServiceToBeAvailable(
......
......@@ -16,9 +16,9 @@
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "third_party/cros_system_api/dbus/vm_plugin_dispatcher/dbus-constants.h"
namespace chromeos {
namespace dispatcher = vm_tools::plugin_dispatcher;
using namespace vm_tools::plugin_dispatcher;
namespace chromeos {
class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
public:
......@@ -34,29 +34,34 @@ class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
observer_list_.RemoveObserver(observer);
}
void StartVm(const StartVmRequest& request,
DBusMethodCallback<StartVmResponse> callback) override {
CallMethod(kStartVmMethod, request, std::move(callback));
void StartVm(
const dispatcher::StartVmRequest& request,
DBusMethodCallback<dispatcher::StartVmResponse> callback) override {
CallMethod(dispatcher::kStartVmMethod, request, std::move(callback));
}
void ListVms(const ListVmRequest& request,
DBusMethodCallback<ListVmResponse> callback) override {
CallMethod(kListVmsMethod, request, std::move(callback));
void ListVms(
const dispatcher::ListVmRequest& request,
DBusMethodCallback<dispatcher::ListVmResponse> callback) override {
CallMethod(dispatcher::kListVmsMethod, request, std::move(callback));
}
void StopVm(const StopVmRequest& request,
DBusMethodCallback<StopVmResponse> callback) override {
CallMethod(kStopVmMethod, request, std::move(callback));
void StopVm(
const dispatcher::StopVmRequest& request,
DBusMethodCallback<dispatcher::StopVmResponse> callback) override {
CallMethod(dispatcher::kStopVmMethod, request, std::move(callback));
}
void SuspendVm(const SuspendVmRequest& request,
DBusMethodCallback<SuspendVmResponse> callback) override {
CallMethod(kSuspendVmMethod, request, std::move(callback));
void SuspendVm(
const dispatcher::SuspendVmRequest& request,
DBusMethodCallback<dispatcher::SuspendVmResponse> callback) override {
CallMethod(dispatcher::kSuspendVmMethod, request, std::move(callback));
}
void ShowVm(const ShowVmRequest& request,
DBusMethodCallback<ShowVmResponse> callback) override {
CallMethod(kShowVmMethod, request, std::move(callback));
void ShowVm(
const dispatcher::ShowVmRequest& request,
DBusMethodCallback<dispatcher::ShowVmResponse> callback) override {
CallMethod(dispatcher::kShowVmMethod, request, std::move(callback));
}
void WaitForServiceToBeAvailable(
......@@ -68,17 +73,17 @@ class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
protected:
void Init(dbus::Bus* bus) override {
vm_plugin_dispatcher_proxy_ =
bus->GetObjectProxy(kVmPluginDispatcherServiceName,
dbus::ObjectPath(kVmPluginDispatcherServicePath));
vm_plugin_dispatcher_proxy_ = bus->GetObjectProxy(
dispatcher::kVmPluginDispatcherServiceName,
dbus::ObjectPath(dispatcher::kVmPluginDispatcherServicePath));
if (!vm_plugin_dispatcher_proxy_) {
LOG(ERROR) << "Unable to get dbus proxy for "
<< kVmPluginDispatcherServiceName;
<< dispatcher::kVmPluginDispatcherServiceName;
}
vm_plugin_dispatcher_proxy_->ConnectToSignal(
vm_tools::plugin_dispatcher::kVmPluginDispatcherInterface,
vm_tools::plugin_dispatcher::kVmStateChangedSignal,
dispatcher::kVmPluginDispatcherInterface,
dispatcher::kVmStateChangedSignal,
base::BindRepeating(
&VmPluginDispatcherClientImpl::OnVmStateChangedSignal,
weak_ptr_factory_.GetWeakPtr()),
......@@ -91,7 +96,8 @@ class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
void CallMethod(const std::string& method_name,
const RequestProto& request,
DBusMethodCallback<ResponseProto> callback) {
dbus::MethodCall method_call(kVmPluginDispatcherInterface, method_name);
dbus::MethodCall method_call(dispatcher::kVmPluginDispatcherInterface,
method_name);
dbus::MessageWriter writer(&method_call);
if (!writer.AppendProtoAsArrayOfBytes(request)) {
......@@ -126,12 +132,10 @@ class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
}
void OnVmStateChangedSignal(dbus::Signal* signal) {
DCHECK_EQ(signal->GetInterface(),
vm_tools::plugin_dispatcher::kVmPluginDispatcherInterface);
DCHECK_EQ(signal->GetMember(),
vm_tools::plugin_dispatcher::kVmStateChangedSignal);
DCHECK_EQ(signal->GetInterface(), dispatcher::kVmPluginDispatcherInterface);
DCHECK_EQ(signal->GetMember(), dispatcher::kVmStateChangedSignal);
vm_tools::plugin_dispatcher::VmStateChangedSignal vm_state_changed_signal;
dispatcher::VmStateChangedSignal vm_state_changed_signal;
dbus::MessageReader reader(signal);
if (!reader.PopArrayOfBytesAsProto(&vm_state_changed_signal)) {
LOG(ERROR) << "Failed to parse proto from DBus Signal";
......@@ -146,8 +150,7 @@ class VmPluginDispatcherClientImpl : public VmPluginDispatcherClient {
void OnSignalConnected(const std::string& interface_name,
const std::string& signal_name,
bool is_connected) {
DCHECK_EQ(interface_name,
vm_tools::plugin_dispatcher::kVmPluginDispatcherInterface);
DCHECK_EQ(interface_name, dispatcher::kVmPluginDispatcherInterface);
if (!is_connected)
LOG(ERROR) << "Failed to connect to signal: " << signal_name;
}
......
......@@ -45,15 +45,14 @@ void GetClientCertTypeAndDescriptor(onc::ONCSource onc_source,
if (identity)
cert_config->policy_identity = *identity;
using namespace ::onc::client_cert;
const std::string* client_cert_type =
dict_with_client_cert.FindStringKey(kClientCertType);
dict_with_client_cert.FindStringKey(::onc::client_cert::kClientCertType);
if (client_cert_type)
cert_config->client_cert_type = *client_cert_type;
if (cert_config->client_cert_type == kPattern) {
if (cert_config->client_cert_type == ::onc::client_cert::kPattern) {
const base::Value* pattern_value = dict_with_client_cert.FindKeyOfType(
kClientCertPattern, base::Value::Type::DICTIONARY);
::onc::client_cert::kClientCertPattern, base::Value::Type::DICTIONARY);
if (pattern_value) {
base::Optional<OncCertificatePattern> pattern =
OncCertificatePattern::ReadFromONCDictionary(*pattern_value);
......@@ -63,9 +62,9 @@ void GetClientCertTypeAndDescriptor(onc::ONCSource onc_source,
}
cert_config->pattern = pattern.value();
}
} else if (cert_config->client_cert_type == kRef) {
} else if (cert_config->client_cert_type == ::onc::client_cert::kRef) {
const base::Value* client_cert_ref_key =
dict_with_client_cert.FindKeyOfType(kClientCertRef,
dict_with_client_cert.FindKeyOfType(::onc::client_cert::kClientCertRef,
base::Value::Type::STRING);
if (client_cert_ref_key)
cert_config->guid = client_cert_ref_key->GetString();
......@@ -242,18 +241,16 @@ ClientCertConfig::~ClientCertConfig() = default;
void OncToClientCertConfig(::onc::ONCSource onc_source,
const base::DictionaryValue& network_config,
ClientCertConfig* cert_config) {
using namespace ::onc;
*cert_config = ClientCertConfig();
const base::DictionaryValue* dict_with_client_cert = NULL;
const base::DictionaryValue* wifi = NULL;
network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi,
network_config.GetDictionaryWithoutPathExpansion(::onc::network_config::kWiFi,
&wifi);
if (wifi) {
const base::DictionaryValue* eap = NULL;
wifi->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
wifi->GetDictionaryWithoutPathExpansion(::onc::wifi::kEAP, &eap);
if (!eap)
return;
......@@ -262,12 +259,13 @@ void OncToClientCertConfig(::onc::ONCSource onc_source,
}
const base::DictionaryValue* vpn = NULL;
network_config.GetDictionaryWithoutPathExpansion(network_config::kVPN, &vpn);
network_config.GetDictionaryWithoutPathExpansion(::onc::network_config::kVPN,
&vpn);
if (vpn) {
const base::DictionaryValue* openvpn = NULL;
vpn->GetDictionaryWithoutPathExpansion(vpn::kOpenVPN, &openvpn);
vpn->GetDictionaryWithoutPathExpansion(::onc::vpn::kOpenVPN, &openvpn);
const base::DictionaryValue* ipsec = NULL;
vpn->GetDictionaryWithoutPathExpansion(vpn::kIPsec, &ipsec);
vpn->GetDictionaryWithoutPathExpansion(::onc::vpn::kIPsec, &ipsec);
if (openvpn) {
dict_with_client_cert = openvpn;
cert_config->location = CONFIG_TYPE_OPENVPN;
......@@ -280,11 +278,11 @@ void OncToClientCertConfig(::onc::ONCSource onc_source,
}
const base::DictionaryValue* ethernet = NULL;
network_config.GetDictionaryWithoutPathExpansion(network_config::kEthernet,
&ethernet);
network_config.GetDictionaryWithoutPathExpansion(
::onc::network_config::kEthernet, &ethernet);
if (ethernet) {
const base::DictionaryValue* eap = NULL;
ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
ethernet->GetDictionaryWithoutPathExpansion(::onc::wifi::kEAP, &eap);
if (!eap)
return;
dict_with_client_cert = eap;
......
......@@ -93,26 +93,27 @@ bool IsIpConfigTypeStatic(base::Value* network,
} // namespace
void Normalizer::NormalizeCertificate(base::DictionaryValue* cert) {
using namespace ::onc::certificate;
std::string type;
cert->GetStringWithoutPathExpansion(::onc::certificate::kType, &type);
RemoveEntryUnless(cert, kPKCS12, type == kClient);
RemoveEntryUnless(cert, kTrustBits, type == kServer || type == kAuthority);
RemoveEntryUnless(cert, kX509, type == kServer || type == kAuthority);
RemoveEntryUnless(cert, ::onc::certificate::kPKCS12,
type == ::onc::certificate::kClient);
RemoveEntryUnless(cert, ::onc::certificate::kTrustBits,
type == ::onc::certificate::kServer ||
type == ::onc::certificate::kAuthority);
RemoveEntryUnless(cert, ::onc::certificate::kX509,
type == ::onc::certificate::kServer ||
type == ::onc::certificate::kAuthority);
}
void Normalizer::NormalizeEthernet(base::DictionaryValue* ethernet) {
using namespace ::onc::ethernet;
std::string auth;
ethernet->GetStringWithoutPathExpansion(kAuthentication, &auth);
RemoveEntryUnless(ethernet, kEAP, auth == k8021X);
ethernet->GetStringWithoutPathExpansion(::onc::ethernet::kAuthentication,
&auth);
RemoveEntryUnless(ethernet, ::onc::ethernet::kEAP,
auth == ::onc::ethernet::k8021X);
}
void Normalizer::NormalizeEAP(base::DictionaryValue* eap) {
using namespace ::onc::eap;
std::string clientcert_type;
eap->GetStringWithoutPathExpansion(::onc::client_cert::kClientCertType,
&clientcert_type);
......@@ -124,23 +125,27 @@ void Normalizer::NormalizeEAP(base::DictionaryValue* eap) {
clientcert_type == ::onc::client_cert::kRef);
std::string outer;
eap->GetStringWithoutPathExpansion(kOuter, &outer);
RemoveEntryUnless(eap, kAnonymousIdentity,
outer == kPEAP || outer == kEAP_TTLS);
RemoveEntryUnless(eap, kInner,
outer == kPEAP || outer == kEAP_TTLS || outer == kEAP_FAST);
eap->GetStringWithoutPathExpansion(::onc::eap::kOuter, &outer);
RemoveEntryUnless(
eap, ::onc::eap::kAnonymousIdentity,
outer == ::onc::eap::kPEAP || outer == ::onc::eap::kEAP_TTLS);
RemoveEntryUnless(eap, ::onc::eap::kInner,
outer == ::onc::eap::kPEAP ||
outer == ::onc::eap::kEAP_TTLS ||
outer == ::onc::eap::kEAP_FAST);
}
void Normalizer::NormalizeIPsec(base::DictionaryValue* ipsec) {
using namespace ::onc::ipsec;
std::string auth_type;
ipsec->GetStringWithoutPathExpansion(kAuthenticationType, &auth_type);
RemoveEntryUnless(
ipsec, ::onc::client_cert::kClientCertType, auth_type == kCert);
RemoveEntryUnless(ipsec, kServerCARef, auth_type == kCert);
RemoveEntryUnless(ipsec, kPSK, auth_type == kPSK);
RemoveEntryUnless(ipsec, ::onc::vpn::kSaveCredentials, auth_type == kPSK);
ipsec->GetStringWithoutPathExpansion(::onc::ipsec::kAuthenticationType,
&auth_type);
RemoveEntryUnless(ipsec, ::onc::client_cert::kClientCertType,
auth_type == ::onc::ipsec::kCert);
RemoveEntryUnless(ipsec, ::onc::ipsec::kServerCARef,
auth_type == ::onc::ipsec::kCert);
RemoveEntryUnless(ipsec, ::onc::ipsec::kPSK, auth_type == ::onc::ipsec::kPSK);
RemoveEntryUnless(ipsec, ::onc::vpn::kSaveCredentials,
auth_type == ::onc::ipsec::kPSK);
std::string clientcert_type;
ipsec->GetStringWithoutPathExpansion(::onc::client_cert::kClientCertType,
......@@ -153,10 +158,11 @@ void Normalizer::NormalizeIPsec(base::DictionaryValue* ipsec) {
clientcert_type == ::onc::client_cert::kRef);
int ike_version = -1;
ipsec->GetIntegerWithoutPathExpansion(kIKEVersion, &ike_version);
RemoveEntryUnless(ipsec, kEAP, ike_version == 2);
RemoveEntryUnless(ipsec, kGroup, ike_version == 1);
RemoveEntryUnless(ipsec, kXAUTH, ike_version == 1);
ipsec->GetIntegerWithoutPathExpansion(::onc::ipsec::kIKEVersion,
&ike_version);
RemoveEntryUnless(ipsec, ::onc::ipsec::kEAP, ike_version == 2);
RemoveEntryUnless(ipsec, ::onc::ipsec::kGroup, ike_version == 1);
RemoveEntryUnless(ipsec, ::onc::ipsec::kXAUTH, ike_version == 1);
}
void Normalizer::NormalizeNetworkConfiguration(base::DictionaryValue* network) {
......@@ -216,35 +222,38 @@ void Normalizer::NormalizeOpenVPN(base::DictionaryValue* openvpn) {
}
void Normalizer::NormalizeProxySettings(base::DictionaryValue* proxy) {
using namespace ::onc::proxy;
std::string type;
proxy->GetStringWithoutPathExpansion(::onc::proxy::kType, &type);
RemoveEntryUnless(proxy, kManual, type == kManual);
RemoveEntryUnless(proxy, kExcludeDomains, type == kManual);
RemoveEntryUnless(proxy, kPAC, type == kPAC);
RemoveEntryUnless(proxy, ::onc::proxy::kManual,
type == ::onc::proxy::kManual);
RemoveEntryUnless(proxy, ::onc::proxy::kExcludeDomains,
type == ::onc::proxy::kManual);
RemoveEntryUnless(proxy, ::onc::proxy::kPAC, type == ::onc::proxy::kPAC);
}
void Normalizer::NormalizeVPN(base::DictionaryValue* vpn) {
using namespace ::onc::vpn;
std::string type;
vpn->GetStringWithoutPathExpansion(::onc::vpn::kType, &type);
RemoveEntryUnless(vpn, kOpenVPN, type == kOpenVPN);
RemoveEntryUnless(vpn, kIPsec, type == kIPsec || type == kTypeL2TP_IPsec);
RemoveEntryUnless(vpn, kL2TP, type == kTypeL2TP_IPsec);
RemoveEntryUnless(vpn, kThirdPartyVpn, type == kThirdPartyVpn);
RemoveEntryUnless(vpn, kArcVpn, type == kArcVpn);
RemoveEntryUnless(vpn, ::onc::vpn::kOpenVPN, type == ::onc::vpn::kOpenVPN);
RemoveEntryUnless(
vpn, ::onc::vpn::kIPsec,
type == ::onc::vpn::kIPsec || type == ::onc::vpn::kTypeL2TP_IPsec);
RemoveEntryUnless(vpn, ::onc::vpn::kL2TP,
type == ::onc::vpn::kTypeL2TP_IPsec);
RemoveEntryUnless(vpn, ::onc::vpn::kThirdPartyVpn,
type == ::onc::vpn::kThirdPartyVpn);
RemoveEntryUnless(vpn, ::onc::vpn::kArcVpn, type == ::onc::vpn::kArcVpn);
}
void Normalizer::NormalizeWiFi(base::DictionaryValue* wifi) {
using namespace ::onc::wifi;
std::string security;
wifi->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security);
RemoveEntryUnless(wifi, kEAP, security == kWEP_8021X || security == kWPA_EAP);
RemoveEntryUnless(wifi, kPassphrase,
security == kWEP_PSK || security == kWPA_PSK);
RemoveEntryUnless(
wifi, ::onc::wifi::kEAP,
security == ::onc::wifi::kWEP_8021X || security == ::onc::wifi::kWPA_EAP);
RemoveEntryUnless(
wifi, ::onc::wifi::kPassphrase,
security == ::onc::wifi::kWEP_PSK || security == ::onc::wifi::kWPA_PSK);
FillInHexSSIDField(wifi);
}
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment