ServiceWorker: Initialize member variable in ctor of ServiceWorkerDatabase
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_adapter_client.h
blobce25735e3df3f213f86ba5de3716d7ba9478cf3c
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_
8 #include <vector>
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/observer_list.h"
13 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/bluetooth_adapter_client.h"
15 #include "dbus/object_path.h"
16 #include "dbus/property.h"
18 namespace chromeos {
20 // FakeBluetoothAdapterClient simulates the behavior of the Bluetooth Daemon
21 // adapter objects and is used both in test cases in place of a mock and on
22 // the Linux desktop.
23 class CHROMEOS_EXPORT FakeBluetoothAdapterClient
24 : public BluetoothAdapterClient {
25 public:
26 struct Properties : public BluetoothAdapterClient::Properties {
27 explicit Properties(const PropertyChangedCallback & callback);
28 virtual ~Properties();
30 // dbus::PropertySet override
31 virtual void Get(dbus::PropertyBase* property,
32 dbus::PropertySet::GetCallback callback) OVERRIDE;
33 virtual void GetAll() OVERRIDE;
34 virtual void Set(dbus::PropertyBase* property,
35 dbus::PropertySet::SetCallback callback) OVERRIDE;
38 FakeBluetoothAdapterClient();
39 virtual ~FakeBluetoothAdapterClient();
41 // BluetoothAdapterClient overrides
42 virtual void Init(dbus::Bus* bus) OVERRIDE;
43 virtual void AddObserver(Observer* observer) OVERRIDE;
44 virtual void RemoveObserver(Observer* observer) OVERRIDE;
45 virtual std::vector<dbus::ObjectPath> GetAdapters() OVERRIDE;
46 virtual Properties* GetProperties(const dbus::ObjectPath& object_path)
47 OVERRIDE;
48 virtual void StartDiscovery(const dbus::ObjectPath& object_path,
49 const base::Closure& callback,
50 const ErrorCallback& error_callback) OVERRIDE;
51 virtual void StopDiscovery(const dbus::ObjectPath& object_path,
52 const base::Closure& callback,
53 const ErrorCallback& error_callback) OVERRIDE;
54 virtual void RemoveDevice(const dbus::ObjectPath& object_path,
55 const dbus::ObjectPath& device_path,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) OVERRIDE;
59 // Sets the current simulation timeout interval.
60 void SetSimulationIntervalMs(int interval_ms);
62 // Mark the adapter and second adapter as visible or invisible.
63 void SetVisible(bool visible);
64 void SetSecondVisible(bool visible);
66 // Object path, name and addresses of the adapters we emulate.
67 static const char kAdapterPath[];
68 static const char kAdapterName[];
69 static const char kAdapterAddress[];
71 static const char kSecondAdapterPath[];
72 static const char kSecondAdapterName[];
73 static const char kSecondAdapterAddress[];
75 private:
76 // Property callback passed when we create Properties* structures.
77 void OnPropertyChanged(const std::string& property_name);
79 // Posts the delayed task represented by |callback| onto the current
80 // message loop to be executed after |simulation_interval_ms_| milliseconds.
81 void PostDelayedTask(const base::Closure& callback);
83 // List of observers interested in event notifications from us.
84 ObserverList<Observer> observers_;
86 // Static properties we return.
87 scoped_ptr<Properties> properties_;
88 scoped_ptr<Properties> second_properties_;
90 // Whether the adapter and second adapter should be visible or not.
91 bool visible_;
92 bool second_visible_;
94 // Number of times we've been asked to discover.
95 int discovering_count_;
97 // Current timeout interval used when posting delayed tasks.
98 int simulation_interval_ms_;
101 } // namespace chromeos
103 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_ADAPTER_CLIENT_H_