| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromeos/dbus/fake_shill_third_party_vpn_driver_client.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chromeos/dbus/shill_third_party_vpn_observer.h" |
| 10 #include "dbus/object_proxy.h" |
| 11 |
| 12 namespace chromeos { |
| 13 |
| 14 FakeShillThirdPartyVpnDriverClient::FakeShillThirdPartyVpnDriverClient() { |
| 15 } |
| 16 |
| 17 FakeShillThirdPartyVpnDriverClient::~FakeShillThirdPartyVpnDriverClient() { |
| 18 } |
| 19 |
| 20 void FakeShillThirdPartyVpnDriverClient::Init(dbus::Bus* bus) { |
| 21 } |
| 22 |
| 23 void FakeShillThirdPartyVpnDriverClient::AddShillThirdPartyVpnObserver( |
| 24 const dbus::ObjectPath& object_path, |
| 25 ShillThirdPartyVpnObserver* observer) { |
| 26 if (observer_map_.find(object_path.value()) != observer_map_.end()) { |
| 27 VLOG(2) << "Observer exists."; |
| 28 return; |
| 29 } |
| 30 observer_map_[object_path.value()] = observer; |
| 31 } |
| 32 |
| 33 void FakeShillThirdPartyVpnDriverClient::RemoveShillThirdPartyVpnObserver( |
| 34 const dbus::ObjectPath& object_path) { |
| 35 if (observer_map_.find(object_path.value()) == observer_map_.end()) { |
| 36 VLOG(2) << "Observer does not exist."; |
| 37 return; |
| 38 } |
| 39 observer_map_.erase(object_path.value()); |
| 40 } |
| 41 |
| 42 void FakeShillThirdPartyVpnDriverClient::SetParameters( |
| 43 const dbus::ObjectPath& object_path, |
| 44 const base::DictionaryValue& parameters, |
| 45 const VoidDBusMethodCallback& callback) { |
| 46 base::MessageLoop::current()->PostTask( |
| 47 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| 48 } |
| 49 |
| 50 void FakeShillThirdPartyVpnDriverClient::UpdateConnectionState( |
| 51 const dbus::ObjectPath& object_path, |
| 52 const uint32 connection_state, |
| 53 const VoidDBusMethodCallback& callback) { |
| 54 base::MessageLoop::current()->PostTask( |
| 55 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| 56 } |
| 57 |
| 58 void FakeShillThirdPartyVpnDriverClient::SendPacket( |
| 59 const dbus::ObjectPath& object_path, |
| 60 const std::vector<uint8>& ip_packet, |
| 61 const VoidDBusMethodCallback& callback) { |
| 62 base::MessageLoop::current()->PostTask( |
| 63 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); |
| 64 } |
| 65 |
| 66 void FakeShillThirdPartyVpnDriverClient::OnPacketReceived( |
| 67 const dbus::ObjectPath& object_path, |
| 68 const uint8* data, |
| 69 size_t length) { |
| 70 ObserverMap::iterator it = observer_map_.find(object_path.value()); |
| 71 if (it == observer_map_.end()) { |
| 72 LOG(ERROR) << "Unexpected OnPacketReceived for " << object_path.value(); |
| 73 return; |
| 74 } |
| 75 |
| 76 it->second->OnPacketReceived(data, length); |
| 77 } |
| 78 |
| 79 void FakeShillThirdPartyVpnDriverClient::OnPlatformMessage( |
| 80 const dbus::ObjectPath& object_path, |
| 81 uint32 message) { |
| 82 ObserverMap::iterator it = observer_map_.find(object_path.value()); |
| 83 if (it == observer_map_.end()) { |
| 84 LOG(ERROR) << "Unexpected OnPlatformMessage for " << object_path.value(); |
| 85 return; |
| 86 } |
| 87 |
| 88 it->second->OnPlatformMessage(message); |
| 89 } |
| 90 |
| 91 ShillThirdPartyVpnDriverClient::TestInterface* |
| 92 FakeShillThirdPartyVpnDriverClient::GetTestInterface() { |
| 93 return this; |
| 94 } |
| 95 |
| 96 } // namespace chromeos |
| OLD | NEW |