Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chromeos / dbus / fake_bluetooth_gatt_service_client.h
index 35b05d4..535b8c7 100644 (file)
@@ -9,6 +9,7 @@
 #include <vector>
 
 #include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
 #include "chromeos/chromeos_export.h"
 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
@@ -29,24 +30,24 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceClient
 
     // dbus::PropertySet override
     virtual void Get(dbus::PropertyBase* property,
-                     dbus::PropertySet::GetCallback callback) OVERRIDE;
-    virtual void GetAll() OVERRIDE;
+                     dbus::PropertySet::GetCallback callback) override;
+    virtual void GetAll() override;
     virtual void Set(dbus::PropertyBase* property,
-                     dbus::PropertySet::SetCallback callback) OVERRIDE;
+                     dbus::PropertySet::SetCallback callback) override;
   };
 
   FakeBluetoothGattServiceClient();
   virtual ~FakeBluetoothGattServiceClient();
 
   // DBusClient override.
-  virtual void Init(dbus::Bus* bus) OVERRIDE;
+  virtual void Init(dbus::Bus* bus) override;
 
   // BluetoothGattServiceClient overrides.
-  virtual void AddObserver(Observer* observer) OVERRIDE;
-  virtual void RemoveObserver(Observer* observer) OVERRIDE;
-  virtual std::vector<dbus::ObjectPath> GetServices() OVERRIDE;
+  virtual void AddObserver(Observer* observer) override;
+  virtual void RemoveObserver(Observer* observer) override;
+  virtual std::vector<dbus::ObjectPath> GetServices() override;
   virtual Properties* GetProperties(const dbus::ObjectPath& object_path)
-      OVERRIDE;
+      override;
 
   // Makes a service visible for device with object path |device_path|. Note
   // that only one instance of a specific service is simulated at a time. Hence,
@@ -54,6 +55,13 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceClient
   void ExposeHeartRateService(const dbus::ObjectPath& device_path);
   void HideHeartRateService();
 
+  // Returns whether or not the Heart Rate Service is visible.
+  bool IsHeartRateVisible() const;
+
+  // Returns the current object path of the visible Heart Rate service. If the
+  // service is not visible, returns an invalid empty path.
+  dbus::ObjectPath GetHeartRateServicePath() const;
+
   // Final object path components and the corresponding UUIDs of the GATT
   // services that we emulate. Service paths are hierarchical to Bluetooth
   // device paths, so if the path component is "service0000", and the device
@@ -71,6 +79,12 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceClient
   void NotifyServiceAdded(const dbus::ObjectPath& object_path);
   void NotifyServiceRemoved(const dbus::ObjectPath& object_path);
 
+  // Tells FakeBluetoothGattCharacteristicClient to expose GATT characteristics.
+  // This is scheduled from ExposeHeartRateService to simulate asynchronous
+  // retrieval of characteristics. If the Heart Rate Service is hidden at the
+  // time this method is called, then it does nothing.
+  void ExposeHeartRateCharacteristics();
+
   // Static properties we return. As long as a service is exposed, this will be
   // non-null. Otherwise it will be null.
   scoped_ptr<Properties> heart_rate_service_properties_;
@@ -79,6 +93,12 @@ class CHROMEOS_EXPORT FakeBluetoothGattServiceClient
   // List of observers interested in event notifications from us.
   ObserverList<Observer> observers_;
 
+  // Weak pointer factory for generating 'this' pointers that might live longer
+  // than we do.
+  // Note: This should remain the last member so it'll be destroyed and
+  // invalidate its weak pointers before any other members are destroyed.
+  base::WeakPtrFactory<FakeBluetoothGattServiceClient> weak_ptr_factory_;
+
   DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattServiceClient);
 };