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