summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/dbus
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 20:08:06 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 20:08:06 +0000
commitbc1b18ecfc890dde4aae0a5a5db27dde2796b25e (patch)
tree8e37e62d98047d218bf8fdeff2f10361fbaab961 /chrome/browser/chromeos/dbus
parentce1402accb9a01358fc1235f1319d934cd611248 (diff)
downloadchromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.zip
chromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.tar.gz
chromium_src-bc1b18ecfc890dde4aae0a5a5db27dde2796b25e.tar.bz2
dbus: add ObjectPath type
Rather than use std::string for object paths, add a dbus::ObjectPath type that wraps one while allowing more type-safety. This solves all sorts of issues with confusing object paths for strings, and allows us to do Properties code using templates disambiguating them from strings. BUG=chromium:109194 TEST=built and run tests Change-Id: Icaf6f19daea4af23a9d2ec0ed76d2cbd379d680e Review URL: http://codereview.chromium.org/9378039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/dbus')
-rw-r--r--chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc154
-rw-r--r--chrome/browser/chromeos/dbus/bluetooth_adapter_client.h19
-rw-r--r--chrome/browser/chromeos/dbus/bluetooth_device_client.cc24
-rw-r--r--chrome/browser/chromeos/dbus/bluetooth_manager_client.cc31
-rw-r--r--chrome/browser/chromeos/dbus/bluetooth_manager_client.h13
-rw-r--r--chrome/browser/chromeos/dbus/cros_dbus_service.cc5
-rw-r--r--chrome/browser/chromeos/dbus/cros_dbus_service_unittest.cc7
-rw-r--r--chrome/browser/chromeos/dbus/cros_disks_client.cc6
-rw-r--r--chrome/browser/chromeos/dbus/image_burner_client.cc6
-rw-r--r--chrome/browser/chromeos/dbus/mock_bluetooth_adapter_client.h4
-rw-r--r--chrome/browser/chromeos/dbus/power_manager_client.cc3
-rw-r--r--chrome/browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc7
-rw-r--r--chrome/browser/chromeos/dbus/sensors_client.cc6
-rw-r--r--chrome/browser/chromeos/dbus/session_manager_client.cc5
-rw-r--r--chrome/browser/chromeos/dbus/speech_synthesizer_client.cc3
-rw-r--r--chrome/browser/chromeos/dbus/update_engine_client.cc5
16 files changed, 162 insertions, 136 deletions
diff --git a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc
index 54b772d..bb62d53 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc
+++ b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -142,11 +143,11 @@ bool PopArrayOfDictEntries(dbus::MessageReader* reader,
break;
}
case dbus::Message::OBJECT_PATH: {
- std::string value;
+ dbus::ObjectPath value;
if (!variant_reader.PopObjectPath(&value)) {
return false;
}
- dictionary->SetString(key, value);
+ dictionary->SetString(key, value.value());
break;
}
case dbus::Message::ARRAY: {
@@ -208,8 +209,8 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
}
// BluetoothAdapterClient override.
- virtual void StartDiscovery(const std::string& object_path) {
- VLOG(1) << "StartDiscovery: " << object_path;
+ virtual void StartDiscovery(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "StartDiscovery: " << object_path.value();
dbus::MethodCall method_call(
bluetooth_adapter::kBluetoothAdapterInterface,
@@ -225,8 +226,8 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
}
// BluetoothAdapterClient override.
- virtual void StopDiscovery(const std::string& object_path) {
- VLOG(1) << "StopDiscovery: " << object_path;
+ virtual void StopDiscovery(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "StopDiscovery: " << object_path.value();
dbus::MethodCall method_call(
bluetooth_adapter::kBluetoothAdapterInterface,
@@ -243,21 +244,22 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
private:
// BluetoothManagerClient::Observer override.
- virtual void AdapterAdded(const std::string& object_path) OVERRIDE {
- VLOG(1) << "AdapterAdded: " << object_path;
+ virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE {
+ VLOG(1) << "AdapterAdded: " << object_path.value();
}
// BluetoothManagerClient::Observer override.
- virtual void AdapterRemoved(const std::string& object_path) OVERRIDE {
- VLOG(1) << "AdapterRemoved: " << object_path;
+ virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE {
+ VLOG(1) << "AdapterRemoved: " << object_path.value();
RemoveObjectProxyForPath(object_path);
}
// Ensures that we have a dbus object proxy for an adapter with dbus
// object path |object_path|, and if not, creates it and stores it in
// our |proxy_map_| map.
- dbus::ObjectProxy* GetObjectProxyForPath(const std::string& object_path) {
- VLOG(1) << "GetObjectProxyForPath: " << object_path;
+ dbus::ObjectProxy* GetObjectProxyForPath(
+ const dbus::ObjectPath& object_path) {
+ VLOG(1) << "GetObjectProxyForPath: " << object_path.value();
ProxyMap::iterator it = proxy_map_.find(object_path);
if (it != proxy_map_.end())
@@ -314,126 +316,129 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
// Removes the dbus object proxy for the adapter with dbus object path
// |object_path| from our |proxy_map_| map.
- void RemoveObjectProxyForPath(const std::string& object_path) {
- VLOG(1) << "RemoveObjectProxyForPath: " << object_path;
+ void RemoveObjectProxyForPath(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "RemoveObjectProxyForPath: " << object_path.value();
proxy_map_.erase(object_path);
}
// Called by dbus:: when a DeviceCreated signal is received.
- void DeviceCreatedReceived(const std::string& object_path,
+ void DeviceCreatedReceived(const dbus::ObjectPath& object_path,
dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string device_path;
+ dbus::ObjectPath device_path;
if (!reader.PopObjectPath(&device_path)) {
- LOG(ERROR) << object_path
- << ": DeviceCreated signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": DeviceCreated signal has incorrect parameters: "
+ << signal->ToString();
return;
}
- VLOG(1) << object_path << ": Device created: " << device_path;
+ VLOG(1) << object_path.value() << ": Device created: "
+ << device_path.value();
FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
DeviceCreated(object_path, device_path));
}
// Called by dbus:: when the DeviceCreated signal is initially connected.
- void DeviceCreatedConnected(const std::string& object_path,
+ void DeviceCreatedConnected(const dbus::ObjectPath& object_path,
const std::string& interface_name,
const std::string& signal_name,
bool success) {
- LOG_IF(WARNING, !success) << object_path
- << ": Failed to connect to DeviceCreated signal.";
+ LOG_IF(WARNING, !success) << object_path.value()
+ << ": Failed to connect to DeviceCreated signal.";
}
// Called by dbus:: when a DeviceRemoved signal is received.
- void DeviceRemovedReceived(const std::string& object_path,
+ void DeviceRemovedReceived(const dbus::ObjectPath& object_path,
dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string device_path;
+ dbus::ObjectPath device_path;
if (!reader.PopObjectPath(&device_path)) {
- LOG(ERROR) << object_path
- << ": DeviceRemoved signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": DeviceRemoved signal has incorrect parameters: "
+ << signal->ToString();
return;
}
- VLOG(1) << object_path << ": Device removed: " << device_path;
+ VLOG(1) << object_path.value() << ": Device removed: "
+ << device_path.value();
FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
DeviceRemoved(object_path, device_path));
}
// Called by dbus:: when the DeviceRemoved signal is initially connected.
- void DeviceRemovedConnected(const std::string& object_path,
+ void DeviceRemovedConnected(const dbus::ObjectPath& object_path,
const std::string& interface_name,
const std::string& signal_name,
bool success) {
- LOG_IF(WARNING, !success) << object_path
- << ": Failed to connect to DeviceRemoved signal.";
+ LOG_IF(WARNING, !success) << object_path.value()
+ << ": Failed to connect to DeviceRemoved signal.";
}
// Called by dbus:: when a PropertyChanged signal is received.
- void PropertyChangedReceived(const std::string& object_path,
+ void PropertyChangedReceived(const dbus::ObjectPath& object_path,
dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
std::string property_name;
if (!reader.PopString(&property_name)) {
- LOG(ERROR) << object_path
- << ": PropertyChanged signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": PropertyChanged signal has incorrect parameters: "
+ << signal->ToString();
return;
}
if (property_name != bluetooth_adapter::kDiscoveringProperty) {
- VLOG(1) << object_path << ": PropertyChanged: " << property_name;
+ VLOG(1) << object_path.value() << ": PropertyChanged: " << property_name;
// We don't care.
return;
}
bool discovering = false;
if (!reader.PopVariantOfBool(&discovering)) {
- LOG(ERROR) << object_path
- << ": PropertyChanged signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": PropertyChanged signal has incorrect parameters: "
+ << signal->ToString();
return;
}
- VLOG(1) << object_path << ": PropertyChanged: Discovering = "
- << discovering;
+ VLOG(1) << object_path.value() << ": PropertyChanged: Discovering = "
+ << discovering;
FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
DiscoveringPropertyChanged(object_path, discovering));
}
// Called by dbus:: when the PropertyChanged signal is initially connected.
- void PropertyChangedConnected(const std::string& object_path,
+ void PropertyChangedConnected(const dbus::ObjectPath& object_path,
const std::string& interface_name,
const std::string& signal_name,
bool success) {
- LOG_IF(WARNING, !success) << object_path
+ LOG_IF(WARNING, !success)
+ << object_path.value()
<< ": Failed to connect to PropertyChanged signal.";
}
// Called by dbus:: when a DeviceFound signal is received.
- void DeviceFoundReceived(const std::string& object_path,
+ void DeviceFoundReceived(const dbus::ObjectPath& object_path,
dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
std::string address;
if (!reader.PopString(&address)) {
- LOG(ERROR) << object_path
- << ": DeviceFound signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": DeviceFound signal has incorrect parameters: "
+ << signal->ToString();
return;
}
- VLOG(1) << object_path << ": Device found: " << address;
+ VLOG(1) << object_path.value() << ": Device found: " << address;
DictionaryValue device_properties;
if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) {
- LOG(ERROR) << object_path
- << ": DeviceFound signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": DeviceFound signal has incorrect parameters: "
+ << signal->ToString();
return;
}
@@ -442,52 +447,55 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
}
// Called by dbus:: when the DeviceFound signal is initially connected.
- void DeviceFoundConnected(const std::string& object_path,
+ void DeviceFoundConnected(const dbus::ObjectPath& object_path,
const std::string& interface_name,
const std::string& signal_name,
bool success) {
- LOG_IF(WARNING, !success) << object_path
- << ": Failed to connect to DeviceFound signal.";
+ LOG_IF(WARNING, !success) << object_path.value()
+ << ": Failed to connect to DeviceFound signal.";
}
// Called by dbus:: when a DeviceDisappeared signal is received.
- void DeviceDisappearedReceived(const std::string& object_path,
+ void DeviceDisappearedReceived(const dbus::ObjectPath& object_path,
dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
std::string address;
if (!reader.PopString(&address)) {
- LOG(ERROR) << object_path
- << ": DeviceDisappeared signal has incorrect parameters: "
- << signal->ToString();
+ LOG(ERROR) << object_path.value()
+ << ": DeviceDisappeared signal has incorrect parameters: "
+ << signal->ToString();
return;
}
- VLOG(1) << object_path << ": Device disappeared: " << address;
+ VLOG(1) << object_path.value() << ": Device disappeared: " << address;
FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_,
DeviceDisappeared(object_path, address));
}
// Called by dbus:: when the DeviceDisappeared signal is initially connected.
- void DeviceDisappearedConnected(const std::string& object_path,
+ void DeviceDisappearedConnected(const dbus::ObjectPath& object_path,
const std::string& interface_name,
const std::string& signal_name,
bool success) {
- LOG_IF(WARNING, !success) << object_path
+ LOG_IF(WARNING, !success)
+ << object_path.value()
<< ": Failed to connect to DeviceDisappeared signal.";
}
// Called when a response for StartDiscovery() is received.
- void OnStartDiscovery(const std::string& object_path,
+ void OnStartDiscovery(const dbus::ObjectPath& object_path,
dbus::Response* response) {
- VLOG(1) << "OnStartDiscovery: " << object_path;
- LOG_IF(WARNING, !response) << object_path << ": OnStartDiscovery: failed.";
+ VLOG(1) << "OnStartDiscovery: " << object_path.value();
+ LOG_IF(WARNING, !response) << object_path.value()
+ << ": OnStartDiscovery: failed.";
}
// Called when a response for StopDiscovery() is received.
- void OnStopDiscovery(const std::string& object_path,
+ void OnStopDiscovery(const dbus::ObjectPath& object_path,
dbus::Response* response) {
- VLOG(1) << "OnStopDiscovery: " << object_path;
- LOG_IF(WARNING, !response) << object_path << ": OnStopDiscovery: failed.";
+ VLOG(1) << "OnStopDiscovery: " << object_path.value();
+ LOG_IF(WARNING, !response) << object_path.value()
+ << ": OnStopDiscovery: failed.";
}
// Weak pointer factory for generating 'this' pointers that might live longer
@@ -497,7 +505,7 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient,
dbus::Bus* bus_;
// We maintain a collection of dbus object proxies, one for each adapter.
- typedef std::map<const std::string, dbus::ObjectProxy*> ProxyMap;
+ typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap;
ProxyMap proxy_map_;
// List of observers interested in event notifications from us.
@@ -521,13 +529,13 @@ class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient {
}
// BluetoothAdapterClient override.
- virtual void StartDiscovery(const std::string& object_path) {
- VLOG(1) << "StartDiscovery: " << object_path;
+ virtual void StartDiscovery(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "StartDiscovery: " << object_path.value();
}
// BluetoothAdapterClient override.
- virtual void StopDiscovery(const std::string& object_path) {
- VLOG(1) << "StopDiscovery: " << object_path;
+ virtual void StopDiscovery(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "StopDiscovery: " << object_path.value();
}
};
diff --git a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h
index e740100..2e7e0f0 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h
+++ b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/values.h"
+#include "dbus/object_path.h"
namespace dbus {
class Bus;
@@ -30,25 +31,25 @@ class BluetoothAdapterClient {
virtual ~Observer() {}
// Called when a new known device has been created.
- virtual void DeviceCreated(const std::string& object_path,
- const std::string& device_path) {}
+ virtual void DeviceCreated(const dbus::ObjectPath& object_path,
+ const dbus::ObjectPath& device_path) {}
// Called when a previously known device is removed.
- virtual void DeviceRemoved(const std::string& object_path,
- const std::string& device_path) {}
+ virtual void DeviceRemoved(const dbus::ObjectPath& object_path,
+ const dbus::ObjectPath& device_path) {}
// Called when the adapter's Discovering property changes.
- virtual void DiscoveringPropertyChanged(const std::string& object_path,
+ virtual void DiscoveringPropertyChanged(const dbus::ObjectPath& object_path,
bool discovering) {}
// Called when a new remote device has been discovered.
// |device_properties| should be copied if needed.
- virtual void DeviceFound(const std::string& object_path,
+ virtual void DeviceFound(const dbus::ObjectPath& object_path,
const std::string& address,
const DictionaryValue& device_properties) {}
// Called when a previously discovered device is no longer visible.
- virtual void DeviceDisappeared(const std::string& object_path,
+ virtual void DeviceDisappeared(const dbus::ObjectPath& object_path,
const std::string& address) {}
};
@@ -60,11 +61,11 @@ class BluetoothAdapterClient {
virtual void RemoveObserver(Observer* observer) = 0;
// Starts a device discovery on the adapter with object path |object_path|.
- virtual void StartDiscovery(const std::string& object_path) = 0;
+ virtual void StartDiscovery(const dbus::ObjectPath& object_path) = 0;
// Cancels any previous device discovery on the adapter with object path
// |object_path|.
- virtual void StopDiscovery(const std::string& object_path) = 0;
+ virtual void StopDiscovery(const dbus::ObjectPath& object_path) = 0;
// Creates the instance.
static BluetoothAdapterClient* Create(dbus::Bus* bus,
diff --git a/chrome/browser/chromeos/dbus/bluetooth_device_client.cc b/chrome/browser/chromeos/dbus/bluetooth_device_client.cc
index 6069681..78121fc 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_device_client.cc
+++ b/chrome/browser/chromeos/dbus/bluetooth_device_client.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -53,23 +54,24 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient,
private:
// BluetoothAdapterClient::Observer override.
- virtual void DeviceCreated(const std::string& adapter_path,
- const std::string& object_path) OVERRIDE {
- VLOG(1) << "DeviceCreated: " << object_path;
+ virtual void DeviceCreated(const dbus::ObjectPath& adapter_path,
+ const dbus::ObjectPath& object_path) OVERRIDE {
+ VLOG(1) << "DeviceCreated: " << object_path.value();
}
// BluetoothAdapterClient::Observer override.
- virtual void DeviceRemoved(const std::string& adapter_path,
- const std::string& object_path) OVERRIDE {
- VLOG(1) << "DeviceRemoved: " << object_path;
+ virtual void DeviceRemoved(const dbus::ObjectPath& adapter_path,
+ const dbus::ObjectPath& object_path) OVERRIDE {
+ VLOG(1) << "DeviceRemoved: " << object_path.value();
RemoveObjectProxyForPath(object_path);
}
// Ensures that we have a dbus object proxy for a device with dbus
// object path |object_path|, and if not, creates it stores it in
// our |proxy_map_| map.
- dbus::ObjectProxy* GetObjectProxyForPath(const std::string& object_path) {
- VLOG(1) << "GetObjectProxyForPath: " << object_path;
+ dbus::ObjectProxy* GetObjectProxyForPath(
+ const dbus::ObjectPath& object_path) {
+ VLOG(1) << "GetObjectProxyForPath: " << object_path.value();
ProxyMap::iterator it = proxy_map_.find(object_path);
if (it != proxy_map_.end())
@@ -86,8 +88,8 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient,
// Removes the dbus object proxy for the device with dbus object path
// |object_path| from our |proxy_map_| map.
- void RemoveObjectProxyForPath(const std::string& object_path) {
- VLOG(1) << "RemoveObjectProxyForPath: " << object_path;
+ void RemoveObjectProxyForPath(const dbus::ObjectPath& object_path) {
+ VLOG(1) << "RemoveObjectProxyForPath: " << object_path.value();
proxy_map_.erase(object_path);
}
@@ -98,7 +100,7 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient,
dbus::Bus* bus_;
// We maintain a collection of dbus object proxies, one for each device.
- typedef std::map<const std::string, dbus::ObjectProxy*> ProxyMap;
+ typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap;
ProxyMap proxy_map_;
// List of observers interested in event notifications from us.
diff --git a/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc b/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
index 12f1e8a..f65fa84 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -26,7 +27,7 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
bluetooth_manager_proxy_ = bus->GetObjectProxy(
bluetooth_manager::kBluetoothManagerServiceName,
- bluetooth_manager::kBluetoothManagerServicePath);
+ dbus::ObjectPath(bluetooth_manager::kBluetoothManagerServicePath));
bluetooth_manager_proxy_->ConnectToSignal(
bluetooth_manager::kBluetoothManagerInterface,
@@ -91,13 +92,13 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
void AdapterAddedReceived(dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string object_path;
+ dbus::ObjectPath object_path;
if (!reader.PopObjectPath(&object_path)) {
LOG(ERROR) << "AdapterAdded signal has incorrect parameters: "
- << signal->ToString();
+ << signal->ToString();
return;
}
- VLOG(1) << "Adapter added: " << object_path;
+ VLOG(1) << "Adapter added: " << object_path.value();
FOR_EACH_OBSERVER(Observer, observers_, AdapterAdded(object_path));
}
@@ -112,13 +113,13 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
void AdapterRemovedReceived(dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string object_path;
+ dbus::ObjectPath object_path;
if (!reader.PopObjectPath(&object_path)) {
LOG(ERROR) << "AdapterRemoved signal has incorrect parameters: "
- << signal->ToString();
+ << signal->ToString();
return;
}
- VLOG(1) << "Adapter removed: " << object_path;
+ VLOG(1) << "Adapter removed: " << object_path.value();
FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(object_path));
}
@@ -133,14 +134,14 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
void DefaultAdapterChangedReceived(dbus::Signal* signal) {
DCHECK(signal);
dbus::MessageReader reader(signal);
- std::string adapter;
- if (!reader.PopObjectPath(&adapter)) {
+ dbus::ObjectPath object_path;
+ if (!reader.PopObjectPath(&object_path)) {
LOG(ERROR) << "DefaultAdapterChanged signal has incorrect parameters: "
- << signal->ToString();
+ << signal->ToString();
return;
}
- VLOG(1) << "Default adapter changed: " << adapter;
- FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(adapter));
+ VLOG(1) << "Default adapter changed: " << object_path.value();
+ FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(object_path));
}
// Called by dbus:: when the DefaultAdapterChanged signal is initially
@@ -157,15 +158,15 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient {
dbus::Response* response) {
// Parse response.
bool success = false;
- std::string adapter;
+ dbus::ObjectPath adapter;
if (response != NULL) {
dbus::MessageReader reader(response);
if (!reader.PopObjectPath(&adapter)) {
LOG(ERROR) << "DefaultAdapter response has incorrect parameters: "
- << response->ToString();
+ << response->ToString();
} else {
success = true;
- LOG(INFO) << "OnDefaultAdapter: " << adapter;
+ LOG(INFO) << "OnDefaultAdapter: " << adapter.value();
}
} else {
LOG(ERROR) << "Failed to get default adapter.";
diff --git a/chrome/browser/chromeos/dbus/bluetooth_manager_client.h b/chrome/browser/chromeos/dbus/bluetooth_manager_client.h
index 394f9c9..a74f925 100644
--- a/chrome/browser/chromeos/dbus/bluetooth_manager_client.h
+++ b/chrome/browser/chromeos/dbus/bluetooth_manager_client.h
@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/observer_list.h"
+#include "dbus/object_path.h"
namespace dbus {
class Bus;
@@ -28,16 +29,16 @@ class BluetoothManagerClient {
// Called when a local bluetooth adapter is added.
// |object_path| is the dbus object path of the adapter.
- virtual void AdapterAdded(const std::string& object_path) {}
+ virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
// Called when a local bluetooth adapter is removed.
// |object_path| is the dbus object path of the adapter.
- virtual void AdapterRemoved(const std::string& object_path) {}
+ virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
// Called when the default local bluetooth adapter changes.
- // |adapter| is the dbus object path of the new default adapter.
+ // |object_path| is the dbus object path of the new default adapter.
// Not called if all adapters are removed.
- virtual void DefaultAdapterChanged(const std::string& adapter) {}
+ virtual void DefaultAdapterChanged(const dbus::ObjectPath& object_path) {}
};
virtual ~BluetoothManagerClient();
@@ -47,9 +48,9 @@ class BluetoothManagerClient {
virtual void RemoveObserver(Observer* observer) = 0;
// The DefaultAdapterCallback receives two arguments:
- // std::string adapter - the unique identifier of the default adapter
+ // dbus::ObjectPath object_path - the path of the new default adapter
// bool success - whether or not the request succeeded
- typedef base::Callback<void(const std::string&, bool)>
+ typedef base::Callback<void(const dbus::ObjectPath&, bool)>
DefaultAdapterCallback;
// Retrieves the dbus object path for the default adapter.
diff --git a/chrome/browser/chromeos/dbus/cros_dbus_service.cc b/chrome/browser/chromeos/dbus/cros_dbus_service.cc
index bb1bdcb..5f912ed 100644
--- a/chrome/browser/chromeos/dbus/cros_dbus_service.cc
+++ b/chrome/browser/chromeos/dbus/cros_dbus_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,6 +11,7 @@
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
+#include "dbus/object_path.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
@@ -40,7 +41,7 @@ class CrosDBusServiceImpl : public CrosDBusService {
exported_object_ = bus_->GetExportedObject(
kLibCrosServiceName,
- kLibCrosServicePath);
+ dbus::ObjectPath(kLibCrosServicePath));
for (size_t i = 0; i < service_providers_.size(); ++i)
service_providers_[i]->Start(exported_object_);
diff --git a/chrome/browser/chromeos/dbus/cros_dbus_service_unittest.cc b/chrome/browser/chromeos/dbus/cros_dbus_service_unittest.cc
index 649f678..3dc6359 100644
--- a/chrome/browser/chromeos/dbus/cros_dbus_service_unittest.cc
+++ b/chrome/browser/chromeos/dbus/cros_dbus_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,6 +11,7 @@
#include "dbus/mock_bus.h"
#include "dbus/mock_exported_object.h"
#include "dbus/mock_object_proxy.h"
+#include "dbus/object_path.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -48,12 +49,12 @@ class CrosDBusServiceTest : public testing::Test {
mock_exported_object_ =
new dbus::MockExportedObject(mock_bus_.get(),
kLibCrosServiceName,
- kLibCrosServicePath);
+ dbus::ObjectPath(kLibCrosServicePath));
// |mock_bus_|'s GetExportedObject() will return mock_exported_object_|
// for the given service name and the object path.
EXPECT_CALL(*mock_bus_, GetExportedObject(
- kLibCrosServiceName, kLibCrosServicePath))
+ kLibCrosServiceName, dbus::ObjectPath(kLibCrosServicePath)))
.WillOnce(Return(mock_exported_object_.get()));
// Create a mock proxy resolution service.
diff --git a/chrome/browser/chromeos/dbus/cros_disks_client.cc b/chrome/browser/chromeos/dbus/cros_disks_client.cc
index 63e63df..210a71d 100644
--- a/chrome/browser/chromeos/dbus/cros_disks_client.cc
+++ b/chrome/browser/chromeos/dbus/cros_disks_client.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -105,8 +106,9 @@ bool MaybePopArrayOfStrings(dbus::MessageReader* reader,
class CrosDisksClientImpl : public CrosDisksClient {
public:
explicit CrosDisksClientImpl(dbus::Bus* bus)
- : proxy_(bus->GetObjectProxy(cros_disks::kCrosDisksServiceName,
- cros_disks::kCrosDisksServicePath)),
+ : proxy_(bus->GetObjectProxy(
+ cros_disks::kCrosDisksServiceName,
+ dbus::ObjectPath(cros_disks::kCrosDisksServicePath))),
weak_ptr_factory_(this) {
}
diff --git a/chrome/browser/chromeos/dbus/image_burner_client.cc b/chrome/browser/chromeos/dbus/image_burner_client.cc
index 813ed47..49ea93f 100644
--- a/chrome/browser/chromeos/dbus/image_burner_client.cc
+++ b/chrome/browser/chromeos/dbus/image_burner_client.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -22,8 +23,9 @@ class ImageBurnerClientImpl : public ImageBurnerClient {
explicit ImageBurnerClientImpl(dbus::Bus* bus)
: proxy_(NULL),
weak_ptr_factory_(this) {
- proxy_ = bus->GetObjectProxy(imageburn::kImageBurnServiceName,
- imageburn::kImageBurnServicePath);
+ proxy_ = bus->GetObjectProxy(
+ imageburn::kImageBurnServiceName,
+ dbus::ObjectPath(imageburn::kImageBurnServicePath));
proxy_->ConnectToSignal(
imageburn::kImageBurnServiceInterface,
imageburn::kSignalBurnFinishedName,
diff --git a/chrome/browser/chromeos/dbus/mock_bluetooth_adapter_client.h b/chrome/browser/chromeos/dbus/mock_bluetooth_adapter_client.h
index 6cd0de9..47c1c9d 100644
--- a/chrome/browser/chromeos/dbus/mock_bluetooth_adapter_client.h
+++ b/chrome/browser/chromeos/dbus/mock_bluetooth_adapter_client.h
@@ -19,8 +19,8 @@ class MockBluetoothAdapterClient : public BluetoothAdapterClient {
MOCK_METHOD1(AddObserver, void(Observer*));
MOCK_METHOD1(RemoveObserver, void(Observer*));
- MOCK_METHOD1(StartDiscovery, void(const std::string&));
- MOCK_METHOD1(StopDiscovery, void(const std::string&));
+ MOCK_METHOD1(StartDiscovery, void(const dbus::ObjectPath&));
+ MOCK_METHOD1(StopDiscovery, void(const dbus::ObjectPath&));
};
} // namespace chromeos
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.cc b/chrome/browser/chromeos/dbus/power_manager_client.cc
index 1391dbfc..54e7ab7 100644
--- a/chrome/browser/chromeos/dbus/power_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/power_manager_client.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -63,7 +64,7 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_(this) {
power_manager_proxy_ = bus->GetObjectProxy(
power_manager::kPowerManagerServiceName,
- power_manager::kPowerManagerServicePath);
+ dbus::ObjectPath(power_manager::kPowerManagerServicePath));
// Monitor the D-Bus signal for brightness changes. Only the power
// manager knows the actual brightness level. We don't cache the
diff --git a/chrome/browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc b/chrome/browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc
index 9cbbdf5..e7f3f9fb 100644
--- a/chrome/browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc
+++ b/chrome/browser/chromeos/dbus/proxy_resolution_service_provider_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -22,6 +22,7 @@
#include "dbus/mock_bus.h"
#include "dbus/mock_exported_object.h"
#include "dbus/mock_object_proxy.h"
+#include "dbus/object_path.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -80,7 +81,7 @@ class ProxyResolutionServiceProviderTest : public testing::Test {
mock_exported_object_ =
new dbus::MockExportedObject(mock_bus_.get(),
kLibCrosServiceName,
- kLibCrosServicePath);
+ dbus::ObjectPath(kLibCrosServicePath));
// |mock_exported_object_|'s ExportMethod() will use
// |MockExportedObject().
@@ -102,7 +103,7 @@ class ProxyResolutionServiceProviderTest : public testing::Test {
mock_object_proxy_ =
new dbus::MockObjectProxy(mock_bus_.get(),
kLibCrosServiceName,
- kLibCrosServicePath);
+ dbus::ObjectPath(kLibCrosServicePath));
// |mock_object_proxy_|'s CallMethodAndBlock() will use
// MockCallMethodAndBlock() to return responses.
EXPECT_CALL(*mock_object_proxy_,
diff --git a/chrome/browser/chromeos/dbus/sensors_client.cc b/chrome/browser/chromeos/dbus/sensors_client.cc
index ff0dd8d..f8c03f4 100644
--- a/chrome/browser/chromeos/dbus/sensors_client.cc
+++ b/chrome/browser/chromeos/dbus/sensors_client.cc
@@ -11,6 +11,7 @@
#include "content/public/browser/sensors_provider.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
using content::BrowserThread;
@@ -31,8 +32,9 @@ class SensorsClientImpl : public SensorsClient {
explicit SensorsClientImpl(dbus::Bus* bus)
: sensors_proxy_(NULL),
weak_ptr_factory_(this) {
- sensors_proxy_ = bus->GetObjectProxy(chromeos::kSensorsServiceName,
- chromeos::kSensorsServicePath);
+ sensors_proxy_ = bus->GetObjectProxy(
+ chromeos::kSensorsServiceName,
+ dbus::ObjectPath(chromeos::kSensorsServicePath));
sensors_proxy_->ConnectToSignal(
chromeos::kSensorsServiceInterface,
chromeos::kScreenOrientationChanged,
diff --git a/chrome/browser/chromeos/dbus/session_manager_client.cc b/chrome/browser/chromeos/dbus/session_manager_client.cc
index b2643c7..a4b3579 100644
--- a/chrome/browser/chromeos/dbus/session_manager_client.cc
+++ b/chrome/browser/chromeos/dbus/session_manager_client.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -23,7 +24,7 @@ class SessionManagerClientImpl : public SessionManagerClient {
weak_ptr_factory_(this) {
session_manager_proxy_ = bus->GetObjectProxy(
login_manager::kSessionManagerServiceName,
- login_manager::kSessionManagerServicePath);
+ dbus::ObjectPath(login_manager::kSessionManagerServicePath));
// Monitor the D-Bus signal for owner key changes.
session_manager_proxy_->ConnectToSignal(
diff --git a/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc b/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc
index 745b4ba..5c474c8 100644
--- a/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc
+++ b/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -32,7 +33,7 @@ class SpeechSynthesizerClientImpl : public SpeechSynthesizerClient {
weak_ptr_factory_(this) {
proxy_ = bus->GetObjectProxy(
speech_synthesis::kSpeechSynthesizerServiceName,
- speech_synthesis::kSpeechSynthesizerServicePath);
+ dbus::ObjectPath(speech_synthesis::kSpeechSynthesizerServicePath));
}
virtual ~SpeechSynthesizerClientImpl() {}
diff --git a/chrome/browser/chromeos/dbus/update_engine_client.cc b/chrome/browser/chromeos/dbus/update_engine_client.cc
index ed5cecb..9352375 100644
--- a/chrome/browser/chromeos/dbus/update_engine_client.cc
+++ b/chrome/browser/chromeos/dbus/update_engine_client.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,6 +10,7 @@
#include "chrome/browser/chromeos/system/runtime_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
+#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -54,7 +55,7 @@ class UpdateEngineClientImpl : public UpdateEngineClient {
last_status_() {
update_engine_proxy_ = bus->GetObjectProxy(
update_engine::kUpdateEngineServiceName,
- update_engine::kUpdateEngineServicePath);
+ dbus::ObjectPath(update_engine::kUpdateEngineServicePath));
// Monitor the D-Bus signal for brightness changes. Only the power
// manager knows the actual brightness level. We don't cache the