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

Unified Diff: dbus/object_proxy.h

Issue 25488002: dbus: Add ObjectProxy::WaitForServiceToBeAvailable() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Also test already-available case 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 | « dbus/dbus.gyp ('k') | dbus/object_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_proxy.h
diff --git a/dbus/object_proxy.h b/dbus/object_proxy.h
index e618d5d81be017b786b4945c59bc435887c49cc6..b183be2ccda0287dc9e8ec932b8bdaeaf5f89330 100644
--- a/dbus/object_proxy.h
+++ b/dbus/object_proxy.h
@@ -77,6 +77,10 @@ class CHROME_DBUS_EXPORT ObjectProxy
const std::string& old_owner,
const std::string& new_owner)> NameOwnerChangedCallback;
+ // Called when the service becomes available.
+ typedef base::Callback<void(
+ bool service_is_available)> WaitForServiceToBeAvailableCallback;
+
// Called when the object proxy is connected to the signal.
// Parameters:
// - the interface name.
@@ -152,6 +156,10 @@ class CHROME_DBUS_EXPORT ObjectProxy
// represented by |service_name_|.
virtual void SetNameOwnerChangedCallback(NameOwnerChangedCallback callback);
+ // Runs the callback as soon as the service becomes available.
+ virtual void WaitForServiceToBeAvailable(
+ WaitForServiceToBeAvailableCallback callback);
+
// Detaches from the remote object. The Bus object will take care of
// detaching so you don't have to do this manually.
//
@@ -208,11 +216,17 @@ class CHROME_DBUS_EXPORT ObjectProxy
static void OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call,
void* user_data);
+ // Connects to NameOwnerChanged signal.
+ bool ConnectToNameOwnerChangedSignal();
+
// Helper function for ConnectToSignal().
bool ConnectToSignalInternal(const std::string& interface_name,
const std::string& signal_name,
SignalCallback signal_callback);
+ // Helper function for WaitForServiceToBeAvailable().
+ void WaitForServiceToBeAvailableInternal();
+
// Handles the incoming request messages and dispatches to the signal
// callbacks.
DBusHandlerResult HandleMessage(DBusConnection* connection,
@@ -262,6 +276,9 @@ class CHROME_DBUS_EXPORT ObjectProxy
void RunNameOwnerChangedCallback(const std::string& old_owner,
const std::string& new_owner);
+ // Runs |wait_for_service_to_be_available_callbacks_|.
+ void RunWaitForServiceToBeAvailableCallbacks(bool service_is_available);
+
scoped_refptr<Bus> bus_;
std::string service_name_;
ObjectPath object_path_;
@@ -277,6 +294,10 @@ class CHROME_DBUS_EXPORT ObjectProxy
// The callback called when NameOwnerChanged signal is received.
NameOwnerChangedCallback name_owner_changed_callback_;
+ // Called when the service becomes available.
+ std::vector<WaitForServiceToBeAvailableCallback>
+ wait_for_service_to_be_available_callbacks_;
+
std::set<std::string> match_rules_;
const bool ignore_service_unknown_errors_;
« no previous file with comments | « dbus/dbus.gyp ('k') | dbus/object_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698