| 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/dbus/bluetooth_le_advertisement_service_provider.h" | 5 #include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.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 "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/stl_util.h" | |
| 11 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 12 #include "dbus/exported_object.h" | 11 #include "dbus/exported_object.h" |
| 13 #include "dbus/message.h" | 12 #include "dbus/message.h" |
| 14 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 13 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 15 #include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider
.h" | 14 #include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider
.h" |
| 16 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 17 | 16 |
| 18 namespace bluez { | 17 namespace bluez { |
| 19 | 18 |
| 20 namespace { | 19 namespace { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 void AppendManufacturerDataVariant(dbus::MessageWriter* writer) { | 330 void AppendManufacturerDataVariant(dbus::MessageWriter* writer) { |
| 332 DCHECK(manufacturer_data_); | 331 DCHECK(manufacturer_data_); |
| 333 dbus::MessageWriter array_writer(NULL); | 332 dbus::MessageWriter array_writer(NULL); |
| 334 writer->OpenArray("{qay}", &array_writer); | 333 writer->OpenArray("{qay}", &array_writer); |
| 335 for (const auto& m : *manufacturer_data_) { | 334 for (const auto& m : *manufacturer_data_) { |
| 336 dbus::MessageWriter entry_writer(NULL); | 335 dbus::MessageWriter entry_writer(NULL); |
| 337 | 336 |
| 338 array_writer.OpenDictEntry(&entry_writer); | 337 array_writer.OpenDictEntry(&entry_writer); |
| 339 | 338 |
| 340 entry_writer.AppendUint32(m.first); | 339 entry_writer.AppendUint32(m.first); |
| 341 entry_writer.AppendArrayOfBytes(vector_as_array(&m.second), | 340 entry_writer.AppendArrayOfBytes(m.second.data(), m.second.size()); |
| 342 m.second.size()); | |
| 343 | 341 |
| 344 array_writer.CloseContainer(&entry_writer); | 342 array_writer.CloseContainer(&entry_writer); |
| 345 } | 343 } |
| 346 writer->CloseContainer(&array_writer); | 344 writer->CloseContainer(&array_writer); |
| 347 } | 345 } |
| 348 | 346 |
| 349 void AppendServiceDataVariant(dbus::MessageWriter* writer) { | 347 void AppendServiceDataVariant(dbus::MessageWriter* writer) { |
| 350 DCHECK(service_data_); | 348 DCHECK(service_data_); |
| 351 dbus::MessageWriter array_writer(NULL); | 349 dbus::MessageWriter array_writer(NULL); |
| 352 writer->OpenArray("{say}", &array_writer); | 350 writer->OpenArray("{say}", &array_writer); |
| 353 for (const auto& m : *service_data_) { | 351 for (const auto& m : *service_data_) { |
| 354 dbus::MessageWriter entry_writer(NULL); | 352 dbus::MessageWriter entry_writer(NULL); |
| 355 | 353 |
| 356 array_writer.OpenDictEntry(&entry_writer); | 354 array_writer.OpenDictEntry(&entry_writer); |
| 357 | 355 |
| 358 entry_writer.AppendString(m.first); | 356 entry_writer.AppendString(m.first); |
| 359 entry_writer.AppendArrayOfBytes(vector_as_array(&m.second), | 357 entry_writer.AppendArrayOfBytes(m.second.data(), m.second.size()); |
| 360 m.second.size()); | |
| 361 | 358 |
| 362 array_writer.CloseContainer(&entry_writer); | 359 array_writer.CloseContainer(&entry_writer); |
| 363 } | 360 } |
| 364 writer->CloseContainer(&array_writer); | 361 writer->CloseContainer(&array_writer); |
| 365 } | 362 } |
| 366 | 363 |
| 367 // Origin thread (i.e. the UI thread in production). | 364 // Origin thread (i.e. the UI thread in production). |
| 368 base::PlatformThreadId origin_thread_id_; | 365 base::PlatformThreadId origin_thread_id_; |
| 369 | 366 |
| 370 // D-Bus bus object is exported on, not owned by this object and must | 367 // D-Bus bus object is exported on, not owned by this object and must |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl( | 414 return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl( |
| 418 bus, object_path, delegate, type, service_uuids.Pass(), | 415 bus, object_path, delegate, type, service_uuids.Pass(), |
| 419 manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass())); | 416 manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass())); |
| 420 } else { | 417 } else { |
| 421 return make_scoped_ptr( | 418 return make_scoped_ptr( |
| 422 new FakeBluetoothLEAdvertisementServiceProvider(object_path, delegate)); | 419 new FakeBluetoothLEAdvertisementServiceProvider(object_path, delegate)); |
| 423 } | 420 } |
| 424 } | 421 } |
| 425 | 422 |
| 426 } // namespace bluez | 423 } // namespace bluez |
| OLD | NEW |