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.
5 #include "chromeos/dbus/fake_shill_third_party_vpn_driver_client.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"
14 FakeShillThirdPartyVpnDriverClient::FakeShillThirdPartyVpnDriverClient() {
17 FakeShillThirdPartyVpnDriverClient::~FakeShillThirdPartyVpnDriverClient() {
20 void FakeShillThirdPartyVpnDriverClient::Init(dbus::Bus
* bus
) {
23 void FakeShillThirdPartyVpnDriverClient::AddShillThirdPartyVpnObserver(
24 const std::string
& object_path_value
,
25 ShillThirdPartyVpnObserver
* observer
) {
26 if (observer_map_
.find(object_path_value
) != observer_map_
.end()) {
27 VLOG(2) << "Observer exists.";
30 observer_map_
[object_path_value
] = observer
;
33 void FakeShillThirdPartyVpnDriverClient::RemoveShillThirdPartyVpnObserver(
34 const std::string
& object_path_value
) {
35 if (observer_map_
.find(object_path_value
) == observer_map_
.end()) {
36 VLOG(2) << "Observer does not exist.";
39 observer_map_
.erase(object_path_value
);
42 void FakeShillThirdPartyVpnDriverClient::SetParameters(
43 const std::string
& object_path_value
,
44 const base::DictionaryValue
& parameters
,
45 const ShillClientHelper::StringCallback
& callback
,
46 const ShillClientHelper::ErrorCallback
& error_callback
) {
47 base::MessageLoop::current()->PostTask(FROM_HERE
,
48 base::Bind(callback
, std::string()));
51 void FakeShillThirdPartyVpnDriverClient::UpdateConnectionState(
52 const std::string
& object_path_value
,
53 const uint32_t connection_state
,
54 const base::Closure
& callback
,
55 const ShillClientHelper::ErrorCallback
& error_callback
) {
56 base::MessageLoop::current()->PostTask(FROM_HERE
, callback
);
59 void FakeShillThirdPartyVpnDriverClient::SendPacket(
60 const std::string
& object_path_value
,
61 const std::vector
<char>& ip_packet
,
62 const base::Closure
& callback
,
63 const ShillClientHelper::ErrorCallback
& error_callback
) {
64 base::MessageLoop::current()->PostTask(FROM_HERE
, callback
);
67 void FakeShillThirdPartyVpnDriverClient::OnPacketReceived(
68 const std::string
& object_path_value
,
69 const std::vector
<char>& packet
) {
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
;
76 it
->second
->OnPacketReceived(packet
);
79 void FakeShillThirdPartyVpnDriverClient::OnPlatformMessage(
80 const std::string
& object_path_value
,
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
;
88 it
->second
->OnPlatformMessage(message
);
91 ShillThirdPartyVpnDriverClient::TestInterface
*
92 FakeShillThirdPartyVpnDriverClient::GetTestInterface() {
96 } // namespace chromeos