diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:22:53 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:22:53 +0000 |
commit | 02743b707e2743cd0f0916e3b405191a48fa3947 (patch) | |
tree | 2b0c0be422f99a2e0dce81c6de92f9a8bc80b969 | |
parent | 7f58f3f417a0598ad796ca7de7b14a38252d91bd (diff) | |
download | chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.zip chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.tar.gz chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.tar.bz2 |
Revert 121920 - 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
TBR=keybuk@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9363045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121923 0039d316-1c4b-4281-b951-d872f2087c98
47 files changed, 333 insertions, 470 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc index 65c53f5..2679274 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc +++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc @@ -49,40 +49,40 @@ class BluetoothAdapterImpl : public BluetoothAdapter, virtual void StartDiscovery() { VLOG(1) << id_ << ": StartDiscovery"; DCHECK(bluetooth_adapter_client_); - bluetooth_adapter_client_->StartDiscovery(dbus::ObjectPath(id_)); + bluetooth_adapter_client_->StartDiscovery(id_); } virtual void StopDiscovery() { VLOG(1) << id_ << ": StopDiscovery"; DCHECK(bluetooth_adapter_client_); - bluetooth_adapter_client_->StopDiscovery(dbus::ObjectPath(id_)); + bluetooth_adapter_client_->StopDiscovery(id_); } // BluetoothAdapterClient::Observer override. - virtual void DiscoveringPropertyChanged(const dbus::ObjectPath& object_path, + virtual void DiscoveringPropertyChanged(const std::string& object_path, bool discovering) { - VLOG(1) << id_ << ": object_path = " << object_path.value() - << ", Discovering = " << discovering; - if (object_path.value() != id_) { + VLOG(1) << id_ << ": object_path = " << object_path << ", Discovering = " + << discovering; + if (object_path != id_) { return; } if (discovering) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DiscoveryStarted(object_path.value())); + DiscoveryStarted(object_path)); } else { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DiscoveryEnded(object_path.value())); + DiscoveryEnded(object_path)); } } // BluetoothAdapterClient::Observer override. - virtual void DeviceFound(const dbus::ObjectPath& object_path, + virtual void DeviceFound(const std::string& object_path, const std::string& address, const base::DictionaryValue& device_properties) { - VLOG(1) << id_ << ": object_path = " << object_path.value() - << ", Device found: " << address << " (with " - << device_properties.size() << " properties)"; - if (object_path.value() != id_) { + VLOG(1) << id_ << ": object_path = " << object_path << ", Device found: " + << address << " (with " << device_properties.size() + << " properties)"; + if (object_path != id_) { return; } // TODO(vlaviano): later, we will want to persist the device. @@ -90,18 +90,18 @@ class BluetoothAdapterImpl : public BluetoothAdapter, BluetoothDevice::Create(device_properties)); if (device.get() != NULL) { FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, - DeviceFound(object_path.value(), device.get())); + DeviceFound(object_path, device.get())); } else { LOG(WARNING) << "Could not create BluetoothDevice from properties."; } } // BluetoothAdapterClient::Observer override. - virtual void DeviceDisappeared(const dbus::ObjectPath& object_path, + virtual void DeviceDisappeared(const std::string& object_path, const std::string& address) { - VLOG(1) << id_ << ": object_path = " << object_path.value() + VLOG(1) << id_ << ": object_path = " << object_path << ", Device disappeared: " << address; - if (object_path.value() != id_) { + if (object_path != id_) { return; } // For now, we don't propagate this event to our observers. diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_manager.cc b/chrome/browser/chromeos/bluetooth/bluetooth_manager.cc index ef362f0..3161885 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_manager.cc +++ b/chrome/browser/chromeos/bluetooth/bluetooth_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +10,6 @@ #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" #include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h" #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" -#include "dbus/object_path.h" namespace chromeos { @@ -51,10 +50,9 @@ class BluetoothManagerImpl : public BluetoothManager, } // BluetoothManagerClient::Observer override. - virtual void AdapterRemoved(const dbus::ObjectPath& adapter) { - VLOG(1) << "AdapterRemoved: " << adapter.value(); - if (default_adapter_.get() == NULL - || default_adapter_->Id() != adapter.value()) { + virtual void AdapterRemoved(const std::string& adapter) { + VLOG(1) << "AdapterRemoved: " << adapter; + if (default_adapter_.get() == NULL || default_adapter_->Id() != adapter) { return; } // The default adapter was removed. @@ -64,8 +62,8 @@ class BluetoothManagerImpl : public BluetoothManager, } // BluetoothManagerClient::Observer override. - virtual void DefaultAdapterChanged(const dbus::ObjectPath& adapter) { - VLOG(1) << "DefaultAdapterChanged: " << adapter.value(); + virtual void DefaultAdapterChanged(const std::string& adapter) { + VLOG(1) << "DefaultAdapterChanged: " << adapter; OnNewDefaultAdapter(adapter); } @@ -75,13 +73,12 @@ class BluetoothManagerImpl : public BluetoothManager, } // We have updated info about the default adapter. - void OnNewDefaultAdapter(const dbus::ObjectPath& adapter) { - VLOG(1) << "OnNewDefaultAdapter: " << adapter.value(); - if (default_adapter_.get() != NULL - && default_adapter_->Id() == adapter.value()) { + void OnNewDefaultAdapter(const std::string& adapter) { + VLOG(1) << "OnNewDefaultAdapter: " << adapter; + if (default_adapter_.get() != NULL && default_adapter_->Id() == adapter) { return; } - default_adapter_.reset(BluetoothAdapter::Create(adapter.value())); + default_adapter_.reset(BluetoothAdapter::Create(adapter)); DCHECK(default_adapter_.get()); FOR_EACH_OBSERVER(BluetoothManager::Observer, observers_, DefaultAdapterChanged(default_adapter_.get())); @@ -89,12 +86,12 @@ class BluetoothManagerImpl : public BluetoothManager, // Called by bluetooth_manager_client when our DefaultAdapter request is // complete - void OnDefaultAdapter(const dbus::ObjectPath& adapter, bool success) { + void OnDefaultAdapter(const std::string& adapter, bool success) { if (!success) { LOG(ERROR) << "OnDefaultAdapter: failed."; return; } - VLOG(1) << "OnDefaultAdapter: " << adapter.value(); + VLOG(1) << "OnDefaultAdapter: " << adapter; OnNewDefaultAdapter(adapter); } diff --git a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc index bb62d53..54b772d 100644 --- a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc +++ b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.cc @@ -13,7 +13,6 @@ #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" @@ -143,11 +142,11 @@ bool PopArrayOfDictEntries(dbus::MessageReader* reader, break; } case dbus::Message::OBJECT_PATH: { - dbus::ObjectPath value; + std::string value; if (!variant_reader.PopObjectPath(&value)) { return false; } - dictionary->SetString(key, value.value()); + dictionary->SetString(key, value); break; } case dbus::Message::ARRAY: { @@ -209,8 +208,8 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, } // BluetoothAdapterClient override. - virtual void StartDiscovery(const dbus::ObjectPath& object_path) { - VLOG(1) << "StartDiscovery: " << object_path.value(); + virtual void StartDiscovery(const std::string& object_path) { + VLOG(1) << "StartDiscovery: " << object_path; dbus::MethodCall method_call( bluetooth_adapter::kBluetoothAdapterInterface, @@ -226,8 +225,8 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, } // BluetoothAdapterClient override. - virtual void StopDiscovery(const dbus::ObjectPath& object_path) { - VLOG(1) << "StopDiscovery: " << object_path.value(); + virtual void StopDiscovery(const std::string& object_path) { + VLOG(1) << "StopDiscovery: " << object_path; dbus::MethodCall method_call( bluetooth_adapter::kBluetoothAdapterInterface, @@ -244,22 +243,21 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, private: // BluetoothManagerClient::Observer override. - virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE { - VLOG(1) << "AdapterAdded: " << object_path.value(); + virtual void AdapterAdded(const std::string& object_path) OVERRIDE { + VLOG(1) << "AdapterAdded: " << object_path; } // BluetoothManagerClient::Observer override. - virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE { - VLOG(1) << "AdapterRemoved: " << object_path.value(); + virtual void AdapterRemoved(const std::string& object_path) OVERRIDE { + VLOG(1) << "AdapterRemoved: " << object_path; 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 dbus::ObjectPath& object_path) { - VLOG(1) << "GetObjectProxyForPath: " << object_path.value(); + dbus::ObjectProxy* GetObjectProxyForPath(const std::string& object_path) { + VLOG(1) << "GetObjectProxyForPath: " << object_path; ProxyMap::iterator it = proxy_map_.find(object_path); if (it != proxy_map_.end()) @@ -316,129 +314,126 @@ 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 dbus::ObjectPath& object_path) { - VLOG(1) << "RemoveObjectProxyForPath: " << object_path.value(); + void RemoveObjectProxyForPath(const std::string& object_path) { + VLOG(1) << "RemoveObjectProxyForPath: " << object_path; proxy_map_.erase(object_path); } // Called by dbus:: when a DeviceCreated signal is received. - void DeviceCreatedReceived(const dbus::ObjectPath& object_path, + void DeviceCreatedReceived(const std::string& object_path, dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); - dbus::ObjectPath device_path; + std::string device_path; if (!reader.PopObjectPath(&device_path)) { - LOG(ERROR) << object_path.value() - << ": DeviceCreated signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": DeviceCreated signal has incorrect parameters: " + << signal->ToString(); return; } - VLOG(1) << object_path.value() << ": Device created: " - << device_path.value(); + VLOG(1) << object_path << ": Device created: " << device_path; FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, DeviceCreated(object_path, device_path)); } // Called by dbus:: when the DeviceCreated signal is initially connected. - void DeviceCreatedConnected(const dbus::ObjectPath& object_path, + void DeviceCreatedConnected(const std::string& object_path, const std::string& interface_name, const std::string& signal_name, bool success) { - LOG_IF(WARNING, !success) << object_path.value() - << ": Failed to connect to DeviceCreated signal."; + LOG_IF(WARNING, !success) << object_path + << ": Failed to connect to DeviceCreated signal."; } // Called by dbus:: when a DeviceRemoved signal is received. - void DeviceRemovedReceived(const dbus::ObjectPath& object_path, + void DeviceRemovedReceived(const std::string& object_path, dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); - dbus::ObjectPath device_path; + std::string device_path; if (!reader.PopObjectPath(&device_path)) { - LOG(ERROR) << object_path.value() - << ": DeviceRemoved signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": DeviceRemoved signal has incorrect parameters: " + << signal->ToString(); return; } - VLOG(1) << object_path.value() << ": Device removed: " - << device_path.value(); + VLOG(1) << object_path << ": Device removed: " << device_path; FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, DeviceRemoved(object_path, device_path)); } // Called by dbus:: when the DeviceRemoved signal is initially connected. - void DeviceRemovedConnected(const dbus::ObjectPath& object_path, + void DeviceRemovedConnected(const std::string& object_path, const std::string& interface_name, const std::string& signal_name, bool success) { - LOG_IF(WARNING, !success) << object_path.value() - << ": Failed to connect to DeviceRemoved signal."; + LOG_IF(WARNING, !success) << object_path + << ": Failed to connect to DeviceRemoved signal."; } // Called by dbus:: when a PropertyChanged signal is received. - void PropertyChangedReceived(const dbus::ObjectPath& object_path, + void PropertyChangedReceived(const std::string& object_path, dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); std::string property_name; if (!reader.PopString(&property_name)) { - LOG(ERROR) << object_path.value() - << ": PropertyChanged signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": PropertyChanged signal has incorrect parameters: " + << signal->ToString(); return; } if (property_name != bluetooth_adapter::kDiscoveringProperty) { - VLOG(1) << object_path.value() << ": PropertyChanged: " << property_name; + VLOG(1) << object_path << ": PropertyChanged: " << property_name; // We don't care. return; } bool discovering = false; if (!reader.PopVariantOfBool(&discovering)) { - LOG(ERROR) << object_path.value() - << ": PropertyChanged signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": PropertyChanged signal has incorrect parameters: " + << signal->ToString(); return; } - VLOG(1) << object_path.value() << ": PropertyChanged: Discovering = " - << discovering; + VLOG(1) << object_path << ": 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 dbus::ObjectPath& object_path, + void PropertyChangedConnected(const std::string& object_path, const std::string& interface_name, const std::string& signal_name, bool success) { - LOG_IF(WARNING, !success) - << object_path.value() + LOG_IF(WARNING, !success) << object_path << ": Failed to connect to PropertyChanged signal."; } // Called by dbus:: when a DeviceFound signal is received. - void DeviceFoundReceived(const dbus::ObjectPath& object_path, + void DeviceFoundReceived(const std::string& object_path, dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); std::string address; if (!reader.PopString(&address)) { - LOG(ERROR) << object_path.value() - << ": DeviceFound signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": DeviceFound signal has incorrect parameters: " + << signal->ToString(); return; } - VLOG(1) << object_path.value() << ": Device found: " << address; + VLOG(1) << object_path << ": Device found: " << address; DictionaryValue device_properties; if (!PopArrayOfDictEntries(&reader, signal, &device_properties)) { - LOG(ERROR) << object_path.value() - << ": DeviceFound signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": DeviceFound signal has incorrect parameters: " + << signal->ToString(); return; } @@ -447,55 +442,52 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, } // Called by dbus:: when the DeviceFound signal is initially connected. - void DeviceFoundConnected(const dbus::ObjectPath& object_path, + void DeviceFoundConnected(const std::string& object_path, const std::string& interface_name, const std::string& signal_name, bool success) { - LOG_IF(WARNING, !success) << object_path.value() - << ": Failed to connect to DeviceFound signal."; + LOG_IF(WARNING, !success) << object_path + << ": Failed to connect to DeviceFound signal."; } // Called by dbus:: when a DeviceDisappeared signal is received. - void DeviceDisappearedReceived(const dbus::ObjectPath& object_path, + void DeviceDisappearedReceived(const std::string& object_path, dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); std::string address; if (!reader.PopString(&address)) { - LOG(ERROR) << object_path.value() - << ": DeviceDisappeared signal has incorrect parameters: " - << signal->ToString(); + LOG(ERROR) << object_path + << ": DeviceDisappeared signal has incorrect parameters: " + << signal->ToString(); return; } - VLOG(1) << object_path.value() << ": Device disappeared: " << address; + VLOG(1) << object_path << ": 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 dbus::ObjectPath& object_path, + void DeviceDisappearedConnected(const std::string& object_path, const std::string& interface_name, const std::string& signal_name, bool success) { - LOG_IF(WARNING, !success) - << object_path.value() + LOG_IF(WARNING, !success) << object_path << ": Failed to connect to DeviceDisappeared signal."; } // Called when a response for StartDiscovery() is received. - void OnStartDiscovery(const dbus::ObjectPath& object_path, + void OnStartDiscovery(const std::string& object_path, dbus::Response* response) { - VLOG(1) << "OnStartDiscovery: " << object_path.value(); - LOG_IF(WARNING, !response) << object_path.value() - << ": OnStartDiscovery: failed."; + VLOG(1) << "OnStartDiscovery: " << object_path; + LOG_IF(WARNING, !response) << object_path << ": OnStartDiscovery: failed."; } // Called when a response for StopDiscovery() is received. - void OnStopDiscovery(const dbus::ObjectPath& object_path, + void OnStopDiscovery(const std::string& object_path, dbus::Response* response) { - VLOG(1) << "OnStopDiscovery: " << object_path.value(); - LOG_IF(WARNING, !response) << object_path.value() - << ": OnStopDiscovery: failed."; + VLOG(1) << "OnStopDiscovery: " << object_path; + LOG_IF(WARNING, !response) << object_path << ": OnStopDiscovery: failed."; } // Weak pointer factory for generating 'this' pointers that might live longer @@ -505,7 +497,7 @@ class BluetoothAdapterClientImpl: public BluetoothAdapterClient, dbus::Bus* bus_; // We maintain a collection of dbus object proxies, one for each adapter. - typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap; + typedef std::map<const std::string, dbus::ObjectProxy*> ProxyMap; ProxyMap proxy_map_; // List of observers interested in event notifications from us. @@ -529,13 +521,13 @@ class BluetoothAdapterClientStubImpl : public BluetoothAdapterClient { } // BluetoothAdapterClient override. - virtual void StartDiscovery(const dbus::ObjectPath& object_path) { - VLOG(1) << "StartDiscovery: " << object_path.value(); + virtual void StartDiscovery(const std::string& object_path) { + VLOG(1) << "StartDiscovery: " << object_path; } // BluetoothAdapterClient override. - virtual void StopDiscovery(const dbus::ObjectPath& object_path) { - VLOG(1) << "StopDiscovery: " << object_path.value(); + virtual void StopDiscovery(const std::string& object_path) { + VLOG(1) << "StopDiscovery: " << object_path; } }; diff --git a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h index 2e7e0f0..e740100 100644 --- a/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h +++ b/chrome/browser/chromeos/dbus/bluetooth_adapter_client.h @@ -11,7 +11,6 @@ #include "base/callback.h" #include "base/observer_list.h" #include "base/values.h" -#include "dbus/object_path.h" namespace dbus { class Bus; @@ -31,25 +30,25 @@ class BluetoothAdapterClient { virtual ~Observer() {} // Called when a new known device has been created. - virtual void DeviceCreated(const dbus::ObjectPath& object_path, - const dbus::ObjectPath& device_path) {} + virtual void DeviceCreated(const std::string& object_path, + const std::string& device_path) {} // Called when a previously known device is removed. - virtual void DeviceRemoved(const dbus::ObjectPath& object_path, - const dbus::ObjectPath& device_path) {} + virtual void DeviceRemoved(const std::string& object_path, + const std::string& device_path) {} // Called when the adapter's Discovering property changes. - virtual void DiscoveringPropertyChanged(const dbus::ObjectPath& object_path, + virtual void DiscoveringPropertyChanged(const std::string& object_path, bool discovering) {} // Called when a new remote device has been discovered. // |device_properties| should be copied if needed. - virtual void DeviceFound(const dbus::ObjectPath& object_path, + virtual void DeviceFound(const std::string& object_path, const std::string& address, const DictionaryValue& device_properties) {} // Called when a previously discovered device is no longer visible. - virtual void DeviceDisappeared(const dbus::ObjectPath& object_path, + virtual void DeviceDisappeared(const std::string& object_path, const std::string& address) {} }; @@ -61,11 +60,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 dbus::ObjectPath& object_path) = 0; + virtual void StartDiscovery(const std::string& object_path) = 0; // Cancels any previous device discovery on the adapter with object path // |object_path|. - virtual void StopDiscovery(const dbus::ObjectPath& object_path) = 0; + virtual void StopDiscovery(const std::string& 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 78121fc..6069681 100644 --- a/chrome/browser/chromeos/dbus/bluetooth_device_client.cc +++ b/chrome/browser/chromeos/dbus/bluetooth_device_client.cc @@ -13,7 +13,6 @@ #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,24 +53,23 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, private: // BluetoothAdapterClient::Observer override. - virtual void DeviceCreated(const dbus::ObjectPath& adapter_path, - const dbus::ObjectPath& object_path) OVERRIDE { - VLOG(1) << "DeviceCreated: " << object_path.value(); + virtual void DeviceCreated(const std::string& adapter_path, + const std::string& object_path) OVERRIDE { + VLOG(1) << "DeviceCreated: " << object_path; } // BluetoothAdapterClient::Observer override. - virtual void DeviceRemoved(const dbus::ObjectPath& adapter_path, - const dbus::ObjectPath& object_path) OVERRIDE { - VLOG(1) << "DeviceRemoved: " << object_path.value(); + virtual void DeviceRemoved(const std::string& adapter_path, + const std::string& object_path) OVERRIDE { + VLOG(1) << "DeviceRemoved: " << object_path; 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 dbus::ObjectPath& object_path) { - VLOG(1) << "GetObjectProxyForPath: " << object_path.value(); + dbus::ObjectProxy* GetObjectProxyForPath(const std::string& object_path) { + VLOG(1) << "GetObjectProxyForPath: " << object_path; ProxyMap::iterator it = proxy_map_.find(object_path); if (it != proxy_map_.end()) @@ -88,8 +86,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 dbus::ObjectPath& object_path) { - VLOG(1) << "RemoveObjectProxyForPath: " << object_path.value(); + void RemoveObjectProxyForPath(const std::string& object_path) { + VLOG(1) << "RemoveObjectProxyForPath: " << object_path; proxy_map_.erase(object_path); } @@ -100,7 +98,7 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, dbus::Bus* bus_; // We maintain a collection of dbus object proxies, one for each device. - typedef std::map<const dbus::ObjectPath, dbus::ObjectProxy*> ProxyMap; + typedef std::map<const std::string, 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 f65fa84..12f1e8a 100644 --- a/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc +++ b/chrome/browser/chromeos/dbus/bluetooth_manager_client.cc @@ -9,7 +9,6 @@ #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" @@ -27,7 +26,7 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { bluetooth_manager_proxy_ = bus->GetObjectProxy( bluetooth_manager::kBluetoothManagerServiceName, - dbus::ObjectPath(bluetooth_manager::kBluetoothManagerServicePath)); + bluetooth_manager::kBluetoothManagerServicePath); bluetooth_manager_proxy_->ConnectToSignal( bluetooth_manager::kBluetoothManagerInterface, @@ -92,13 +91,13 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { void AdapterAddedReceived(dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); - dbus::ObjectPath object_path; + std::string 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.value(); + VLOG(1) << "Adapter added: " << object_path; FOR_EACH_OBSERVER(Observer, observers_, AdapterAdded(object_path)); } @@ -113,13 +112,13 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { void AdapterRemovedReceived(dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); - dbus::ObjectPath object_path; + std::string 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.value(); + VLOG(1) << "Adapter removed: " << object_path; FOR_EACH_OBSERVER(Observer, observers_, AdapterRemoved(object_path)); } @@ -134,14 +133,14 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { void DefaultAdapterChangedReceived(dbus::Signal* signal) { DCHECK(signal); dbus::MessageReader reader(signal); - dbus::ObjectPath object_path; - if (!reader.PopObjectPath(&object_path)) { + std::string adapter; + if (!reader.PopObjectPath(&adapter)) { LOG(ERROR) << "DefaultAdapterChanged signal has incorrect parameters: " - << signal->ToString(); + << signal->ToString(); return; } - VLOG(1) << "Default adapter changed: " << object_path.value(); - FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(object_path)); + VLOG(1) << "Default adapter changed: " << adapter; + FOR_EACH_OBSERVER(Observer, observers_, DefaultAdapterChanged(adapter)); } // Called by dbus:: when the DefaultAdapterChanged signal is initially @@ -158,15 +157,15 @@ class BluetoothManagerClientImpl : public BluetoothManagerClient { dbus::Response* response) { // Parse response. bool success = false; - dbus::ObjectPath adapter; + std::string 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.value(); + LOG(INFO) << "OnDefaultAdapter: " << adapter; } } 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 a74f925..394f9c9 100644 --- a/chrome/browser/chromeos/dbus/bluetooth_manager_client.h +++ b/chrome/browser/chromeos/dbus/bluetooth_manager_client.h @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/observer_list.h" -#include "dbus/object_path.h" namespace dbus { class Bus; @@ -29,16 +28,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 dbus::ObjectPath& object_path) {} + virtual void AdapterAdded(const std::string& object_path) {} // Called when a local bluetooth adapter is removed. // |object_path| is the dbus object path of the adapter. - virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {} + virtual void AdapterRemoved(const std::string& object_path) {} // Called when the default local bluetooth adapter changes. - // |object_path| is the dbus object path of the new default adapter. + // |adapter| is the dbus object path of the new default adapter. // Not called if all adapters are removed. - virtual void DefaultAdapterChanged(const dbus::ObjectPath& object_path) {} + virtual void DefaultAdapterChanged(const std::string& adapter) {} }; virtual ~BluetoothManagerClient(); @@ -48,9 +47,9 @@ class BluetoothManagerClient { virtual void RemoveObserver(Observer* observer) = 0; // The DefaultAdapterCallback receives two arguments: - // dbus::ObjectPath object_path - the path of the new default adapter + // std::string adapter - the unique identifier of the default adapter // bool success - whether or not the request succeeded - typedef base::Callback<void(const dbus::ObjectPath&, bool)> + typedef base::Callback<void(const std::string&, 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 5f912ed..bb1bdcb 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +11,6 @@ #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 { @@ -41,7 +40,7 @@ class CrosDBusServiceImpl : public CrosDBusService { exported_object_ = bus_->GetExportedObject( kLibCrosServiceName, - dbus::ObjectPath(kLibCrosServicePath)); + 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 3dc6359..649f678 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +11,6 @@ #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" @@ -49,12 +48,12 @@ class CrosDBusServiceTest : public testing::Test { mock_exported_object_ = new dbus::MockExportedObject(mock_bus_.get(), kLibCrosServiceName, - dbus::ObjectPath(kLibCrosServicePath)); + 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, dbus::ObjectPath(kLibCrosServicePath))) + kLibCrosServiceName, 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 210a71d..63e63df 100644 --- a/chrome/browser/chromeos/dbus/cros_disks_client.cc +++ b/chrome/browser/chromeos/dbus/cros_disks_client.cc @@ -9,7 +9,6 @@ #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" @@ -106,9 +105,8 @@ bool MaybePopArrayOfStrings(dbus::MessageReader* reader, class CrosDisksClientImpl : public CrosDisksClient { public: explicit CrosDisksClientImpl(dbus::Bus* bus) - : proxy_(bus->GetObjectProxy( - cros_disks::kCrosDisksServiceName, - dbus::ObjectPath(cros_disks::kCrosDisksServicePath))), + : proxy_(bus->GetObjectProxy(cros_disks::kCrosDisksServiceName, + 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 49ea93f..813ed47 100644 --- a/chrome/browser/chromeos/dbus/image_burner_client.cc +++ b/chrome/browser/chromeos/dbus/image_burner_client.cc @@ -9,7 +9,6 @@ #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,9 +22,8 @@ class ImageBurnerClientImpl : public ImageBurnerClient { explicit ImageBurnerClientImpl(dbus::Bus* bus) : proxy_(NULL), weak_ptr_factory_(this) { - proxy_ = bus->GetObjectProxy( - imageburn::kImageBurnServiceName, - dbus::ObjectPath(imageburn::kImageBurnServicePath)); + proxy_ = bus->GetObjectProxy(imageburn::kImageBurnServiceName, + 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 47c1c9d..6cd0de9 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 dbus::ObjectPath&)); - MOCK_METHOD1(StopDiscovery, void(const dbus::ObjectPath&)); + MOCK_METHOD1(StartDiscovery, void(const std::string&)); + MOCK_METHOD1(StopDiscovery, void(const std::string&)); }; } // namespace chromeos diff --git a/chrome/browser/chromeos/dbus/power_manager_client.cc b/chrome/browser/chromeos/dbus/power_manager_client.cc index 54e7ab7..1391dbfc 100644 --- a/chrome/browser/chromeos/dbus/power_manager_client.cc +++ b/chrome/browser/chromeos/dbus/power_manager_client.cc @@ -18,7 +18,6 @@ #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" @@ -64,7 +63,7 @@ class PowerManagerClientImpl : public PowerManagerClient { weak_ptr_factory_(this) { power_manager_proxy_ = bus->GetObjectProxy( power_manager::kPowerManagerServiceName, - dbus::ObjectPath(power_manager::kPowerManagerServicePath)); + 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 e7f3f9fb..9cbbdf5 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +22,6 @@ #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" @@ -81,7 +80,7 @@ class ProxyResolutionServiceProviderTest : public testing::Test { mock_exported_object_ = new dbus::MockExportedObject(mock_bus_.get(), kLibCrosServiceName, - dbus::ObjectPath(kLibCrosServicePath)); + kLibCrosServicePath); // |mock_exported_object_|'s ExportMethod() will use // |MockExportedObject(). @@ -103,7 +102,7 @@ class ProxyResolutionServiceProviderTest : public testing::Test { mock_object_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(), kLibCrosServiceName, - dbus::ObjectPath(kLibCrosServicePath)); + 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 f8c03f4..ff0dd8d 100644 --- a/chrome/browser/chromeos/dbus/sensors_client.cc +++ b/chrome/browser/chromeos/dbus/sensors_client.cc @@ -11,7 +11,6 @@ #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; @@ -32,9 +31,8 @@ class SensorsClientImpl : public SensorsClient { explicit SensorsClientImpl(dbus::Bus* bus) : sensors_proxy_(NULL), weak_ptr_factory_(this) { - sensors_proxy_ = bus->GetObjectProxy( - chromeos::kSensorsServiceName, - dbus::ObjectPath(chromeos::kSensorsServicePath)); + sensors_proxy_ = bus->GetObjectProxy(chromeos::kSensorsServiceName, + 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 a4b3579..b2643c7 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +10,6 @@ #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" @@ -24,7 +23,7 @@ class SessionManagerClientImpl : public SessionManagerClient { weak_ptr_factory_(this) { session_manager_proxy_ = bus->GetObjectProxy( login_manager::kSessionManagerServiceName, - dbus::ObjectPath(login_manager::kSessionManagerServicePath)); + 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 5c474c8..745b4ba 100644 --- a/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc +++ b/chrome/browser/chromeos/dbus/speech_synthesizer_client.cc @@ -9,7 +9,6 @@ #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" @@ -33,7 +32,7 @@ class SpeechSynthesizerClientImpl : public SpeechSynthesizerClient { weak_ptr_factory_(this) { proxy_ = bus->GetObjectProxy( speech_synthesis::kSpeechSynthesizerServiceName, - dbus::ObjectPath(speech_synthesis::kSpeechSynthesizerServicePath)); + 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 9352375..ed5cecb 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) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +10,6 @@ #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" @@ -55,7 +54,7 @@ class UpdateEngineClientImpl : public UpdateEngineClient { last_status_() { update_engine_proxy_ = bus->GetObjectProxy( update_engine::kUpdateEngineServiceName, - dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); + 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 diff --git a/chrome/browser/password_manager/native_backend_kwallet_x.cc b/chrome/browser/password_manager/native_backend_kwallet_x.cc index 787ed5b..d74898d 100644 --- a/chrome/browser/password_manager/native_backend_kwallet_x.cc +++ b/chrome/browser/password_manager/native_backend_kwallet_x.cc @@ -15,7 +15,6 @@ #include "content/public/browser/browser_thread.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "grit/chromium_strings.h" #include "ui/base/l10n/l10n_util.h" @@ -104,8 +103,7 @@ void NativeBackendKWallet::InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, session_bus_ = new dbus::Bus(options); } kwallet_proxy_ = - session_bus_->GetObjectProxy(kKWalletServiceName, - dbus::ObjectPath(kKWalletPath)); + session_bus_->GetObjectProxy(kKWalletServiceName, kKWalletPath); // kwalletd may not be running. If we get a temporary failure initializing it, // try to start it and then try again. (Note the short-circuit evaluation.) const InitResult result = InitWallet(); @@ -120,8 +118,7 @@ bool NativeBackendKWallet::StartKWalletd() { // Sadly kwalletd doesn't use DBus activation, so we have to make a call to // klauncher to start it. dbus::ObjectProxy* klauncher = - session_bus_->GetObjectProxy(kKLauncherServiceName, - dbus::ObjectPath(kKLauncherPath)); + session_bus_->GetObjectProxy(kKLauncherServiceName, kKLauncherPath); dbus::MethodCall method_call(kKLauncherInterface, "start_service_by_desktop_name"); diff --git a/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc b/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc index dbdcd20..a091be5 100644 --- a/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc +++ b/chrome/browser/password_manager/native_backend_kwallet_x_unittest.cc @@ -20,7 +20,6 @@ #include "dbus/message.h" #include "dbus/mock_bus.h" #include "dbus/mock_object_proxy.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -226,7 +225,7 @@ void NativeBackendKWalletTest::SetUp() { mock_klauncher_proxy_ = new dbus::MockObjectProxy(mock_session_bus_.get(), "org.kde.klauncher", - dbus::ObjectPath("/KLauncher")); + "/KLauncher"); EXPECT_CALL(*mock_klauncher_proxy_, CallMethodAndBlock(_, _)) .WillRepeatedly(Invoke(this, @@ -235,7 +234,7 @@ void NativeBackendKWalletTest::SetUp() { mock_kwallet_proxy_ = new dbus::MockObjectProxy(mock_session_bus_.get(), "org.kde.kwalletd", - dbus::ObjectPath("/modules/kwalletd")); + "/modules/kwalletd"); EXPECT_CALL(*mock_kwallet_proxy_, CallMethodAndBlock(_, _)) .WillRepeatedly(Invoke(this, @@ -243,11 +242,11 @@ void NativeBackendKWalletTest::SetUp() { EXPECT_CALL(*mock_session_bus_, GetObjectProxy( "org.kde.klauncher", - dbus::ObjectPath("/KLauncher"))) + "/KLauncher")) .WillRepeatedly(Return(mock_klauncher_proxy_.get())); EXPECT_CALL(*mock_session_bus_, GetObjectProxy( "org.kde.kwalletd", - dbus::ObjectPath("/modules/kwalletd"))) + "/modules/kwalletd")) .WillRepeatedly(Return(mock_kwallet_proxy_.get())); EXPECT_CALL(*mock_session_bus_, diff --git a/content/browser/geolocation/wifi_data_provider_linux.cc b/content/browser/geolocation/wifi_data_provider_linux.cc index a1f5237..178260a 100644 --- a/content/browser/geolocation/wifi_data_provider_linux.cc +++ b/content/browser/geolocation/wifi_data_provider_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,7 +13,6 @@ #include "base/utf_string_conversions.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" namespace { @@ -57,12 +56,12 @@ class NetworkManagerWlanApi : public WifiDataProviderCommon::WlanApiInterface { private: // Enumerates the list of available network adapter devices known to // NetworkManager. Return true on success. - bool GetAdapterDeviceList(std::vector<dbus::ObjectPath>* device_paths); + bool GetAdapterDeviceList(std::vector<std::string>* device_paths); // Given the NetworkManager path to a wireless adapater, dumps the wifi scan // results and appends them to |data|. Returns false if a fatal error is // encountered such that the data set could not be populated. - bool GetAccessPointsForAdapter(const dbus::ObjectPath& adapter_path, + bool GetAccessPointsForAdapter(const std::string& adapter_path, WifiData::AccessPointDataSet* data); // Internal method used by |GetAccessPointsForAdapter|, given a wifi access @@ -111,9 +110,9 @@ bool NetworkManagerWlanApi::InitWithBus(dbus::Bus* bus) { // system_bus_ will own all object proxies created from the bus. network_manager_proxy_ = system_bus_->GetObjectProxy(kNetworkManagerServiceName, - dbus::ObjectPath(kNetworkManagerPath)); + kNetworkManagerPath); // Validate the proxy object by checking we can enumerate devices. - std::vector<dbus::ObjectPath> adapter_paths; + std::vector<std::string> adapter_paths; const bool success = GetAdapterDeviceList(&adapter_paths); VLOG(1) << "Init() result: " << success; return success; @@ -121,7 +120,7 @@ bool NetworkManagerWlanApi::InitWithBus(dbus::Bus* bus) { bool NetworkManagerWlanApi::GetAccessPointData( WifiData::AccessPointDataSet* data) { - std::vector<dbus::ObjectPath> device_paths; + std::vector<std::string> device_paths; if (!GetAdapterDeviceList(&device_paths)) { LOG(WARNING) << "Could not enumerate access points"; return false; @@ -131,8 +130,8 @@ bool NetworkManagerWlanApi::GetAccessPointData( // Iterate the devices, getting APs for each wireless adapter found for (size_t i = 0; i < device_paths.size(); ++i) { - const dbus::ObjectPath& device_path = device_paths[i]; - VLOG(1) << "Checking device: " << device_path.value(); + const std::string& device_path = device_paths[i]; + VLOG(1) << "Checking device: " << device_path; dbus::ObjectProxy* device_proxy = system_bus_->GetObjectProxy(kNetworkManagerServiceName, @@ -147,8 +146,7 @@ bool NetworkManagerWlanApi::GetAccessPointData( &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response.get()) { - LOG(WARNING) << "Failed to get the device type for " - << device_path.value(); + LOG(WARNING) << "Failed to get the device type for " << device_path; continue; // Check the next device. } dbus::MessageReader reader(response.get()); @@ -172,7 +170,7 @@ bool NetworkManagerWlanApi::GetAccessPointData( } bool NetworkManagerWlanApi::GetAdapterDeviceList( - std::vector<dbus::ObjectPath>* device_paths) { + std::vector<std::string>* device_paths) { dbus::MethodCall method_call(kNetworkManagerInterface, "GetDevices"); scoped_ptr<dbus::Response> response( network_manager_proxy_->CallMethodAndBlock( @@ -193,7 +191,7 @@ bool NetworkManagerWlanApi::GetAdapterDeviceList( bool NetworkManagerWlanApi::GetAccessPointsForAdapter( - const dbus::ObjectPath& adapter_path, WifiData::AccessPointDataSet* data) { + const std::string& adapter_path, WifiData::AccessPointDataSet* data) { // Create a proxy object for this wifi adapter, and ask it to do a scan // (or at least, dump its scan results). dbus::ObjectProxy* device_proxy = @@ -207,24 +205,23 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response.get()) { - LOG(WARNING) << "Failed to get access points data for " - << adapter_path.value(); + LOG(WARNING) << "Failed to get access points data for " << adapter_path; return false; } dbus::MessageReader reader(response.get()); - std::vector<dbus::ObjectPath> access_point_paths; + std::vector<std::string> access_point_paths; if (!reader.PopArrayOfObjectPaths(&access_point_paths)) { - LOG(WARNING) << "Unexpected response for " << adapter_path.value() << ": " + LOG(WARNING) << "Unexpected response for " << adapter_path << ": " << response->ToString(); return false; } - VLOG(1) << "Wireless adapter " << adapter_path.value() << " found " + VLOG(1) << "Wireless adapter " << adapter_path << " found " << access_point_paths.size() << " access points."; for (size_t i = 0; i < access_point_paths.size(); ++i) { - const dbus::ObjectPath& access_point_path = access_point_paths[i]; - VLOG(1) << "Checking access point: " << access_point_path.value(); + const std::string& access_point_path = access_point_paths[i]; + VLOG(1) << "Checking access point: " << access_point_path; dbus::ObjectProxy* access_point_proxy = system_bus_->GetObjectProxy(kNetworkManagerServiceName, @@ -240,15 +237,15 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( dbus::MessageReader reader(response.get()); dbus::MessageReader variant_reader(response.get()); if (!reader.PopVariant(&variant_reader)) { - LOG(WARNING) << "Unexpected response for " << access_point_path.value() - << ": " << response->ToString(); + LOG(WARNING) << "Unexpected response for " << access_point_path << ": " + << response->ToString(); continue; } uint8* ssid_bytes = NULL; size_t ssid_length = 0; if (!variant_reader.PopArrayOfBytes(&ssid_bytes, &ssid_length)) { - LOG(WARNING) << "Unexpected response for " << access_point_path.value() - << ": " << response->ToString(); + LOG(WARNING) << "Unexpected response for " << access_point_path << ": " + << response->ToString(); continue; } std::string ssid(ssid_bytes, ssid_bytes + ssid_length); @@ -263,8 +260,8 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( dbus::MessageReader reader(response.get()); std::string mac; if (!reader.PopVariantOfString(&mac)) { - LOG(WARNING) << "Unexpected response for " << access_point_path.value() - << ": " << response->ToString(); + LOG(WARNING) << "Unexpected response for " << access_point_path << ": " + << response->ToString(); continue; } @@ -287,8 +284,8 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( dbus::MessageReader reader(response.get()); uint8 strength = 0; if (!reader.PopVariantOfByte(&strength)) { - LOG(WARNING) << "Unexpected response for " << access_point_path.value() - << ": " << response->ToString(); + LOG(WARNING) << "Unexpected response for " << access_point_path << ": " + << response->ToString(); continue; } // Convert strength as a percentage into dBs. @@ -303,8 +300,8 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( dbus::MessageReader reader(response.get()); uint32 frequency = 0; if (!reader.PopVariantOfUint32(&frequency)) { - LOG(WARNING) << "Unexpected response for " << access_point_path.value() - << ": " << response->ToString(); + LOG(WARNING) << "Unexpected response for " << access_point_path << ": " + << response->ToString(); continue; } @@ -312,7 +309,7 @@ bool NetworkManagerWlanApi::GetAccessPointsForAdapter( access_point_data.channel = frquency_in_khz_to_channel(frequency * 1000); } - VLOG(1) << "Access point data of " << access_point_path.value() << ": " + VLOG(1) << "Access point data of " << access_point_path << ": " << "SSID: " << access_point_data.ssid << ", " << "MAC: " << access_point_data.mac_address << ", " << "Strength: " << access_point_data.radio_signal_strength << ", " diff --git a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc index 94c56f2..e5a39b9 100644 --- a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc +++ b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +11,6 @@ #include "dbus/message.h" #include "dbus/mock_bus.h" #include "dbus/mock_object_proxy.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -30,10 +29,9 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { // Create a mock proxy that behaves as NetworkManager. mock_network_manager_proxy_ = - new dbus::MockObjectProxy( - mock_bus_.get(), - "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager")); + new dbus::MockObjectProxy(mock_bus_.get(), + "org.freedesktop.NetworkManager", + "/org/freedesktop/NetworkManager"); // Set an expectation so mock_network_manager_proxy_'s // CallMethodAndBlock() will use CreateNetowrkManagerProxyResponse() // to return responses. @@ -46,10 +44,9 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { // Create a mock proxy that behaves as NetworkManager/Devices/0. mock_device_proxy_ = - new dbus::MockObjectProxy( - mock_bus_.get(), - "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0")); + new dbus::MockObjectProxy(mock_bus_.get(), + "org.freedesktop.NetworkManager", + "/org/freedesktop/NetworkManager/Devices/0"); EXPECT_CALL(*mock_device_proxy_, CallMethodAndBlock(_, _)) .WillRepeatedly(Invoke( @@ -61,7 +58,7 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { new dbus::MockObjectProxy( mock_bus_.get(), "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0")); + "/org/freedesktop/NetworkManager/AccessPoint/0"); EXPECT_CALL(*mock_access_point_proxy_, CallMethodAndBlock(_, _)) .WillRepeatedly(Invoke( @@ -74,18 +71,18 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { // mock_network_manager_proxy_. EXPECT_CALL(*mock_bus_, GetObjectProxy( "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager"))) + "/org/freedesktop/NetworkManager")) .WillOnce(Return(mock_network_manager_proxy_.get())); // Likewise, set an expectation for mock_device_proxy_. EXPECT_CALL(*mock_bus_, GetObjectProxy( "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))) + "/org/freedesktop/NetworkManager/Devices/0")) .WillOnce(Return(mock_device_proxy_.get())) .WillOnce(Return(mock_device_proxy_.get())); // Likewise, set an expectation for mock_access_point_proxy_. EXPECT_CALL(*mock_bus_, GetObjectProxy( "org.freedesktop.NetworkManager", - dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0"))) + "/org/freedesktop/NetworkManager/AccessPoint/0")) .WillOnce(Return(mock_access_point_proxy_.get())); // ShutdownAndBlock() should be called. @@ -118,9 +115,8 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { if (method_call->GetInterface() == "org.freedesktop.NetworkManager" && method_call->GetMember() == "GetDevices") { // The list of devices is asked. Return the object path. - std::vector<dbus::ObjectPath> object_paths; - object_paths.push_back( - dbus::ObjectPath("/org/freedesktop/NetworkManager/Devices/0")); + std::vector<std::string> object_paths; + object_paths.push_back("/org/freedesktop/NetworkManager/Devices/0"); dbus::Response* response = dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response); @@ -156,9 +152,8 @@ class GeolocationWifiDataProviderLinuxTest : public testing::Test { // The list of access points is asked. Return the object path. dbus::Response* response = dbus::Response::CreateEmpty(); dbus::MessageWriter writer(response); - std::vector<dbus::ObjectPath> object_paths; - object_paths.push_back( - dbus::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/0")); + std::vector<std::string> object_paths; + object_paths.push_back("/org/freedesktop/NetworkManager/AccessPoint/0"); writer.AppendArrayOfObjectPaths(object_paths); return response; } diff --git a/content/browser/power_save_blocker_linux.cc b/content/browser/power_save_blocker_linux.cc index f08150a..5a5b29e 100644 --- a/content/browser/power_save_blocker_linux.cc +++ b/content/browser/power_save_blocker_linux.cc @@ -20,7 +20,6 @@ #include "content/public/browser/browser_thread.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" using content::BrowserThread; @@ -137,7 +136,7 @@ class KDEPowerSaveBlocker: public DBusPowerSaveBlocker::Delegate { scoped_refptr<dbus::ObjectProxy> object_proxy = DBusPowerSaveBlocker::GetInstance()->bus()->GetObjectProxy( "org.freedesktop.PowerManagement", - dbus::ObjectPath("/org/freedesktop/PowerManagement/Inhibit")); + "/org/freedesktop/PowerManagement/Inhibit"); dbus::MethodCall method_call("org.freedesktop.PowerManagement.Inhibit", "Inhibit"); dbus::MessageWriter message_writer(&method_call); @@ -285,7 +284,7 @@ class GnomePowerSaveBlocker: public DBusPowerSaveBlocker::Delegate { scoped_refptr<dbus::ObjectProxy> object_proxy = DBusPowerSaveBlocker::GetInstance()->bus()->GetObjectProxy( "org.gnome.SessionManager", - dbus::ObjectPath("/org/gnome/SessionManager")); + "/org/gnome/SessionManager"); dbus::MethodCall method_call("org.gnome.SessionManager", "Inhibit"); dbus::MessageWriter message_writer(&method_call); base::Callback<void(dbus::Response*)> bus_callback; diff --git a/dbus/bus.cc b/dbus/bus.cc index 3b2f059..0c6a421 100644 --- a/dbus/bus.cc +++ b/dbus/bus.cc @@ -16,7 +16,6 @@ #include "base/threading/thread_restrictions.h" #include "base/time.h" #include "dbus/exported_object.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "dbus/scoped_dbus_error.h" @@ -208,19 +207,18 @@ Bus::~Bus() { } ObjectProxy* Bus::GetObjectProxy(const std::string& service_name, - const ObjectPath& object_path) { + const std::string& object_path) { return GetObjectProxyWithOptions(service_name, object_path, ObjectProxy::DEFAULT_OPTIONS); } ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name, - const dbus::ObjectPath& object_path, + const std::string& object_path, int options) { AssertOnOriginThread(); // Check if we already have the requested object proxy. - const ObjectProxyTable::key_type key(service_name + object_path.value(), - options); + const ObjectProxyTable::key_type key(service_name + object_path, options); ObjectProxyTable::iterator iter = object_proxy_table_.find(key); if (iter != object_proxy_table_.end()) { return iter->second; @@ -234,11 +232,11 @@ ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name, } ExportedObject* Bus::GetExportedObject(const std::string& service_name, - const ObjectPath& object_path) { + const std::string& object_path) { AssertOnOriginThread(); // Check if we already have the requested exported object. - const std::string key = service_name + object_path.value(); + const std::string key = service_name + object_path; ExportedObjectTable::iterator iter = exported_object_table_.find(key); if (iter != exported_object_table_.end()) { return iter->second; @@ -523,7 +521,7 @@ void Bus::RemoveMatch(const std::string& match_rule, DBusError* error) { match_rules_added_.erase(match_rule); } -bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, +bool Bus::TryRegisterObjectPath(const std::string& object_path, const DBusObjectPathVTable* vtable, void* user_data, DBusError* error) { @@ -532,13 +530,13 @@ bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, if (registered_object_paths_.find(object_path) != registered_object_paths_.end()) { - LOG(ERROR) << "Object path already registered: " << object_path.value(); + LOG(ERROR) << "Object path already registered: " << object_path; return false; } const bool success = dbus_connection_try_register_object_path( connection_, - object_path.value().c_str(), + object_path.c_str(), vtable, user_data, error); @@ -547,20 +545,20 @@ bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, return success; } -void Bus::UnregisterObjectPath(const ObjectPath& object_path) { +void Bus::UnregisterObjectPath(const std::string& object_path) { DCHECK(connection_); AssertOnDBusThread(); if (registered_object_paths_.find(object_path) == registered_object_paths_.end()) { LOG(ERROR) << "Requested to unregister an unknown object path: " - << object_path.value(); + << object_path; return; } const bool success = dbus_connection_unregister_object_path( connection_, - object_path.value().c_str()); + object_path.c_str()); CHECK(success) << "Unable to allocate memory"; registered_object_paths_.erase(object_path); } @@ -17,7 +17,6 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" #include "base/tracked_objects.h" -#include "dbus/object_path.h" class MessageLoop; @@ -113,7 +112,7 @@ class ObjectProxy; // } // // void OnExported(const std::string& interface_name, -// const ObjectPath& object_path, +// const std::string& object_path, // bool success) { // // success is true if the method was exported successfully. // } @@ -195,13 +194,13 @@ class Bus : public base::RefCountedThreadSafe<Bus> { // // Must be called in the origin thread. virtual ObjectProxy* GetObjectProxy(const std::string& service_name, - const ObjectPath& object_path); + const std::string& object_path); // Same as above, but also takes a bitfield of ObjectProxy::Options. // See object_proxy.h for available options. virtual ObjectProxy* GetObjectProxyWithOptions( const std::string& service_name, - const ObjectPath& object_path, + const std::string& object_path, int options); // Gets the exported object for the given service name and the object @@ -220,7 +219,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { // // Must be called in the origin thread. virtual ExportedObject* GetExportedObject(const std::string& service_name, - const ObjectPath& object_path); + const std::string& object_path); // Shuts down the bus and blocks until it's done. More specifically, this // function does the following: @@ -354,7 +353,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { // http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html // // BLOCKING CALL. - virtual bool TryRegisterObjectPath(const ObjectPath& object_path, + virtual bool TryRegisterObjectPath(const std::string& object_path, const DBusObjectPathVTable* vtable, void* user_data, DBusError* error); @@ -362,7 +361,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { // Unregister the object path. // // BLOCKING CALL. - virtual void UnregisterObjectPath(const ObjectPath& object_path); + virtual void UnregisterObjectPath(const std::string& object_path); // Posts the task to the message loop of the thread that created the bus. virtual void PostTaskToOriginThread( @@ -462,7 +461,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { // The following sets are used to check if rules/object_paths/filters // are properly cleaned up before destruction of the bus object. std::set<std::string> match_rules_added_; - std::set<ObjectPath> registered_object_paths_; + std::set<std::string> registered_object_paths_; std::set<std::pair<DBusHandleMessageFunction, void*> > filter_functions_added_; diff --git a/dbus/bus_unittest.cc b/dbus/bus_unittest.cc index c66a05b..c21044b 100644 --- a/dbus/bus_unittest.cc +++ b/dbus/bus_unittest.cc @@ -9,7 +9,6 @@ #include "base/memory/ref_counted.h" #include "base/threading/thread.h" #include "dbus/exported_object.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "testing/gtest/include/gtest/gtest.h" @@ -31,21 +30,20 @@ TEST(BusTest, GetObjectProxy) { dbus::ObjectProxy* object_proxy1 = bus->GetObjectProxy("org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); ASSERT_TRUE(object_proxy1); // This should return the same object. dbus::ObjectProxy* object_proxy2 = bus->GetObjectProxy("org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); ASSERT_TRUE(object_proxy2); EXPECT_EQ(object_proxy1, object_proxy2); // This should not. dbus::ObjectProxy* object_proxy3 = - bus->GetObjectProxy( - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/DifferentTestObject")); + bus->GetObjectProxy("org.chromium.TestService", + "/org/chromium/DifferentTestObject"); ASSERT_TRUE(object_proxy3); EXPECT_NE(object_proxy1, object_proxy3); @@ -59,7 +57,7 @@ TEST(BusTest, GetObjectProxyIgnoreUnknownService) { dbus::ObjectProxy* object_proxy1 = bus->GetObjectProxyWithOptions( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject"), + "/org/chromium/TestObject", dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); ASSERT_TRUE(object_proxy1); @@ -67,7 +65,7 @@ TEST(BusTest, GetObjectProxyIgnoreUnknownService) { dbus::ObjectProxy* object_proxy2 = bus->GetObjectProxyWithOptions( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject"), + "/org/chromium/TestObject", dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); ASSERT_TRUE(object_proxy2); EXPECT_EQ(object_proxy1, object_proxy2); @@ -76,7 +74,7 @@ TEST(BusTest, GetObjectProxyIgnoreUnknownService) { dbus::ObjectProxy* object_proxy3 = bus->GetObjectProxyWithOptions( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/DifferentTestObject"), + "/org/chromium/DifferentTestObject", dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); ASSERT_TRUE(object_proxy3); EXPECT_NE(object_proxy1, object_proxy3); @@ -90,21 +88,20 @@ TEST(BusTest, GetExportedObject) { dbus::ExportedObject* object_proxy1 = bus->GetExportedObject("org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); ASSERT_TRUE(object_proxy1); // This should return the same object. dbus::ExportedObject* object_proxy2 = bus->GetExportedObject("org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); ASSERT_TRUE(object_proxy2); EXPECT_EQ(object_proxy1, object_proxy2); // This should not. dbus::ExportedObject* object_proxy3 = - bus->GetExportedObject( - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/DifferentTestObject")); + bus->GetExportedObject("org.chromium.TestService", + "/org/chromium/DifferentTestObject"); ASSERT_TRUE(object_proxy3); EXPECT_NE(object_proxy1, object_proxy3); diff --git a/dbus/dbus.gyp b/dbus/dbus.gyp index 8a3cb22..2dc8fee 100644 --- a/dbus/dbus.gyp +++ b/dbus/dbus.gyp @@ -25,8 +25,6 @@ 'exported_object.h', 'message.cc', 'message.h', - 'object_path.cc', - 'object_path.h', 'object_proxy.cc', 'object_proxy.h', 'scoped_dbus_error.h', diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc index 9a88b42..150ed29 100644 --- a/dbus/end_to_end_async_unittest.cc +++ b/dbus/end_to_end_async_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -15,7 +15,6 @@ #include "base/threading/thread_restrictions.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "dbus/test_service.h" #include "testing/gtest/include/gtest/gtest.h" @@ -52,9 +51,8 @@ class EndToEndAsyncTest : public testing::Test { bus_options.dbus_thread_message_loop_proxy = dbus_thread_->message_loop_proxy(); bus_ = new dbus::Bus(bus_options); - object_proxy_ = bus_->GetObjectProxy( - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", + "/org/chromium/TestObject"); ASSERT_TRUE(bus_->HasDBusThread()); // Connect to the "Test" signal of "org.chromium.TestInterface" from diff --git a/dbus/end_to_end_sync_unittest.cc b/dbus/end_to_end_sync_unittest.cc index 26a9011..c338809 100644 --- a/dbus/end_to_end_sync_unittest.cc +++ b/dbus/end_to_end_sync_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,7 +6,6 @@ #include "base/memory/scoped_ptr.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "dbus/test_service.h" #include "testing/gtest/include/gtest/gtest.h" @@ -32,9 +31,8 @@ class EndToEndSyncTest : public testing::Test { client_bus_options.bus_type = dbus::Bus::SESSION; client_bus_options.connection_type = dbus::Bus::PRIVATE; client_bus_ = new dbus::Bus(client_bus_options); - object_proxy_ = client_bus_->GetObjectProxy( - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + object_proxy_ = client_bus_->GetObjectProxy("org.chromium.TestService", + "/org/chromium/TestObject"); ASSERT_FALSE(client_bus_->HasDBusThread()); } diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc index 730c98b..de25168 100644 --- a/dbus/exported_object.cc +++ b/dbus/exported_object.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,7 +13,6 @@ #include "base/time.h" #include "dbus/bus.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/scoped_dbus_error.h" namespace dbus { @@ -36,7 +35,7 @@ std::string GetAbsoluteMethodName( ExportedObject::ExportedObject(Bus* bus, const std::string& service_name, - const ObjectPath& object_path) + const std::string& object_path) : bus_(bus), service_name_(service_name), object_path_(object_path), @@ -176,8 +175,8 @@ bool ExportedObject::Register() { this, error.get()); if (!success) { - LOG(ERROR) << "Failed to register the object: " << object_path_.value() - << ": " << (error.is_set() ? error.message() : ""); + LOG(ERROR) << "Failed to register the object: " << object_path_ << ": " + << (error.is_set() ? error.message() : ""); return false; } diff --git a/dbus/exported_object.h b/dbus/exported_object.h index 24db66e..7ac2f88 100644 --- a/dbus/exported_object.h +++ b/dbus/exported_object.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -17,7 +17,6 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" #include "base/time.h" -#include "dbus/object_path.h" namespace dbus { @@ -37,7 +36,7 @@ class ExportedObject : public base::RefCountedThreadSafe<ExportedObject> { // constructor. ExportedObject(Bus* bus, const std::string& service_name, - const ObjectPath& object_path); + const std::string& object_path); // Called to send a response from an exported method. Response* is the // response message. Callers should pass a NULL Response* in the event @@ -158,7 +157,7 @@ class ExportedObject : public base::RefCountedThreadSafe<ExportedObject> { scoped_refptr<Bus> bus_; std::string service_name_; - ObjectPath object_path_; + std::string object_path_; bool object_is_registered_; // The method table where keys are absolute method names (i.e. interface diff --git a/dbus/message.cc b/dbus/message.cc index 486538a..4a94b54 100644 --- a/dbus/message.cc +++ b/dbus/message.cc @@ -10,7 +10,6 @@ #include "base/format_macros.h" #include "base/logging.h" #include "base/stringprintf.h" -#include "dbus/object_path.h" #include "third_party/protobuf/src/google/protobuf/message_lite.h" namespace { @@ -158,10 +157,10 @@ std::string Message::ToStringInternal(const std::string& indent, break; } case OBJECT_PATH: { - ObjectPath value; + std::string value; if (!reader->PopObjectPath(&value)) return kBrokenMessage; - output += indent + "object_path \"" + value.value() + "\"\n"; + output += indent + "object_path \"" + value + "\"\n"; break; } case ARRAY: { @@ -225,7 +224,7 @@ std::string Message::ToString() { std::string headers; AppendStringHeader("message_type", GetMessageTypeAsString(), &headers); AppendStringHeader("destination", GetDestination(), &headers); - AppendStringHeader("path", GetPath().value(), &headers); + AppendStringHeader("path", GetPath(), &headers); AppendStringHeader("interface", GetInterface(), &headers); AppendStringHeader("member", GetMember(), &headers); AppendStringHeader("error_name", GetErrorName(), &headers); @@ -245,9 +244,9 @@ void Message::SetDestination(const std::string& destination) { CHECK(success) << "Unable to allocate memory"; } -void Message::SetPath(const ObjectPath& path) { +void Message::SetPath(const std::string& path) { const bool success = dbus_message_set_path(raw_message_, - path.value().c_str()); + path.c_str()); CHECK(success) << "Unable to allocate memory"; } @@ -288,9 +287,9 @@ std::string Message::GetDestination() { return destination ? destination : ""; } -ObjectPath Message::GetPath() { +std::string Message::GetPath() { const char* path = dbus_message_get_path(raw_message_); - return ObjectPath(path ? path : ""); + return path ? path : ""; } std::string Message::GetInterface() { @@ -491,8 +490,8 @@ void MessageWriter::AppendString(const std::string& value) { // bool AppendStringWithErrorChecking(). } -void MessageWriter::AppendObjectPath(const ObjectPath& value) { - const char* pointer = value.value().c_str(); +void MessageWriter::AppendObjectPath(const std::string& value) { + const char* pointer = value.c_str(); AppendBasic(DBUS_TYPE_OBJECT_PATH, &pointer); } @@ -588,7 +587,7 @@ void MessageWriter::AppendArrayOfStrings( } void MessageWriter::AppendArrayOfObjectPaths( - const std::vector<ObjectPath>& object_paths) { + const std::vector<std::string>& object_paths) { DCHECK(!container_is_open_); MessageWriter array_writer(message_); OpenArray("o", &array_writer); @@ -653,8 +652,8 @@ void MessageWriter::AppendVariantOfString(const std::string& value) { AppendVariantOfBasic(DBUS_TYPE_STRING, &pointer); } -void MessageWriter::AppendVariantOfObjectPath(const ObjectPath& value) { - const char* pointer = value.value().c_str(); +void MessageWriter::AppendVariantOfObjectPath(const std::string& value) { + const char* pointer = value.c_str(); AppendVariantOfBasic(DBUS_TYPE_OBJECT_PATH, &pointer); } @@ -747,11 +746,11 @@ bool MessageReader::PopString(std::string* value) { return success; } -bool MessageReader::PopObjectPath(ObjectPath* value) { +bool MessageReader::PopObjectPath(std::string* value) { char* tmp_value = NULL; const bool success = PopBasic(DBUS_TYPE_OBJECT_PATH, &tmp_value); if (success) - *value = ObjectPath(tmp_value); + value->assign(tmp_value); return success; } @@ -806,12 +805,12 @@ bool MessageReader::PopArrayOfStrings( } bool MessageReader::PopArrayOfObjectPaths( - std::vector<ObjectPath> *object_paths) { + std::vector<std::string> *object_paths) { MessageReader array_reader(message_); if (!PopArray(&array_reader)) return false; while (array_reader.HasMoreData()) { - ObjectPath object_path; + std::string object_path; if (!array_reader.PopObjectPath(&object_path)) return false; object_paths->push_back(object_path); @@ -883,11 +882,11 @@ bool MessageReader::PopVariantOfString(std::string* value) { return success; } -bool MessageReader::PopVariantOfObjectPath(ObjectPath* value) { +bool MessageReader::PopVariantOfObjectPath(std::string* value) { char* tmp_value = NULL; const bool success = PopVariantOfBasic(DBUS_TYPE_OBJECT_PATH, &tmp_value); if (success) - *value = ObjectPath(tmp_value); + value->assign(tmp_value); return success; } diff --git a/dbus/message.h b/dbus/message.h index 4683abe..54227a0 100644 --- a/dbus/message.h +++ b/dbus/message.h @@ -11,7 +11,6 @@ #include <dbus/dbus.h> #include "base/basictypes.h" -#include "dbus/object_path.h" namespace google { namespace protobuf { @@ -81,7 +80,7 @@ class Message { // Sets the destination, the path, the interface, the member, etc. void SetDestination(const std::string& destination); - void SetPath(const ObjectPath& path); + void SetPath(const std::string& path); void SetInterface(const std::string& interface); void SetMember(const std::string& member); void SetErrorName(const std::string& error_name); @@ -93,7 +92,7 @@ class Message { // Gets the destination, the path, the interface, the member, etc. // If not set, an empty string is returned. std::string GetDestination(); - ObjectPath GetPath(); + std::string GetPath(); std::string GetInterface(); std::string GetMember(); std::string GetErrorName(); @@ -266,7 +265,7 @@ class MessageWriter { void AppendUint64(uint64 value); void AppendDouble(double value); void AppendString(const std::string& value); - void AppendObjectPath(const ObjectPath& value); + void AppendObjectPath(const std::string& value); // Opens an array. The array contents can be added to the array with // |sub_writer|. The client code must close the array with @@ -303,7 +302,7 @@ class MessageWriter { // Appends the array of object paths. Arrays of object paths are often // used when exchanging object paths, hence it's worth having a // specialized function. - void AppendArrayOfObjectPaths(const std::vector<ObjectPath>& object_paths); + void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths); // Appends the protocol buffer as an array of bytes. The buffer is serialized // into an array of bytes before communication, since protocol buffers are not @@ -327,7 +326,7 @@ class MessageWriter { void AppendVariantOfUint64(uint64 value); void AppendVariantOfDouble(double value); void AppendVariantOfString(const std::string& value); - void AppendVariantOfObjectPath(const ObjectPath& value); + void AppendVariantOfObjectPath(const std::string& value); private: // Helper function used to implement AppendByte etc. @@ -375,7 +374,7 @@ class MessageReader { bool PopUint64(uint64* value); bool PopDouble(double* value); bool PopString(std::string* value); - bool PopObjectPath(ObjectPath* value); + bool PopObjectPath(std::string* value); // Sets up the given message reader to read an array at the current // iterator position. @@ -410,7 +409,7 @@ class MessageReader { // Arrays of object paths are often used to communicate with D-Bus // services like NetworkManager, hence it's worth having a specialized // function. - bool PopArrayOfObjectPaths(std::vector<ObjectPath>* object_paths); + bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths); // Gets the array of bytes at the current iterator position. It then parses // this binary blob into the protocol buffer supplied. @@ -437,7 +436,7 @@ class MessageReader { bool PopVariantOfUint64(uint64* value); bool PopVariantOfDouble(double* value); bool PopVariantOfString(std::string* value); - bool PopVariantOfObjectPath(ObjectPath* value); + bool PopVariantOfObjectPath(std::string* value); // Get the data type of the value at the current iterator // position. INVALID_DATA will be returned if the iterator points to the diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc index a40ba0aa..1e6d668 100644 --- a/dbus/message_unittest.cc +++ b/dbus/message_unittest.cc @@ -7,7 +7,6 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "dbus/object_path.h" #include "dbus/test_proto.pb.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,7 +50,7 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) { writer.AppendUint64(7); writer.AppendDouble(8.0); writer.AppendString("string"); - writer.AppendObjectPath(dbus::ObjectPath("/object/path")); + writer.AppendObjectPath("/object/path"); uint8 byte_value = 0; bool bool_value = false; @@ -63,7 +62,7 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) { uint64 uint64_value = 0; double double_value = 0; std::string string_value; - dbus::ObjectPath object_path_value; + std::string object_path_value; dbus::MessageReader reader(message.get()); ASSERT_TRUE(reader.HasMoreData()); @@ -91,7 +90,7 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) { EXPECT_EQ(7U, uint64_value); EXPECT_DOUBLE_EQ(8.0, double_value); EXPECT_EQ("string", string_value); - EXPECT_EQ(dbus::ObjectPath("/object/path"), object_path_value); + EXPECT_EQ("/object/path", object_path_value); } // Check all variant types can be properly written and read. @@ -110,7 +109,7 @@ TEST(MessageTest, AppendAndPopVariantDataTypes) { writer.AppendVariantOfUint64(7); writer.AppendVariantOfDouble(8.0); writer.AppendVariantOfString("string"); - writer.AppendVariantOfObjectPath(dbus::ObjectPath("/object/path")); + writer.AppendVariantOfObjectPath("/object/path"); uint8 byte_value = 0; bool bool_value = false; @@ -122,7 +121,7 @@ TEST(MessageTest, AppendAndPopVariantDataTypes) { uint64 uint64_value = 0; double double_value = 0; std::string string_value; - dbus::ObjectPath object_path_value; + std::string object_path_value; dbus::MessageReader reader(message.get()); ASSERT_TRUE(reader.HasMoreData()); @@ -150,7 +149,7 @@ TEST(MessageTest, AppendAndPopVariantDataTypes) { EXPECT_EQ(7U, uint64_value); EXPECT_DOUBLE_EQ(8.0, double_value); EXPECT_EQ("string", string_value); - EXPECT_EQ(dbus::ObjectPath("/object/path"), object_path_value); + EXPECT_EQ("/object/path", object_path_value); } TEST(MessageTest, ArrayOfBytes) { @@ -212,20 +211,20 @@ TEST(MessageTest, ArrayOfStrings) { TEST(MessageTest, ArrayOfObjectPaths) { scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); dbus::MessageWriter writer(message.get()); - std::vector<dbus::ObjectPath> object_paths; - object_paths.push_back(dbus::ObjectPath("/object/path/1")); - object_paths.push_back(dbus::ObjectPath("/object/path/2")); - object_paths.push_back(dbus::ObjectPath("/object/path/3")); + std::vector<std::string> object_paths; + object_paths.push_back("/object/path/1"); + object_paths.push_back("/object/path/2"); + object_paths.push_back("/object/path/3"); writer.AppendArrayOfObjectPaths(object_paths); dbus::MessageReader reader(message.get()); - std::vector<dbus::ObjectPath> output_object_paths; + std::vector<std::string> output_object_paths; ASSERT_TRUE(reader.PopArrayOfObjectPaths(&output_object_paths)); ASSERT_FALSE(reader.HasMoreData()); ASSERT_EQ(3U, output_object_paths.size()); - EXPECT_EQ(dbus::ObjectPath("/object/path/1"), output_object_paths[0]); - EXPECT_EQ(dbus::ObjectPath("/object/path/2"), output_object_paths[1]); - EXPECT_EQ(dbus::ObjectPath("/object/path/3"), output_object_paths[2]); + EXPECT_EQ("/object/path/1", output_object_paths[0]); + EXPECT_EQ("/object/path/2", output_object_paths[1]); + EXPECT_EQ("/object/path/3", output_object_paths[2]); } TEST(MessageTest, ProtoBuf) { @@ -409,7 +408,7 @@ TEST(MessageTest, MethodCall) { EXPECT_EQ(dbus::Message::MESSAGE_METHOD_CALL, method_call.GetMessageType()); EXPECT_EQ("MESSAGE_METHOD_CALL", method_call.GetMessageTypeAsString()); method_call.SetDestination("com.example.Service"); - method_call.SetPath(dbus::ObjectPath("/com/example/Object")); + method_call.SetPath("/com/example/Object"); dbus::MessageWriter writer(&method_call); writer.AppendString("payload"); @@ -441,7 +440,7 @@ TEST(MessageTest, Signal) { EXPECT_TRUE(signal.raw_message() != NULL); EXPECT_EQ(dbus::Message::MESSAGE_SIGNAL, signal.GetMessageType()); EXPECT_EQ("MESSAGE_SIGNAL", signal.GetMessageTypeAsString()); - signal.SetPath(dbus::ObjectPath("/com/example/Object")); + signal.SetPath("/com/example/Object"); dbus::MessageWriter writer(&signal); writer.AppendString("payload"); @@ -514,7 +513,7 @@ TEST(MessageTest, GetAndSetHeaders) { scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); EXPECT_EQ("", message->GetDestination()); - EXPECT_EQ(dbus::ObjectPath(""), message->GetPath()); + EXPECT_EQ("", message->GetPath()); EXPECT_EQ("", message->GetInterface()); EXPECT_EQ("", message->GetMember()); EXPECT_EQ("", message->GetErrorName()); @@ -523,7 +522,7 @@ TEST(MessageTest, GetAndSetHeaders) { EXPECT_EQ(0U, message->GetReplySerial()); message->SetDestination("org.chromium.destination"); - message->SetPath(dbus::ObjectPath("/org/chromium/path")); + message->SetPath("/org/chromium/path"); message->SetInterface("org.chromium.interface"); message->SetMember("member"); message->SetErrorName("org.chromium.error"); @@ -532,7 +531,7 @@ TEST(MessageTest, GetAndSetHeaders) { message->SetReplySerial(456); EXPECT_EQ("org.chromium.destination", message->GetDestination()); - EXPECT_EQ(dbus::ObjectPath("/org/chromium/path"), message->GetPath()); + EXPECT_EQ("/org/chromium/path", message->GetPath()); EXPECT_EQ("org.chromium.interface", message->GetInterface()); EXPECT_EQ("member", message->GetMember()); EXPECT_EQ("org.chromium.error", message->GetErrorName()); diff --git a/dbus/mock_bus.h b/dbus/mock_bus.h index 463790a..31c1349 100644 --- a/dbus/mock_bus.h +++ b/dbus/mock_bus.h @@ -7,7 +7,6 @@ #pragma once #include "dbus/bus.h" -#include "dbus/object_path.h" #include "testing/gmock/include/gmock/gmock.h" namespace dbus { @@ -21,14 +20,14 @@ class MockBus : public Bus { virtual ~MockBus(); MOCK_METHOD2(GetObjectProxy, ObjectProxy*(const std::string& service_name, - const ObjectPath& object_path)); + const std::string& object_path)); MOCK_METHOD3(GetObjectProxyWithOptions, ObjectProxy*(const std::string& service_name, - const ObjectPath& object_path, + const std::string& object_path, int options)); MOCK_METHOD2(GetExportedObject, ExportedObject*( const std::string& service_name, - const ObjectPath& object_path)); + const std::string& object_path)); MOCK_METHOD0(ShutdownAndBlock, void()); MOCK_METHOD0(ShutdownOnDBusThreadAndBlock, void()); MOCK_METHOD0(Connect, bool()); @@ -51,11 +50,11 @@ class MockBus : public Bus { DBusError* error)); MOCK_METHOD2(RemoveMatch, void(const std::string& match_rule, DBusError* error)); - MOCK_METHOD4(TryRegisterObjectPath, bool(const ObjectPath& object_path, + MOCK_METHOD4(TryRegisterObjectPath, bool(const std::string& object_path, const DBusObjectPathVTable* vtable, void* user_data, DBusError* error)); - MOCK_METHOD1(UnregisterObjectPath, void(const ObjectPath& object_path)); + MOCK_METHOD1(UnregisterObjectPath, void(const std::string& object_path)); MOCK_METHOD2(PostTaskToOriginThread, void( const tracked_objects::Location& from_here, const base::Closure& task)); diff --git a/dbus/mock_exported_object.cc b/dbus/mock_exported_object.cc index f49cd3d..0fd4f2e 100644 --- a/dbus/mock_exported_object.cc +++ b/dbus/mock_exported_object.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,7 +8,7 @@ namespace dbus { MockExportedObject::MockExportedObject(Bus* bus, const std::string& service_name, - const ObjectPath& object_path) + const std::string& object_path) : ExportedObject(bus, service_name, object_path) { } diff --git a/dbus/mock_exported_object.h b/dbus/mock_exported_object.h index 7deb111..17a36d0 100644 --- a/dbus/mock_exported_object.h +++ b/dbus/mock_exported_object.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,7 +9,6 @@ #include <string> #include "dbus/exported_object.h" -#include "dbus/object_path.h" #include "testing/gmock/include/gmock/gmock.h" namespace dbus { @@ -19,7 +18,7 @@ class MockExportedObject : public ExportedObject { public: MockExportedObject(Bus* bus, const std::string& service_name, - const ObjectPath& object_path); + const std::string& object_path); virtual ~MockExportedObject(); MOCK_METHOD3(ExportMethodAndBlock, diff --git a/dbus/mock_object_proxy.cc b/dbus/mock_object_proxy.cc index 7e26f01..a7186bb 100644 --- a/dbus/mock_object_proxy.cc +++ b/dbus/mock_object_proxy.cc @@ -8,7 +8,7 @@ namespace dbus { MockObjectProxy::MockObjectProxy(Bus* bus, const std::string& service_name, - const ObjectPath& object_path) + const std::string& object_path) : ObjectProxy(bus, service_name, object_path, DEFAULT_OPTIONS) { } diff --git a/dbus/mock_object_proxy.h b/dbus/mock_object_proxy.h index a8a5791..b5d4477 100644 --- a/dbus/mock_object_proxy.h +++ b/dbus/mock_object_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,7 +8,6 @@ #include <string> -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "testing/gmock/include/gmock/gmock.h" @@ -19,7 +18,7 @@ class MockObjectProxy : public ObjectProxy { public: MockObjectProxy(Bus* bus, const std::string& service_name, - const ObjectPath& object_path); + const std::string& object_path); virtual ~MockObjectProxy(); MOCK_METHOD2(CallMethodAndBlock, Response*(MethodCall* method_call, diff --git a/dbus/mock_unittest.cc b/dbus/mock_unittest.cc index cf644df..022b03d 100644 --- a/dbus/mock_unittest.cc +++ b/dbus/mock_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +11,6 @@ #include "dbus/mock_bus.h" #include "dbus/mock_object_proxy.h" #include "dbus/mock_exported_object.h" -#include "dbus/object_path.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -32,10 +31,9 @@ class MockTest : public testing::Test { mock_bus_ = new dbus::MockBus(options); // Create a mock proxy. - mock_proxy_ = new dbus::MockObjectProxy( - mock_bus_.get(), - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + mock_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(), + "org.chromium.TestService", + "/org/chromium/TestObject"); // Set an expectation so mock_proxy's CallMethodAndBlock() will use // CreateMockProxyResponse() to return responses. @@ -51,9 +49,8 @@ class MockTest : public testing::Test { // Set an expectation so mock_bus's GetObjectProxy() for the given // service name and the object path will return mock_proxy_. - EXPECT_CALL(*mock_bus_, GetObjectProxy( - "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject"))) + EXPECT_CALL(*mock_bus_, GetObjectProxy("org.chromium.TestService", + "/org/chromium/TestObject")) .WillOnce(Return(mock_proxy_.get())); // ShutdownAndBlock() will be called in TearDown(). @@ -133,7 +130,7 @@ TEST_F(MockTest, CallMethodAndBlock) { // Get an object proxy from the mock bus. dbus::ObjectProxy* proxy = mock_bus_->GetObjectProxy( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); // Create a method call. dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); @@ -162,7 +159,7 @@ TEST_F(MockTest, CallMethod) { // Get an object proxy from the mock bus. dbus::ObjectProxy* proxy = mock_bus_->GetObjectProxy( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); // Create a method call. dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); diff --git a/dbus/object_path.cc b/dbus/object_path.cc deleted file mode 100644 index 2dda466..0000000 --- a/dbus/object_path.cc +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -#include "dbus/object_path.h" - -namespace dbus { - -bool ObjectPath::operator<(const ObjectPath& that) const { - return value_ < that.value_; -} - -bool ObjectPath::operator==(const ObjectPath& that) const { - return value_ == that.value_; -} - -bool ObjectPath::operator!=(const ObjectPath& that) const { - return value_ != that.value_; -} - -} // namespace dbus diff --git a/dbus/object_path.h b/dbus/object_path.h deleted file mode 100644 index 59071da..0000000 --- a/dbus/object_path.h +++ /dev/null @@ -1,46 +0,0 @@ -// 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. - -#ifndef DBUS_OBJECT_PATH_H_ -#define DBUS_OBJECT_PATH_H_ -#pragma once - -#include <string> - -namespace dbus { - -// ObjectPath is a type used to distinguish D-Bus object paths from simple -// strings, especially since normal practice is that these should be only -// initialized from static constants or obtained from remote objects and no -// assumptions about their value made. -class ObjectPath { - public: - // Permit initialization without a value for passing to - // dbus::MessageReader::PopObjectPath to fill in and from std::string - // objects. - // - // The compiler synthesised copy constructor and assignment operator are - // sufficient for our needs, as is implicit initialization of a std::string - // from a string constant. - ObjectPath() {} - explicit ObjectPath(const std::string& value) : value_(value) {} - - // Retrieves value as a std::string. - const std::string& value() const { return value_; } - - // Permit sufficient comparison to allow an ObjectPath to be used as a - // key in a std::map. - bool operator<(const ObjectPath&) const; - - // Permit testing for equality, required for mocks to work and useful for - // observers. - bool operator==(const ObjectPath&) const; - bool operator!=(const ObjectPath&) const; - private: - std::string value_; -}; - -} // namespace dbus - -#endif // DBUS_OBJECT_PATH_H_ diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc index 32f6a60..58d679c 100644 --- a/dbus/object_proxy.cc +++ b/dbus/object_proxy.cc @@ -13,7 +13,6 @@ #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "dbus/scoped_dbus_error.h" @@ -43,7 +42,7 @@ namespace dbus { ObjectProxy::ObjectProxy(Bus* bus, const std::string& service_name, - const ObjectPath& object_path, + const std::string& object_path, int options) : bus_(bus), service_name_(service_name), diff --git a/dbus/object_proxy.h b/dbus/object_proxy.h index 3a9fab1..3da4e9b 100644 --- a/dbus/object_proxy.h +++ b/dbus/object_proxy.h @@ -16,7 +16,6 @@ #include "base/memory/ref_counted.h" #include "base/string_piece.h" #include "base/time.h" -#include "dbus/object_path.h" namespace dbus { @@ -36,7 +35,7 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { // Bus::GetObjectProxyWithOptions() instead of this constructor. ObjectProxy(Bus* bus, const std::string& service_name, - const ObjectPath& object_path, + const std::string& object_path, int options); // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions(). @@ -197,7 +196,7 @@ class ObjectProxy : public base::RefCountedThreadSafe<ObjectProxy> { scoped_refptr<Bus> bus_; std::string service_name_; - ObjectPath object_path_; + std::string object_path_; // True if the message filter was added. bool filter_added_; diff --git a/dbus/test_service.cc b/dbus/test_service.cc index 6454bb5..714c09b 100644 --- a/dbus/test_service.cc +++ b/dbus/test_service.cc @@ -10,7 +10,6 @@ #include "dbus/bus.h" #include "dbus/exported_object.h" #include "dbus/message.h" -#include "dbus/object_path.h" namespace dbus { @@ -97,7 +96,7 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { // Use "/" just like dbus-send does. ExportedObject* root_object = bus_->GetExportedObject("org.chromium.TestService", - dbus::ObjectPath("/")); + "/"); root_object->SendSignal(&signal); } @@ -126,7 +125,7 @@ void TestService::Run(MessageLoop* message_loop) { exported_object_ = bus_->GetExportedObject( "org.chromium.TestService", - dbus::ObjectPath("/org/chromium/TestObject")); + "/org/chromium/TestObject"); int num_methods = 0; exported_object_->ExportMethod( diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc index ff3c3c0..edc77b9 100644 --- a/net/base/network_change_notifier_linux.cc +++ b/net/base/network_change_notifier_linux.cc @@ -137,8 +137,8 @@ void NetworkManagerApi::Init() { // Ignore ServiceUnknown errors to avoid log spam: http://crbug.com/109696. dbus::ObjectProxy* proxy = system_bus_->GetObjectProxyWithOptions( - kNetworkManagerServiceName, dbus::ObjectPath(kNetworkManagerPath), - dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); + kNetworkManagerServiceName, kNetworkManagerPath, + dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); // Get the initial state asynchronously. dbus::MethodCall method_call(DBUS_INTERFACE_PROPERTIES, "Get"); diff --git a/net/base/network_change_notifier_linux_unittest.cc b/net/base/network_change_notifier_linux_unittest.cc index d8513ce..ecd48a5 100644 --- a/net/base/network_change_notifier_linux_unittest.cc +++ b/net/base/network_change_notifier_linux_unittest.cc @@ -10,7 +10,6 @@ #include "dbus/mock_bus.h" #include "dbus/mock_object_proxy.h" #include "dbus/message.h" -#include "dbus/object_path.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -42,10 +41,9 @@ class NetworkChangeNotifierLinuxTest : public testing::Test { options.bus_type = dbus::Bus::SYSTEM; mock_bus_ = new dbus::MockBus(options); - mock_object_proxy_ = new dbus::MockObjectProxy( - mock_bus_.get(), - "service_name", - dbus::ObjectPath("service_path")); + mock_object_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(), + "service_name", + "service_path"); EXPECT_CALL(*mock_bus_, GetObjectProxyWithOptions(_, _, _)) .WillOnce(Return(mock_object_proxy_.get())); |