Fixes bug in html_viewer that could lead to dropping interface requests
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_agent_manager_client.cc
blob1b8decc7c1cac3746342ae681c68ae639308a5fe
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.
5 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
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"
11 namespace chromeos {
13 FakeBluetoothAgentManagerClient::FakeBluetoothAgentManagerClient()
14 : service_provider_(NULL) {
17 FakeBluetoothAgentManagerClient::~FakeBluetoothAgentManagerClient() {
20 void FakeBluetoothAgentManagerClient::Init(dbus::Bus* bus) {
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();
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();
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();
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();
65 void FakeBluetoothAgentManagerClient::RegisterAgentServiceProvider(
66 FakeBluetoothAgentServiceProvider* service_provider) {
67 service_provider_ = service_provider;
70 void FakeBluetoothAgentManagerClient::UnregisterAgentServiceProvider(
71 FakeBluetoothAgentServiceProvider* service_provider) {
72 if (service_provider_ == service_provider)
73 service_provider_ = NULL;
76 FakeBluetoothAgentServiceProvider*
77 FakeBluetoothAgentManagerClient::GetAgentServiceProvider() {
78 return service_provider_;
81 } // namespace chromeos