| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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_bluetooth_agent_manager_client.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chromeos/dbus/fake_bluetooth_agent_service_provider.h" | |
| 9 #include "third_party/cros_system_api/dbus/service_constants.h" | |
| 10 | |
| 11 namespace chromeos { | |
| 12 | |
| 13 FakeBluetoothAgentManagerClient::FakeBluetoothAgentManagerClient() | |
| 14 : service_provider_(NULL) { | |
| 15 } | |
| 16 | |
| 17 FakeBluetoothAgentManagerClient::~FakeBluetoothAgentManagerClient() { | |
| 18 } | |
| 19 | |
| 20 void FakeBluetoothAgentManagerClient::Init(dbus::Bus* bus) { | |
| 21 } | |
| 22 | |
| 23 void FakeBluetoothAgentManagerClient::RegisterAgent( | |
| 24 const dbus::ObjectPath& agent_path, | |
| 25 const std::string& capability, | |
| 26 const base::Closure& callback, | |
| 27 const ErrorCallback& error_callback) { | |
| 28 VLOG(1) << "RegisterAgent: " << agent_path.value(); | |
| 29 | |
| 30 if (service_provider_ == NULL) { | |
| 31 error_callback.Run(bluetooth_agent_manager::kErrorInvalidArguments, | |
| 32 "No agent created"); | |
| 33 } else if (service_provider_->object_path_ != agent_path) { | |
| 34 error_callback.Run(bluetooth_agent_manager::kErrorAlreadyExists, | |
| 35 "Agent already registered"); | |
| 36 } else { | |
| 37 callback.Run(); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 void FakeBluetoothAgentManagerClient::UnregisterAgent( | |
| 42 const dbus::ObjectPath& agent_path, | |
| 43 const base::Closure& callback, | |
| 44 const ErrorCallback& error_callback) { | |
| 45 VLOG(1) << "UnregisterAgent: " << agent_path.value(); | |
| 46 if (service_provider_ == NULL) { | |
| 47 error_callback.Run(bluetooth_agent_manager::kErrorDoesNotExist, | |
| 48 "No agent registered"); | |
| 49 } else if (service_provider_->object_path_ != agent_path) { | |
| 50 error_callback.Run(bluetooth_agent_manager::kErrorDoesNotExist, | |
| 51 "Agent still registered"); | |
| 52 } else { | |
| 53 callback.Run(); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 void FakeBluetoothAgentManagerClient::RequestDefaultAgent( | |
| 58 const dbus::ObjectPath& agent_path, | |
| 59 const base::Closure& callback, | |
| 60 const ErrorCallback& error_callback) { | |
| 61 VLOG(1) << "RequestDefaultAgent: " << agent_path.value(); | |
| 62 callback.Run(); | |
| 63 } | |
| 64 | |
| 65 void FakeBluetoothAgentManagerClient::RegisterAgentServiceProvider( | |
| 66 FakeBluetoothAgentServiceProvider* service_provider) { | |
| 67 service_provider_ = service_provider; | |
| 68 } | |
| 69 | |
| 70 void FakeBluetoothAgentManagerClient::UnregisterAgentServiceProvider( | |
| 71 FakeBluetoothAgentServiceProvider* service_provider) { | |
| 72 if (service_provider_ == service_provider) | |
| 73 service_provider_ = NULL; | |
| 74 } | |
| 75 | |
| 76 FakeBluetoothAgentServiceProvider* | |
| 77 FakeBluetoothAgentManagerClient::GetAgentServiceProvider() { | |
| 78 return service_provider_; | |
| 79 } | |
| 80 | |
| 81 } // namespace chromeos | |
| OLD | NEW |