Chromium Code Reviews| Index: chromeos/dbus/fake_shill_third_party_vpn_driver_client.cc |
| 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 0000000000000000000000000000000000000000..1c375381ae64d12016e987a27592576ee2d8e401 |
| --- /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 dbus::ObjectPath& object_path, |
| + ShillThirdPartyVpnObserver* observer) { |
| + if (observer_map_.find(object_path.value()) != observer_map_.end()) { |
| + LOG(ERROR) << "Observer exists."; |
|
stevenjb
2014/10/30 20:55:36
We should either allow this and use VLOG here, or
kaliamoorthi
2014/10/31 11:03:47
Done.
|
| + return; |
| + } |
| + observer_map_[object_path.value()] = observer; |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::RemoveShillThirdPartyVpnObserver( |
| + const dbus::ObjectPath& object_path) { |
| + if (observer_map_.find(object_path.value()) == observer_map_.end()) { |
| + LOG(ERROR) << "Observer does not exist."; |
| + return; |
| + } |
| + observer_map_.erase(object_path.value()); |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::SetParameters( |
| + const dbus::ObjectPath& object_path, |
| + const base::DictionaryValue& parameters, |
| + const VoidDBusMethodCallback& callback) { |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::UpdateConnectionState( |
| + const dbus::ObjectPath& object_path, |
| + const uint32 connection_state, |
| + const VoidDBusMethodCallback& callback) { |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::SendPacket( |
| + const dbus::ObjectPath& object_path, |
| + const std::vector<uint8>& ip_packet, |
| + const VoidDBusMethodCallback& callback) { |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::OnPacketReceived( |
| + const dbus::ObjectPath& object_path, |
| + const uint8* data, |
| + size_t length) { |
| + 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(data, length); |
| +} |
| + |
| +void FakeShillThirdPartyVpnDriverClient::OnPlatformMessage( |
| + const dbus::ObjectPath& object_path, |
| + uint32 connection_state) { |
| + 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(connection_state); |
| +} |
| + |
| +ShillThirdPartyVpnDriverClient::TestInterface* |
| +FakeShillThirdPartyVpnDriverClient::GetTestInterface() { |
| + return this; |
| +} |
| + |
| +} // namespace chromeos |