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

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

Issue 2223203002: arc: bluetooth: Add/Remove BT observer only when ARC is ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix #2 comment Created 4 years, 4 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 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>
(...skipping 27 matching lines...) Expand all
38 public device::BluetoothAdapter::Observer, 38 public device::BluetoothAdapter::Observer,
39 public device::BluetoothAdapterFactory::AdapterCallback, 39 public device::BluetoothAdapterFactory::AdapterCallback,
40 public device::BluetoothLocalGattService::Delegate, 40 public device::BluetoothLocalGattService::Delegate,
41 public mojom::BluetoothHost { 41 public mojom::BluetoothHost {
42 public: 42 public:
43 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); 43 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service);
44 ~ArcBluetoothBridge() override; 44 ~ArcBluetoothBridge() override;
45 45
46 // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer: 46 // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer:
47 void OnInstanceReady() override; 47 void OnInstanceReady() override;
48 void OnInstanceClosed() override;
48 49
49 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); 50 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter);
50 51
51 // Overridden from device::BluetoothAdadpter::Observer 52 // Overridden from device::BluetoothAdadpter::Observer
52 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 53 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
53 bool powered) override; 54 bool powered) override;
54 55
55 void DeviceAdded(device::BluetoothAdapter* adapter, 56 void DeviceAdded(device::BluetoothAdapter* adapter,
56 device::BluetoothDevice* device) override; 57 device::BluetoothDevice* device) override;
57 58
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 const std::vector<uint8_t>& value, 358 const std::vector<uint8_t>& value,
358 int offset, 359 int offset,
359 const base::Closure& success_callback, 360 const base::Closure& success_callback,
360 const ErrorCallback& error_callback); 361 const ErrorCallback& error_callback);
361 362
362 bool CalledOnValidThread(); 363 bool CalledOnValidThread();
363 364
364 mojo::Binding<mojom::BluetoothHost> binding_; 365 mojo::Binding<mojom::BluetoothHost> binding_;
365 366
366 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_; 367 scoped_refptr<bluez::BluetoothAdapterBlueZ> bluetooth_adapter_;
368 bool bluetooth_observer_flag_ = false;
rkc 2016/08/08 21:58:29 The correct solution is just to add a HasObserver
367 scoped_refptr<device::BluetoothAdvertisement> advertisment_; 369 scoped_refptr<device::BluetoothAdvertisement> advertisment_;
368 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 370 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
369 std::unordered_map<std::string, 371 std::unordered_map<std::string,
370 std::unique_ptr<device::BluetoothGattNotifySession>> 372 std::unique_ptr<device::BluetoothGattNotifySession>>
371 notification_session_; 373 notification_session_;
372 // Map from Android int handle to Chrome (BlueZ) string identifier. 374 // Map from Android int handle to Chrome (BlueZ) string identifier.
373 std::unordered_map<int32_t, std::string> gatt_identifier_; 375 std::unordered_map<int32_t, std::string> gatt_identifier_;
374 // Map from Chrome (BlueZ) string identifier to android int handle. 376 // Map from Chrome (BlueZ) string identifier to android int handle.
375 std::unordered_map<std::string, int32_t> gatt_handle_; 377 std::unordered_map<std::string, int32_t> gatt_handle_;
376 // Store last GattCharacteristic added to each GattService for GattServer. 378 // Store last GattCharacteristic added to each GattService for GattServer.
377 std::unordered_map<int32_t, int32_t> last_characteristic_; 379 std::unordered_map<int32_t, int32_t> last_characteristic_;
378 // 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.
379 int32_t gatt_server_attribute_next_handle_ = 0; 381 int32_t gatt_server_attribute_next_handle_ = 0;
380 382
381 base::ThreadChecker thread_checker_; 383 base::ThreadChecker thread_checker_;
382 384
383 // WeakPtrFactory to use for callbacks. 385 // WeakPtrFactory to use for callbacks.
384 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; 386 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
385 387
386 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); 388 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge);
387 }; 389 };
388 390
389 } // namespace arc 391 } // namespace arc
390 392
391 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ 393 #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') | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698