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

Unified Diff: trunk/src/chromeos/dbus/shill_client_helper.cc

Issue 24293002: Revert 224179 "Track active references in ShillClientHelper" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/chromeos/dbus/shill_client_helper.h ('k') | trunk/src/chromeos/dbus/shill_device_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/chromeos/dbus/shill_client_helper.cc
===================================================================
--- trunk/src/chromeos/dbus/shill_client_helper.cc (revision 224203)
+++ trunk/src/chromeos/dbus/shill_client_helper.cc (working copy)
@@ -5,7 +5,6 @@
#include "chromeos/dbus/shill_client_helper.h"
#include "base/bind.h"
-#include "base/callback_helpers.h"
#include "base/values.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
@@ -14,36 +13,12 @@
namespace chromeos {
-// Class to hold onto a reference to a ShillClientHelper. This calss
-// is owned by callbacks and released once the callback completes.
-// Note: Only success callbacks hold the reference. If an error callback is
-// invoked instead, the success callback will still be destroyed and the
-// RefHolder with it, once the callback chain completes.
-class ShillClientHelper::RefHolder {
- public:
- explicit RefHolder(base::WeakPtr<ShillClientHelper> helper)
- : helper_(helper) {
- helper_->AddRef();
- }
- ~RefHolder() {
- if (helper_)
- helper_->Release();
- }
-
- private:
- base::WeakPtr<ShillClientHelper> helper_;
-};
-
namespace {
const char kInvalidResponseErrorName[] = ""; // No error name.
const char kInvalidResponseErrorMessage[] = "Invalid response.";
-// Note: here and below, |ref_holder| is unused in the function body. It only
-// exists so that it will be destroyed (and the reference released) with the
-// Callback object once completed.
void OnBooleanMethodWithErrorCallback(
- ShillClientHelper::RefHolder* ref_holder,
const ShillClientHelper::BooleanCallback& callback,
const ShillClientHelper::ErrorCallback& error_callback,
dbus::Response* response) {
@@ -61,7 +36,6 @@
}
void OnStringMethodWithErrorCallback(
- ShillClientHelper::RefHolder* ref_holder,
const ShillClientHelper::StringCallback& callback,
const ShillClientHelper::ErrorCallback& error_callback,
dbus::Response* response) {
@@ -79,8 +53,7 @@
}
// Handles responses for methods without results.
-void OnVoidMethod(ShillClientHelper::RefHolder* ref_holder,
- const VoidDBusMethodCallback& callback,
+void OnVoidMethod(const VoidDBusMethodCallback& callback,
dbus::Response* response) {
if (!response) {
callback.Run(DBUS_METHOD_CALL_FAILURE);
@@ -91,7 +64,6 @@
// Handles responses for methods with ObjectPath results.
void OnObjectPathMethod(
- ShillClientHelper::RefHolder* ref_holder,
const ObjectPathDBusMethodCallback& callback,
dbus::Response* response) {
if (!response) {
@@ -109,7 +81,6 @@
// Handles responses for methods with ObjectPath results and no status.
void OnObjectPathMethodWithoutStatus(
- ShillClientHelper::RefHolder* ref_holder,
const ObjectPathCallback& callback,
const ShillClientHelper::ErrorCallback& error_callback,
dbus::Response* response) {
@@ -128,7 +99,6 @@
// Handles responses for methods with DictionaryValue results.
void OnDictionaryValueMethod(
- ShillClientHelper::RefHolder* ref_holder,
const ShillClientHelper::DictionaryValueCallback& callback,
dbus::Response* response) {
if (!response) {
@@ -149,7 +119,6 @@
// Handles responses for methods without results.
void OnVoidMethodWithErrorCallback(
- ShillClientHelper::RefHolder* ref_holder,
const base::Closure& callback,
dbus::Response* response) {
callback.Run();
@@ -158,7 +127,6 @@
// Handles responses for methods with DictionaryValue results.
// Used by CallDictionaryValueMethodWithErrorCallback().
void OnDictionaryValueMethodWithErrorCallback(
- ShillClientHelper::RefHolder* ref_holder,
const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback,
const ShillClientHelper::ErrorCallback& error_callback,
dbus::Response* response) {
@@ -174,7 +142,6 @@
// Handles responses for methods with ListValue results.
void OnListValueMethodWithErrorCallback(
- ShillClientHelper::RefHolder* ref_holder,
const ShillClientHelper::ListValueCallback& callback,
const ShillClientHelper::ErrorCallback& error_callback,
dbus::Response* response) {
@@ -204,9 +171,9 @@
} // namespace
-ShillClientHelper::ShillClientHelper(dbus::ObjectProxy* proxy)
+ShillClientHelper::ShillClientHelper(dbus::Bus* bus,
+ dbus::ObjectProxy* proxy)
: proxy_(proxy),
- active_refs_(0),
weak_ptr_factory_(this) {
}
@@ -215,16 +182,8 @@
<< "ShillClientHelper destroyed with active observers";
}
-void ShillClientHelper::SetReleasedCallback(ReleasedCallback callback) {
- CHECK(released_callback_.is_null());
- released_callback_ = callback;
-}
-
void ShillClientHelper::AddPropertyChangedObserver(
ShillPropertyChangedObserver* observer) {
- if (observer_list_.HasObserver(observer))
- return;
- AddRef();
// Excecute all the pending MonitorPropertyChanged calls.
for (size_t i = 0; i < interfaces_to_be_monitored_.size(); ++i) {
MonitorPropertyChangedInternal(interfaces_to_be_monitored_[i]);
@@ -236,10 +195,7 @@
void ShillClientHelper::RemovePropertyChangedObserver(
ShillPropertyChangedObserver* observer) {
- if (!observer_list_.HasObserver(observer))
- return;
observer_list_.RemoveObserver(observer);
- Release();
}
void ShillClientHelper::MonitorPropertyChanged(
@@ -269,22 +225,18 @@
dbus::MethodCall* method_call,
const VoidDBusMethodCallback& callback) {
DCHECK(!callback.is_null());
- proxy_->CallMethod(
- method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&OnVoidMethod,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
- callback));
+ proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&OnVoidMethod,
+ callback));
}
void ShillClientHelper::CallObjectPathMethod(
dbus::MethodCall* method_call,
const ObjectPathDBusMethodCallback& callback) {
DCHECK(!callback.is_null());
- proxy_->CallMethod(
- method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&OnObjectPathMethod,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
- callback));
+ proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&OnObjectPathMethod,
+ callback));
}
void ShillClientHelper::CallObjectPathMethodWithErrorCallback(
@@ -297,7 +249,6 @@
method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&OnObjectPathMethodWithoutStatus,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
callback,
error_callback),
base::Bind(&OnError,
@@ -308,11 +259,9 @@
dbus::MethodCall* method_call,
const DictionaryValueCallback& callback) {
DCHECK(!callback.is_null());
- proxy_->CallMethod(
- method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&OnDictionaryValueMethod,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
- callback));
+ proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&OnDictionaryValueMethod,
+ callback));
}
void ShillClientHelper::CallVoidMethodWithErrorCallback(
@@ -324,7 +273,6 @@
proxy_->CallMethodWithErrorCallback(
method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&OnVoidMethodWithErrorCallback,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
callback),
base::Bind(&OnError,
error_callback));
@@ -339,7 +287,6 @@
proxy_->CallMethodWithErrorCallback(
method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&OnBooleanMethodWithErrorCallback,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
callback,
error_callback),
base::Bind(&OnError,
@@ -355,7 +302,6 @@
proxy_->CallMethodWithErrorCallback(
method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&OnStringMethodWithErrorCallback,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
callback,
error_callback),
base::Bind(&OnError,
@@ -370,10 +316,10 @@
DCHECK(!error_callback.is_null());
proxy_->CallMethodWithErrorCallback(
method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&OnDictionaryValueMethodWithErrorCallback,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
- callback,
- error_callback),
+ base::Bind(
+ &OnDictionaryValueMethodWithErrorCallback,
+ callback,
+ error_callback),
base::Bind(&OnError,
error_callback));
}
@@ -386,10 +332,10 @@
DCHECK(!error_callback.is_null());
proxy_->CallMethodWithErrorCallback(
method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
- base::Bind(&OnListValueMethodWithErrorCallback,
- base::Owned(new RefHolder(weak_ptr_factory_.GetWeakPtr())),
- callback,
- error_callback),
+ base::Bind(
+ &OnListValueMethodWithErrorCallback,
+ callback,
+ error_callback),
base::Bind(&OnError,
error_callback));
}
@@ -474,16 +420,6 @@
writer->CloseContainer(&array_writer);
}
-void ShillClientHelper::AddRef() {
- ++active_refs_;
-}
-
-void ShillClientHelper::Release() {
- --active_refs_;
- if (active_refs_ == 0 && !released_callback_.is_null())
- base::ResetAndReturn(&released_callback_).Run(this); // May delete this
-}
-
void ShillClientHelper::OnSignalConnected(const std::string& interface,
const std::string& signal,
bool success) {
@@ -507,4 +443,5 @@
OnPropertyChanged(name, *value));
}
+
} // namespace chromeos
« no previous file with comments | « trunk/src/chromeos/dbus/shill_client_helper.h ('k') | trunk/src/chromeos/dbus/shill_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698