OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bluez/bluetooth_advertisement_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_advertisement_bluez.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 ERROR_ADVERTISEMENT_INVALID_LENGTH; | 40 ERROR_ADVERTISEMENT_INVALID_LENGTH; |
41 } else if (error_name == bluetooth_advertising_manager::kErrorDoesNotExist) { | 41 } else if (error_name == bluetooth_advertising_manager::kErrorDoesNotExist) { |
42 return device::BluetoothAdvertisement::ErrorCode:: | 42 return device::BluetoothAdvertisement::ErrorCode:: |
43 ERROR_ADVERTISEMENT_DOES_NOT_EXIST; | 43 ERROR_ADVERTISEMENT_DOES_NOT_EXIST; |
44 } | 44 } |
45 return device::BluetoothAdvertisement::ErrorCode:: | 45 return device::BluetoothAdvertisement::ErrorCode:: |
46 INVALID_ADVERTISEMENT_ERROR_CODE; | 46 INVALID_ADVERTISEMENT_ERROR_CODE; |
47 } | 47 } |
48 | 48 |
49 void RegisterErrorCallbackConnector( | 49 void RegisterErrorCallbackConnector( |
50 const device::BluetoothAdapter::CreateAdvertisementErrorCallback& | 50 const device::BluetoothAdapter::AdvertisementErrorCallback& error_callback, |
51 error_callback, | |
52 const std::string& error_name, | 51 const std::string& error_name, |
53 const std::string& error_message) { | 52 const std::string& error_message) { |
54 LOG(ERROR) << "Error while registering advertisement. error_name = " | 53 LOG(ERROR) << "Error while registering advertisement. error_name = " |
55 << error_name << ", error_message = " << error_message; | 54 << error_name << ", error_message = " << error_message; |
56 error_callback.Run(GetErrorCodeFromErrorStrings(error_name, error_message)); | 55 error_callback.Run(GetErrorCodeFromErrorStrings(error_name, error_message)); |
57 } | 56 } |
58 | 57 |
59 void UnregisterErrorCallbackConnector( | 58 void UnregisterErrorCallbackConnector( |
60 const device::BluetoothAdapter::CreateAdvertisementErrorCallback& | 59 const device::BluetoothAdapter::AdvertisementErrorCallback& error_callback, |
61 error_callback, | |
62 const std::string& error_name, | 60 const std::string& error_name, |
63 const std::string& error_message) { | 61 const std::string& error_message) { |
64 LOG(WARNING) << "Error while unregistering advertisement. error_name = " | 62 LOG(WARNING) << "Error while unregistering advertisement. error_name = " |
65 << error_name << ", error_message = " << error_message; | 63 << error_name << ", error_message = " << error_message; |
66 error_callback.Run(GetErrorCodeFromErrorStrings(error_name, error_message)); | 64 error_callback.Run(GetErrorCodeFromErrorStrings(error_name, error_message)); |
67 } | 65 } |
68 | 66 |
69 } // namespace | 67 } // namespace |
70 | 68 |
71 namespace bluez { | 69 namespace bluez { |
(...skipping 16 matching lines...) Expand all Loading... |
88 this, | 86 this, |
89 static_cast< | 87 static_cast< |
90 bluez::BluetoothLEAdvertisementServiceProvider::AdvertisementType>( | 88 bluez::BluetoothLEAdvertisementServiceProvider::AdvertisementType>( |
91 data->type()), | 89 data->type()), |
92 data->service_uuids(), data->manufacturer_data(), data->solicit_uuids(), | 90 data->service_uuids(), data->manufacturer_data(), data->solicit_uuids(), |
93 data->service_data()); | 91 data->service_data()); |
94 } | 92 } |
95 | 93 |
96 void BluetoothAdvertisementBlueZ::Register( | 94 void BluetoothAdvertisementBlueZ::Register( |
97 const base::Closure& success_callback, | 95 const base::Closure& success_callback, |
98 const device::BluetoothAdapter::CreateAdvertisementErrorCallback& | 96 const device::BluetoothAdapter::AdvertisementErrorCallback& |
99 error_callback) { | 97 error_callback) { |
100 DCHECK(bluez::BluezDBusManager::Get()); | 98 DCHECK(bluez::BluezDBusManager::Get()); |
101 bluez::BluezDBusManager::Get() | 99 bluez::BluezDBusManager::Get() |
102 ->GetBluetoothLEAdvertisingManagerClient() | 100 ->GetBluetoothLEAdvertisingManagerClient() |
103 ->RegisterAdvertisement( | 101 ->RegisterAdvertisement( |
104 adapter_->object_path(), provider_->object_path(), success_callback, | 102 adapter_->object_path(), provider_->object_path(), success_callback, |
105 base::Bind(&RegisterErrorCallbackConnector, error_callback)); | 103 base::Bind(&RegisterErrorCallbackConnector, error_callback)); |
106 } | 104 } |
107 | 105 |
108 BluetoothAdvertisementBlueZ::~BluetoothAdvertisementBlueZ() { | 106 BluetoothAdvertisementBlueZ::~BluetoothAdvertisementBlueZ() { |
(...skipping 21 matching lines...) Expand all Loading... |
130 } | 128 } |
131 | 129 |
132 void BluetoothAdvertisementBlueZ::Released() { | 130 void BluetoothAdvertisementBlueZ::Released() { |
133 LOG(WARNING) << "Advertisement released."; | 131 LOG(WARNING) << "Advertisement released."; |
134 provider_.reset(); | 132 provider_.reset(); |
135 FOR_EACH_OBSERVER(BluetoothAdvertisement::Observer, observers_, | 133 FOR_EACH_OBSERVER(BluetoothAdvertisement::Observer, observers_, |
136 AdvertisementReleased(this)); | 134 AdvertisementReleased(this)); |
137 } | 135 } |
138 | 136 |
139 } // namespace bluez | 137 } // namespace bluez |
OLD | NEW |