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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.h

Issue 2316353003: arc: bluetooth: Implement set discoverable state (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <unordered_map> 12 #include <unordered_map>
13 #include <unordered_set>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/timer/timer.h"
16 #include "components/arc/arc_bridge_service.h" 18 #include "components/arc/arc_bridge_service.h"
17 #include "components/arc/arc_service.h" 19 #include "components/arc/arc_service.h"
18 #include "components/arc/common/bluetooth.mojom.h" 20 #include "components/arc/common/bluetooth.mojom.h"
19 #include "components/arc/instance_holder.h" 21 #include "components/arc/instance_holder.h"
20 #include "device/bluetooth/bluetooth_adapter.h" 22 #include "device/bluetooth/bluetooth_adapter.h"
21 #include "device/bluetooth/bluetooth_adapter_factory.h" 23 #include "device/bluetooth/bluetooth_adapter_factory.h"
22 #include "device/bluetooth/bluetooth_device.h" 24 #include "device/bluetooth/bluetooth_device.h"
23 #include "device/bluetooth/bluetooth_discovery_session.h" 25 #include "device/bluetooth/bluetooth_discovery_session.h"
24 #include "device/bluetooth/bluetooth_local_gatt_service.h" 26 #include "device/bluetooth/bluetooth_local_gatt_service.h"
25 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 27 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 351
350 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest 352 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest
351 template <class LocalGattAttribute> 353 template <class LocalGattAttribute>
352 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device, 354 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device,
353 const LocalGattAttribute* attribute, 355 const LocalGattAttribute* attribute,
354 const std::vector<uint8_t>& value, 356 const std::vector<uint8_t>& value,
355 int offset, 357 int offset,
356 const base::Closure& success_callback, 358 const base::Closure& success_callback,
357 const ErrorCallback& error_callback); 359 const ErrorCallback& error_callback);
358 360
361 void OnSetDiscoverable(bool discoverable, bool success, uint32_t timeout);
362 void SetDiscoverable(bool discoverable, uint32_t timeout);
363
359 bool CalledOnValidThread(); 364 bool CalledOnValidThread();
360 365
361 mojo::Binding<mojom::BluetoothHost> binding_; 366 mojo::Binding<mojom::BluetoothHost> binding_;
362 367
363 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; 368 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_;
364 scoped_refptr<device::BluetoothAdvertisement> advertisment_; 369 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
365 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 370 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
366 std::unordered_map<std::string, 371 std::unordered_map<std::string,
367 std::unique_ptr<device::BluetoothGattNotifySession>> 372 std::unique_ptr<device::BluetoothGattNotifySession>>
368 notification_session_; 373 notification_session_;
369 // Map from Android int handle to Chrome (BlueZ) string identifier. 374 // Map from Android int handle to Chrome (BlueZ) string identifier.
370 std::unordered_map<int32_t, std::string> gatt_identifier_; 375 std::unordered_map<int32_t, std::string> gatt_identifier_;
371 // Map from Chrome (BlueZ) string identifier to android int handle. 376 // Map from Chrome (BlueZ) string identifier to android int handle.
372 std::unordered_map<std::string, int32_t> gatt_handle_; 377 std::unordered_map<std::string, int32_t> gatt_handle_;
373 // Store last GattCharacteristic added to each GattService for GattServer. 378 // Store last GattCharacteristic added to each GattService for GattServer.
374 std::unordered_map<int32_t, int32_t> last_characteristic_; 379 std::unordered_map<int32_t, int32_t> last_characteristic_;
375 // Monotonically increasing value to use as handle to give to Android side. 380 // Monotonically increasing value to use as handle to give to Android side.
376 int32_t gatt_server_attribute_next_handle_ = 0; 381 int32_t gatt_server_attribute_next_handle_ = 0;
377 // Keeps track of all devices which initiated a GATT connection to us. 382 // Keeps track of all devices which initiated a GATT connection to us.
378 std::unordered_set<std::string> gatt_connection_cache_; 383 std::unordered_set<std::string> gatt_connection_cache_;
384 // Timer to turn adapter discoverable off.
385 base::OneShotTimer discoverable_off_timer_;
379 386
380 base::ThreadChecker thread_checker_; 387 base::ThreadChecker thread_checker_;
381 388
382 // WeakPtrFactory to use for callbacks. 389 // WeakPtrFactory to use for callbacks.
383 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 390 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
384 391
385 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 392 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
386 }; 393 };
387 394
388 } // namespace arc 395 } // namespace arc
389 396
390 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 397 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698