| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 5 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 public: | 23 public: |
| 24 BluetoothAgentManagerClientImpl() : weak_ptr_factory_(this) {} | 24 BluetoothAgentManagerClientImpl() : weak_ptr_factory_(this) {} |
| 25 | 25 |
| 26 virtual ~BluetoothAgentManagerClientImpl() { | 26 virtual ~BluetoothAgentManagerClientImpl() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 // BluetoothAgentManagerClient override. | 29 // BluetoothAgentManagerClient override. |
| 30 virtual void RegisterAgent(const dbus::ObjectPath& agent_path, | 30 virtual void RegisterAgent(const dbus::ObjectPath& agent_path, |
| 31 const std::string& capability, | 31 const std::string& capability, |
| 32 const base::Closure& callback, | 32 const base::Closure& callback, |
| 33 const ErrorCallback& error_callback) OVERRIDE { | 33 const ErrorCallback& error_callback) override { |
| 34 dbus::MethodCall method_call( | 34 dbus::MethodCall method_call( |
| 35 bluetooth_agent_manager::kBluetoothAgentManagerInterface, | 35 bluetooth_agent_manager::kBluetoothAgentManagerInterface, |
| 36 bluetooth_agent_manager::kRegisterAgent); | 36 bluetooth_agent_manager::kRegisterAgent); |
| 37 | 37 |
| 38 dbus::MessageWriter writer(&method_call); | 38 dbus::MessageWriter writer(&method_call); |
| 39 writer.AppendObjectPath(agent_path); | 39 writer.AppendObjectPath(agent_path); |
| 40 writer.AppendString(capability); | 40 writer.AppendString(capability); |
| 41 | 41 |
| 42 object_proxy_->CallMethodWithErrorCallback( | 42 object_proxy_->CallMethodWithErrorCallback( |
| 43 &method_call, | 43 &method_call, |
| 44 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 44 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 45 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, | 45 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, |
| 46 weak_ptr_factory_.GetWeakPtr(), callback), | 46 weak_ptr_factory_.GetWeakPtr(), callback), |
| 47 base::Bind(&BluetoothAgentManagerClientImpl::OnError, | 47 base::Bind(&BluetoothAgentManagerClientImpl::OnError, |
| 48 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 48 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // BluetoothAgentManagerClient override. | 51 // BluetoothAgentManagerClient override. |
| 52 virtual void UnregisterAgent(const dbus::ObjectPath& agent_path, | 52 virtual void UnregisterAgent(const dbus::ObjectPath& agent_path, |
| 53 const base::Closure& callback, | 53 const base::Closure& callback, |
| 54 const ErrorCallback& error_callback) OVERRIDE { | 54 const ErrorCallback& error_callback) override { |
| 55 dbus::MethodCall method_call( | 55 dbus::MethodCall method_call( |
| 56 bluetooth_agent_manager::kBluetoothAgentManagerInterface, | 56 bluetooth_agent_manager::kBluetoothAgentManagerInterface, |
| 57 bluetooth_agent_manager::kUnregisterAgent); | 57 bluetooth_agent_manager::kUnregisterAgent); |
| 58 | 58 |
| 59 dbus::MessageWriter writer(&method_call); | 59 dbus::MessageWriter writer(&method_call); |
| 60 writer.AppendObjectPath(agent_path); | 60 writer.AppendObjectPath(agent_path); |
| 61 | 61 |
| 62 object_proxy_->CallMethodWithErrorCallback( | 62 object_proxy_->CallMethodWithErrorCallback( |
| 63 &method_call, | 63 &method_call, |
| 64 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 64 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 65 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, | 65 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, |
| 66 weak_ptr_factory_.GetWeakPtr(), callback), | 66 weak_ptr_factory_.GetWeakPtr(), callback), |
| 67 base::Bind(&BluetoothAgentManagerClientImpl::OnError, | 67 base::Bind(&BluetoothAgentManagerClientImpl::OnError, |
| 68 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 68 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 // BluetoothAgentManagerClient override. | 72 // BluetoothAgentManagerClient override. |
| 73 virtual void RequestDefaultAgent(const dbus::ObjectPath& agent_path, | 73 virtual void RequestDefaultAgent(const dbus::ObjectPath& agent_path, |
| 74 const base::Closure& callback, | 74 const base::Closure& callback, |
| 75 const ErrorCallback& error_callback) | 75 const ErrorCallback& error_callback) |
| 76 OVERRIDE { | 76 override { |
| 77 dbus::MethodCall method_call( | 77 dbus::MethodCall method_call( |
| 78 bluetooth_agent_manager::kBluetoothAgentManagerInterface, | 78 bluetooth_agent_manager::kBluetoothAgentManagerInterface, |
| 79 bluetooth_agent_manager::kRequestDefaultAgent); | 79 bluetooth_agent_manager::kRequestDefaultAgent); |
| 80 | 80 |
| 81 dbus::MessageWriter writer(&method_call); | 81 dbus::MessageWriter writer(&method_call); |
| 82 writer.AppendObjectPath(agent_path); | 82 writer.AppendObjectPath(agent_path); |
| 83 | 83 |
| 84 object_proxy_->CallMethodWithErrorCallback( | 84 object_proxy_->CallMethodWithErrorCallback( |
| 85 &method_call, | 85 &method_call, |
| 86 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 86 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 87 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, | 87 base::Bind(&BluetoothAgentManagerClientImpl::OnSuccess, |
| 88 weak_ptr_factory_.GetWeakPtr(), callback), | 88 weak_ptr_factory_.GetWeakPtr(), callback), |
| 89 base::Bind(&BluetoothAgentManagerClientImpl::OnError, | 89 base::Bind(&BluetoothAgentManagerClientImpl::OnError, |
| 90 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 90 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 protected: | 93 protected: |
| 94 virtual void Init(dbus::Bus* bus) OVERRIDE { | 94 virtual void Init(dbus::Bus* bus) override { |
| 95 DCHECK(bus); | 95 DCHECK(bus); |
| 96 object_proxy_ = bus->GetObjectProxy( | 96 object_proxy_ = bus->GetObjectProxy( |
| 97 bluetooth_agent_manager::kBluetoothAgentManagerServiceName, | 97 bluetooth_agent_manager::kBluetoothAgentManagerServiceName, |
| 98 dbus::ObjectPath( | 98 dbus::ObjectPath( |
| 99 bluetooth_agent_manager::kBluetoothAgentManagerServicePath)); | 99 bluetooth_agent_manager::kBluetoothAgentManagerServicePath)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 // Called when a response for successful method call is received. | 103 // Called when a response for successful method call is received. |
| 104 void OnSuccess(const base::Closure& callback, | 104 void OnSuccess(const base::Closure& callback, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 BluetoothAgentManagerClient::~BluetoothAgentManagerClient() { | 142 BluetoothAgentManagerClient::~BluetoothAgentManagerClient() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 BluetoothAgentManagerClient* BluetoothAgentManagerClient::Create() { | 145 BluetoothAgentManagerClient* BluetoothAgentManagerClient::Create() { |
| 146 return new BluetoothAgentManagerClientImpl(); | 146 return new BluetoothAgentManagerClientImpl(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace chromeos | 149 } // namespace chromeos |
| OLD | NEW |