diff options
author | kaliamoorthi <kaliamoorthi@chromium.org> | 2014-11-13 10:51:04 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-13 18:51:21 +0000 |
commit | 4c839047c821a5109fd8b5b828f1ca2082cca07a (patch) | |
tree | b2455d85551c6f71cf9bd7096a8d3e1bd268e5af /chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc | |
parent | 4771655f7a4798c5021772b4275bac5dd298a7c5 (diff) | |
download | chromium_src-4c839047c821a5109fd8b5b828f1ca2082cca07a.zip chromium_src-4c839047c821a5109fd8b5b828f1ca2082cca07a.tar.gz chromium_src-4c839047c821a5109fd8b5b828f1ca2082cca07a.tar.bz2 |
Add new shill client for VPN
This CL adds new shill client for third party vpn dbus interface.
BUG=407541
Review URL: https://codereview.chromium.org/681723003
Cr-Commit-Position: refs/heads/master@{#304054}
Diffstat (limited to 'chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc')
-rw-r--r-- | chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc b/chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc new file mode 100644 index 0000000..e8d370b --- /dev/null +++ b/chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc @@ -0,0 +1,96 @@ +// Copyright 2014 The Chromium 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 "chromeos/dbus/fake_shill_third_party_vpn_driver_client.h" + +#include "base/bind.h" +#include "base/message_loop/message_loop.h" +#include "chromeos/dbus/shill_third_party_vpn_observer.h" +#include "dbus/object_proxy.h" + +namespace chromeos { + +FakeShillThirdPartyVpnDriverClient::FakeShillThirdPartyVpnDriverClient() { +} + +FakeShillThirdPartyVpnDriverClient::~FakeShillThirdPartyVpnDriverClient() { +} + +void FakeShillThirdPartyVpnDriverClient::Init(dbus::Bus* bus) { +} + +void FakeShillThirdPartyVpnDriverClient::AddShillThirdPartyVpnObserver( + const std::string& object_path_value, + ShillThirdPartyVpnObserver* observer) { + if (observer_map_.find(object_path_value) != observer_map_.end()) { + VLOG(2) << "Observer exists."; + return; + } + observer_map_[object_path_value] = observer; +} + +void FakeShillThirdPartyVpnDriverClient::RemoveShillThirdPartyVpnObserver( + const std::string& object_path_value) { + if (observer_map_.find(object_path_value) == observer_map_.end()) { + VLOG(2) << "Observer does not exist."; + return; + } + observer_map_.erase(object_path_value); +} + +void FakeShillThirdPartyVpnDriverClient::SetParameters( + const std::string& object_path_value, + const base::DictionaryValue& parameters, + const base::Closure& callback, + const ShillClientHelper::ErrorCallback& error_callback) { + base::MessageLoop::current()->PostTask(FROM_HERE, callback); +} + +void FakeShillThirdPartyVpnDriverClient::UpdateConnectionState( + const std::string& object_path_value, + const uint32_t connection_state, + const base::Closure& callback, + const ShillClientHelper::ErrorCallback& error_callback) { + base::MessageLoop::current()->PostTask(FROM_HERE, callback); +} + +void FakeShillThirdPartyVpnDriverClient::SendPacket( + const std::string& object_path_value, + const std::string& ip_packet, + const base::Closure& callback, + const ShillClientHelper::ErrorCallback& error_callback) { + base::MessageLoop::current()->PostTask(FROM_HERE, callback); +} + +void FakeShillThirdPartyVpnDriverClient::OnPacketReceived( + const std::string& object_path_value, + const std::string& packet) { + ObserverMap::iterator it = observer_map_.find(object_path_value); + if (it == observer_map_.end()) { + LOG(ERROR) << "Unexpected OnPacketReceived for " << object_path_value; + return; + } + + it->second->OnPacketReceived(reinterpret_cast<const uint8_t*>(packet.data()), + packet.length()); +} + +void FakeShillThirdPartyVpnDriverClient::OnPlatformMessage( + const std::string& object_path_value, + uint32_t message) { + ObserverMap::iterator it = observer_map_.find(object_path_value); + if (it == observer_map_.end()) { + LOG(ERROR) << "Unexpected OnPlatformMessage for " << object_path_value; + return; + } + + it->second->OnPlatformMessage(message); +} + +ShillThirdPartyVpnDriverClient::TestInterface* +FakeShillThirdPartyVpnDriverClient::GetTestInterface() { + return this; +} + +} // namespace chromeos |