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

Side by Side Diff: device/bluetooth/bluetooth_device_chromeos.h

Issue 13416005: Bluetooth: clean up BluetoothDevice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make GetServices return a copy of the list Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 // The BluetoothDeviceChromeOS class is an implementation of BluetoothDevice 33 // The BluetoothDeviceChromeOS class is an implementation of BluetoothDevice
34 // for Chrome OS platform. 34 // for Chrome OS platform.
35 class BluetoothDeviceChromeOS 35 class BluetoothDeviceChromeOS
36 : public device::BluetoothDevice, 36 : public device::BluetoothDevice,
37 public BluetoothDeviceClient::Observer, 37 public BluetoothDeviceClient::Observer,
38 public BluetoothAgentServiceProvider::Delegate { 38 public BluetoothAgentServiceProvider::Delegate {
39 public: 39 public:
40 virtual ~BluetoothDeviceChromeOS(); 40 virtual ~BluetoothDeviceChromeOS();
41 41
42 // BluetoothDevice override 42 // BluetoothDevice override
43 virtual uint32 bluetooth_class() const OVERRIDE;
44 virtual std::string name() const OVERRIDE;
45 virtual std::string address() const OVERRIDE;
43 virtual bool IsPaired() const OVERRIDE; 46 virtual bool IsPaired() const OVERRIDE;
44 virtual const ServiceList& GetServices() const OVERRIDE; 47 virtual bool IsConnected() const OVERRIDE;
48 virtual bool IsConnectable() const OVERRIDE;
49 virtual bool IsConnecting() const OVERRIDE;
50 virtual ServiceList GetServices() const OVERRIDE;
45 virtual void GetServiceRecords( 51 virtual void GetServiceRecords(
46 const ServiceRecordsCallback& callback, 52 const ServiceRecordsCallback& callback,
47 const ErrorCallback& error_callback) OVERRIDE; 53 const ErrorCallback& error_callback) OVERRIDE;
48 virtual void ProvidesServiceWithName( 54 virtual void ProvidesServiceWithName(
49 const std::string& name, 55 const std::string& name,
50 const ProvidesServiceCallback& callback) OVERRIDE; 56 const ProvidesServiceCallback& callback) OVERRIDE;
51 virtual bool ExpectingPinCode() const OVERRIDE; 57 virtual bool ExpectingPinCode() const OVERRIDE;
52 virtual bool ExpectingPasskey() const OVERRIDE; 58 virtual bool ExpectingPasskey() const OVERRIDE;
53 virtual bool ExpectingConfirmation() const OVERRIDE; 59 virtual bool ExpectingConfirmation() const OVERRIDE;
54 virtual void Connect( 60 virtual void Connect(
(...skipping 19 matching lines...) Expand all
74 virtual void ClearOutOfBandPairingData( 80 virtual void ClearOutOfBandPairingData(
75 const base::Closure& callback, 81 const base::Closure& callback,
76 const ErrorCallback& error_callback) OVERRIDE; 82 const ErrorCallback& error_callback) OVERRIDE;
77 83
78 private: 84 private:
79 friend class BluetoothAdapterChromeOS; 85 friend class BluetoothAdapterChromeOS;
80 friend class device::MockBluetoothDevice; 86 friend class device::MockBluetoothDevice;
81 87
82 explicit BluetoothDeviceChromeOS(BluetoothAdapterChromeOS* adapter); 88 explicit BluetoothDeviceChromeOS(BluetoothAdapterChromeOS* adapter);
83 89
90 // Returns whether this device has an object path.
91 bool HasObjectPath() const { return !object_path_.value().empty(); }
92
84 // Sets the dbus object path for the device to |object_path|, indicating 93 // Sets the dbus object path for the device to |object_path|, indicating
85 // that the device has gone from being discovered to paired or bonded. 94 // that the device has gone from being discovered to paired or connected.
86 void SetObjectPath(const dbus::ObjectPath& object_path); 95 void SetObjectPath(const dbus::ObjectPath& object_path);
87 96
88 // Removes the dbus object path from the device, indicating that the 97 // Removes the dbus object path from the device, indicating that the
89 // device is no longer paired or bonded, but perhaps still visible. 98 // device is no longer paired or connected, but perhaps still visible.
90 void RemoveObjectPath(); 99 void RemoveObjectPath();
91 100
92 // Sets whether the device is visible to the owning adapter to |visible|. 101 // Returns whether this was a discovered device.
93 void SetVisible(bool visible) { visible_ = visible; } 102 bool WasDiscovered() const { return discovered_; }
103
104 // Sets whether the device was discovered.
105 void SetDiscovered(bool discovered) { discovered_ = discovered; }
94 106
95 // Updates device information from the properties in |properties|, device 107 // Updates device information from the properties in |properties|, device
96 // state properties such as |paired_| and |connected_| are ignored unless 108 // state properties such as |paired_| and |connected_| are ignored unless
97 // |update_state| is true. 109 // |update_state| is true.
98 void Update(const BluetoothDeviceClient::Properties* properties, 110 void Update(const BluetoothDeviceClient::Properties* properties,
99 bool update_state); 111 bool update_state);
100 112
101 // Called by BluetoothAdapterClient when a call to CreateDevice() or 113 // Called by BluetoothAdapterClient when a call to CreateDevice() or
102 // CreatePairedDevice() succeeds, provides the new object path for the remote 114 // CreatePairedDevice() succeeds, provides the new object path for the remote
103 // device in |device_path|. |callback| and |error_callback| are the callbacks 115 // device in |device_path|. |callback| and |error_callback| are the callbacks
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // |adapter|. 376 // |adapter|.
365 static BluetoothDeviceChromeOS* Create(BluetoothAdapterChromeOS* adapter); 377 static BluetoothDeviceChromeOS* Create(BluetoothAdapterChromeOS* adapter);
366 378
367 // The adapter that owns this device instance. 379 // The adapter that owns this device instance.
368 BluetoothAdapterChromeOS* adapter_; 380 BluetoothAdapterChromeOS* adapter_;
369 381
370 // The dbus object path of the device, will be empty if the device has only 382 // The dbus object path of the device, will be empty if the device has only
371 // been discovered and not yet paired with. 383 // been discovered and not yet paired with.
372 dbus::ObjectPath object_path_; 384 dbus::ObjectPath object_path_;
373 385
386 // The Bluetooth class of the device, a bitmask that may be decoded using
387 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
388 uint32 bluetooth_class_;
389
390 // The name of the device, as supplied by the remote device.
391 std::string name_;
392
393 // The Bluetooth address of the device.
394 std::string address_;
395
396 // Tracked device state, updated by the adapter managing the lifecyle of
397 // the device.
398 bool paired_;
399 bool connected_;
400
401 // Indicates whether the device normally accepts connections initiated from
402 // the adapter once paired.
403 bool connectable_;
404
405 // Indicated whether the device is in a connecting status.
406 bool connecting_;
407
408 // Used by BluetoothAdapterChromeOS (a friend) to avoid removing discovered
409 // devices when they are unpaired.
410 bool discovered_;
411
374 // The services (identified by UUIDs) that this device provides. 412 // The services (identified by UUIDs) that this device provides.
375 std::vector<std::string> service_uuids_; 413 ServiceList service_uuids_;
376 414
377 // During pairing this is set to an object that we don't own, but on which 415 // During pairing this is set to an object that we don't own, but on which
378 // we can make method calls to request, display or confirm PIN Codes and 416 // we can make method calls to request, display or confirm PIN Codes and
379 // Passkeys. Generally it is the object that owns this one. 417 // Passkeys. Generally it is the object that owns this one.
380 device::BluetoothDevice::PairingDelegate* pairing_delegate_; 418 device::BluetoothDevice::PairingDelegate* pairing_delegate_;
381 419
382 // During pairing this is set to an instance of a D-Bus agent object 420 // During pairing this is set to an instance of a D-Bus agent object
383 // intialized with our own class as its delegate. 421 // intialized with our own class as its delegate.
384 scoped_ptr<BluetoothAgentServiceProvider> agent_; 422 scoped_ptr<BluetoothAgentServiceProvider> agent_;
385 423
(...skipping 20 matching lines...) Expand all
406 // Note: This should remain the last member so it'll be destroyed and 444 // Note: This should remain the last member so it'll be destroyed and
407 // invalidate its weak pointers before any other members are destroyed. 445 // invalidate its weak pointers before any other members are destroyed.
408 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; 446 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_;
409 447
410 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); 448 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS);
411 }; 449 };
412 450
413 } // namespace chromeos 451 } // namespace chromeos
414 452
415 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ 453 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698