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

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

Issue 2324463004: 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 355
354 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest 356 // Common code for OnCharacteristicWriteRequest and OnDescriptorWriteRequest
355 template <class LocalGattAttribute> 357 template <class LocalGattAttribute>
356 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device, 358 void OnGattAttributeWriteRequest(const device::BluetoothDevice* device,
357 const LocalGattAttribute* attribute, 359 const LocalGattAttribute* attribute,
358 const std::vector<uint8_t>& value, 360 const std::vector<uint8_t>& value,
359 int offset, 361 int offset,
360 const base::Closure& success_callback, 362 const base::Closure& success_callback,
361 const ErrorCallback& error_callback); 363 const ErrorCallback& error_callback);
362 364
365 void OnSetDiscoverable(bool discoverable, bool success, uint32_t timeout);
366 void SetDiscoverable(bool discoverable, uint32_t timeout);
367
363 bool CalledOnValidThread(); 368 bool CalledOnValidThread();
364 369
365 mojo::Binding<mojom::BluetoothHost> binding_; 370 mojo::Binding<mojom::BluetoothHost> binding_;
366 371
367 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; 372 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_;
368 scoped_refptr<device::BluetoothAdvertisement> advertisment_; 373 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
369 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 374 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
370 std::unordered_map<std::string, 375 std::unordered_map<std::string,
371 std::unique_ptr<device::BluetoothGattNotifySession>> 376 std::unique_ptr<device::BluetoothGattNotifySession>>
372 notification_session_; 377 notification_session_;
373 // Map from Android int handle to Chrome (BlueZ) string identifier. 378 // Map from Android int handle to Chrome (BlueZ) string identifier.
374 std::unordered_map<int32_t, std::string> gatt_identifier_; 379 std::unordered_map<int32_t, std::string> gatt_identifier_;
375 // Map from Chrome (BlueZ) string identifier to android int handle. 380 // Map from Chrome (BlueZ) string identifier to android int handle.
376 std::unordered_map<std::string, int32_t> gatt_handle_; 381 std::unordered_map<std::string, int32_t> gatt_handle_;
377 // Store last GattCharacteristic added to each GattService for GattServer. 382 // Store last GattCharacteristic added to each GattService for GattServer.
378 std::unordered_map<int32_t, int32_t> last_characteristic_; 383 std::unordered_map<int32_t, int32_t> last_characteristic_;
379 // Monotonically increasing value to use as handle to give to Android side. 384 // Monotonically increasing value to use as handle to give to Android side.
380 int32_t gatt_server_attribute_next_handle_ = 0; 385 int32_t gatt_server_attribute_next_handle_ = 0;
381 // Keeps track of all devices which initiated a GATT connection to us. 386 // Keeps track of all devices which initiated a GATT connection to us.
382 std::unordered_set<std::string> gatt_connection_cache_; 387 std::unordered_set<std::string> gatt_connection_cache_;
388 // Timer to turn adapter discoverable off.
389 base::OneShotTimer discoverable_off_timer_;
383 390
384 base::ThreadChecker thread_checker_; 391 base::ThreadChecker thread_checker_;
385 392
386 // WeakPtrFactory to use for callbacks. 393 // WeakPtrFactory to use for callbacks.
387 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 394 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
388 395
389 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 396 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
390 }; 397 };
391 398
392 } // namespace arc 399 } // namespace arc
393 400
394 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 401 #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