Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: device/bluetooth/dbus/bluetooth_gatt_manager_client.cc

Issue 1920693002: Complete //device/bt implementation for hosting local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" 5 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "dbus/bus.h" 10 #include "dbus/bus.h"
11 #include "dbus/message.h" 11 #include "dbus/message.h"
12 #include "dbus/object_proxy.h" 12 #include "dbus/object_proxy.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "third_party/cros_system_api/dbus/service_constants.h"
14 14
15 namespace bluez { 15 namespace bluez {
16 16
17 const char BluetoothGattManagerClient::kNoResponseError[] = 17 const char BluetoothGattManagerClient::kNoResponseError[] =
18 "org.chromium.Error.NoResponse"; 18 "org.chromium.Error.NoResponse";
19 19
20 // The BluetoothGattManagerClient implementation used in production. 20 // The BluetoothGattManagerClient implementation used in production.
21 class BluetoothGattManagerClientImpl : public BluetoothGattManagerClient { 21 class BluetoothGattManagerClientImpl : public BluetoothGattManagerClient {
22 public: 22 public:
23 BluetoothGattManagerClientImpl() 23 BluetoothGattManagerClientImpl()
24 : object_proxy_(NULL), weak_ptr_factory_(this) {} 24 : object_proxy_(NULL), weak_ptr_factory_(this) {}
25 25
26 ~BluetoothGattManagerClientImpl() override {} 26 ~BluetoothGattManagerClientImpl() override {}
27 27
28 // BluetoothGattManagerClient override. 28 // BluetoothGattManagerClient override.
29 void RegisterService(const dbus::ObjectPath& service_path, 29 void RegisterApplication(const dbus::ObjectPath& application_path,
30 const Options& options, 30 const Options& options,
31 const base::Closure& callback, 31 const base::Closure& callback,
32 const ErrorCallback& error_callback) override { 32 const ErrorCallback& error_callback) override {
33 dbus::MethodCall method_call( 33 dbus::MethodCall method_call(
34 bluetooth_gatt_manager::kBluetoothGattManagerInterface, 34 bluetooth_gatt_manager::kBluetoothGattManagerInterface,
35 bluetooth_gatt_manager::kRegisterService); 35 bluetooth_gatt_manager::kRegisterService);
36 36
37 dbus::MessageWriter writer(&method_call); 37 dbus::MessageWriter writer(&method_call);
38 writer.AppendObjectPath(service_path); 38 writer.AppendObjectPath(application_path);
39 39
40 // TODO(armansito): The parameters of the Options dictionary are undefined 40 // The parameters of the Options dictionary are undefined but the method
41 // but the method signature still requires a value dictionary. Pass an 41 // signature still requires a value dictionary. Pass an empty dictionary
42 // empty dictionary and fill in the contents later once this is defined. 42 // and fill in the contents later if and when we add any options.
43 dbus::MessageWriter array_writer(NULL); 43 dbus::MessageWriter array_writer(NULL);
44 writer.OpenArray("{sv}", &array_writer); 44 writer.OpenArray("{sv}", &array_writer);
45 writer.CloseContainer(&array_writer); 45 writer.CloseContainer(&array_writer);
46 46
47 DCHECK(object_proxy_); 47 DCHECK(object_proxy_);
48 object_proxy_->CallMethodWithErrorCallback( 48 object_proxy_->CallMethodWithErrorCallback(
49 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 49 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
50 base::Bind(&BluetoothGattManagerClientImpl::OnSuccess, 50 base::Bind(&BluetoothGattManagerClientImpl::OnSuccess,
51 weak_ptr_factory_.GetWeakPtr(), callback), 51 weak_ptr_factory_.GetWeakPtr(), callback),
52 base::Bind(&BluetoothGattManagerClientImpl::OnError, 52 base::Bind(&BluetoothGattManagerClientImpl::OnError,
53 weak_ptr_factory_.GetWeakPtr(), error_callback)); 53 weak_ptr_factory_.GetWeakPtr(), error_callback));
54 } 54 }
55 55
56 // BluetoothGattManagerClient override. 56 // BluetoothGattManagerClient override.
57 void UnregisterService(const dbus::ObjectPath& service_path, 57 void UnregisterApplication(const dbus::ObjectPath& application_path,
58 const base::Closure& callback, 58 const base::Closure& callback,
59 const ErrorCallback& error_callback) override { 59 const ErrorCallback& error_callback) override {
60 dbus::MethodCall method_call( 60 dbus::MethodCall method_call(
61 bluetooth_gatt_manager::kBluetoothGattManagerInterface, 61 bluetooth_gatt_manager::kBluetoothGattManagerInterface,
62 bluetooth_gatt_manager::kUnregisterService); 62 bluetooth_gatt_manager::kUnregisterService);
63 63
64 dbus::MessageWriter writer(&method_call); 64 dbus::MessageWriter writer(&method_call);
65 writer.AppendObjectPath(service_path); 65 writer.AppendObjectPath(application_path);
66 66
67 DCHECK(object_proxy_); 67 DCHECK(object_proxy_);
68 object_proxy_->CallMethodWithErrorCallback( 68 object_proxy_->CallMethodWithErrorCallback(
69 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 69 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
70 base::Bind(&BluetoothGattManagerClientImpl::OnSuccess, 70 base::Bind(&BluetoothGattManagerClientImpl::OnSuccess,
71 weak_ptr_factory_.GetWeakPtr(), callback), 71 weak_ptr_factory_.GetWeakPtr(), callback),
72 base::Bind(&BluetoothGattManagerClientImpl::OnError, 72 base::Bind(&BluetoothGattManagerClientImpl::OnError,
73 weak_ptr_factory_.GetWeakPtr(), error_callback)); 73 weak_ptr_factory_.GetWeakPtr(), error_callback));
74 } 74 }
75 75
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 BluetoothGattManagerClient::BluetoothGattManagerClient() {} 121 BluetoothGattManagerClient::BluetoothGattManagerClient() {}
122 122
123 BluetoothGattManagerClient::~BluetoothGattManagerClient() {} 123 BluetoothGattManagerClient::~BluetoothGattManagerClient() {}
124 124
125 // static 125 // static
126 BluetoothGattManagerClient* BluetoothGattManagerClient::Create() { 126 BluetoothGattManagerClient* BluetoothGattManagerClient::Create() {
127 return new BluetoothGattManagerClientImpl(); 127 return new BluetoothGattManagerClientImpl();
128 } 128 }
129 129
130 } // namespace bluez 130 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/bluetooth_gatt_manager_client.h ('k') | device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698