Commit 2a363a8c authored by Ryo Hashimoto's avatar Ryo Hashimoto Committed by Commit Bot

dbus: Let ObjectProxy::CallMethod() take OnceCallback

Currently, ObjectProxy::CallMethod is implemented by creating ErrorCallback from ResponseCallback.
This does not work with OnceCallback because it's not allowed to create two callbacks from one OnceCallback.
To solve this, this change introduces CallMethodCallbackInternal to ObjectProxy which takes either Response* or ErrorResponse*, and dispatches the response to the appropriate callback.

Also, Gmock does not allow directly mocking functions which take move-only
arguments.
https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#mocking-methods-that-use-move-only-types
To workaround this, add DoCallMethod to MockObjetProxy.

BUG=740015
TEST=build

Change-Id: I1a98b5fd1d6d70f69674102a3d66bcec0c13214c
Reviewed-on: https://chromium-review.googlesource.com/578541
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarSatoru Takabayashi <satorux@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488615}
parent c342ef57
......@@ -51,7 +51,7 @@ MATCHER_P(HasMember, name, "") {
// bare pointer rather than an std::unique_ptr.
void RunResponseCallback(dbus::ObjectProxy::ResponseCallback callback,
std::unique_ptr<dbus::Response> response) {
callback.Run(response.get());
std::move(callback).Run(response.get());
}
} // namespace
......@@ -98,7 +98,7 @@ class BiodClientTest : public testing::Test {
std::unique_ptr<dbus::Response> response) {
ASSERT_FALSE(pending_method_calls_.count(method_name));
pending_method_calls_[method_name] = std::move(response);
EXPECT_CALL(*proxy_.get(), CallMethod(HasMember(method_name), _, _))
EXPECT_CALL(*proxy_.get(), DoCallMethod(HasMember(method_name), _, _))
.WillOnce(Invoke(this, &BiodClientTest::OnCallMethod));
}
......@@ -187,15 +187,15 @@ class BiodClientTest : public testing::Test {
// Handles calls to |proxy_|'s CallMethod().
void OnCallMethod(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
auto it = pending_method_calls_.find(method_call->GetMember());
ASSERT_TRUE(it != pending_method_calls_.end());
auto pending_response = std::move(it->second);
pending_method_calls_.erase(it);
message_loop_.task_runner()->PostTask(
FROM_HERE, base::Bind(&RunResponseCallback, callback,
base::Passed(&pending_response)));
FROM_HERE, base::BindOnce(&RunResponseCallback, std::move(*callback),
base::Passed(&pending_response)));
}
DISALLOW_COPY_AND_ASSIGN(BiodClientTest);
......
......@@ -267,13 +267,13 @@ class CrasAudioClientTest : public testing::Test {
// Set an expectation so mock_cras_proxy's CallMethod() will use
// OnCallMethod() to return responses.
EXPECT_CALL(*mock_cras_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_cras_proxy_.get(), DoCallMethod(_, _, _))
.WillRepeatedly(Invoke(this, &CrasAudioClientTest::OnCallMethod));
// Set an expectation so mock_cras_proxy's CallMethodWithErrorCallback()
// will use OnCallMethodWithErrorCallback() to return responses.
EXPECT_CALL(*mock_cras_proxy_.get(),
CallMethodWithErrorCallback(_, _, _, _))
DoCallMethodWithErrorCallback(_, _, _, _))
.WillRepeatedly(
Invoke(this, &CrasAudioClientTest::OnCallMethodWithErrorCallback));
......@@ -532,13 +532,13 @@ class CrasAudioClientTest : public testing::Test {
// Used to implement the mock cras proxy.
void OnCallMethod(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response) {
dbus::ObjectProxy::ResponseCallback* response) {
EXPECT_EQ(interface_name_, method_call->GetInterface());
EXPECT_EQ(expected_method_name_, method_call->GetMember());
dbus::MessageReader reader(method_call);
argument_checker_.Run(&reader);
message_loop_.task_runner()->PostTask(
FROM_HERE, base::Bind(response, response_));
FROM_HERE, base::BindOnce(std::move(*response), response_));
}
// Checks the content of the method call and returns the response.
......@@ -546,8 +546,8 @@ class CrasAudioClientTest : public testing::Test {
void OnCallMethodWithErrorCallback(
dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response_callback,
const dbus::ObjectProxy::ErrorCallback& error_callback) {
dbus::ObjectProxy::ResponseCallback* response_callback,
dbus::ObjectProxy::ErrorCallback* error_callback) {
OnCallMethod(method_call, timeout_ms, response_callback);
}
};
......
......@@ -100,7 +100,7 @@ class GsmSMSClientTest : public testing::Test {
// Handles Delete method call.
void OnDelete(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
EXPECT_EQ(modemmanager::kModemManagerSMSInterface,
method_call->GetInterface());
EXPECT_EQ(modemmanager::kSMSDeleteFunction, method_call->GetMember());
......@@ -110,14 +110,14 @@ class GsmSMSClientTest : public testing::Test {
EXPECT_EQ(expected_index_, index);
EXPECT_FALSE(reader.HasMoreData());
message_loop_.task_runner()->PostTask(FROM_HERE,
base::Bind(callback, response_));
message_loop_.task_runner()->PostTask(
FROM_HERE, base::BindOnce(std::move(*callback), response_));
}
// Handles Get method call.
void OnGet(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
EXPECT_EQ(modemmanager::kModemManagerSMSInterface,
method_call->GetInterface());
EXPECT_EQ(modemmanager::kSMSGetFunction, method_call->GetMember());
......@@ -127,22 +127,22 @@ class GsmSMSClientTest : public testing::Test {
EXPECT_EQ(expected_index_, index);
EXPECT_FALSE(reader.HasMoreData());
message_loop_.task_runner()->PostTask(FROM_HERE,
base::Bind(callback, response_));
message_loop_.task_runner()->PostTask(
FROM_HERE, base::BindOnce(std::move(*callback), response_));
}
// Handles List method call.
void OnList(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
EXPECT_EQ(modemmanager::kModemManagerSMSInterface,
method_call->GetInterface());
EXPECT_EQ(modemmanager::kSMSListFunction, method_call->GetMember());
dbus::MessageReader reader(method_call);
EXPECT_FALSE(reader.HasMoreData());
message_loop_.task_runner()->PostTask(FROM_HERE,
base::Bind(callback, response_));
message_loop_.task_runner()->PostTask(
FROM_HERE, base::BindOnce(std::move(*callback), response_));
}
// Checks the results of Get and List.
......@@ -214,7 +214,7 @@ TEST_F(GsmSMSClientTest, Delete) {
// Set expectations.
const uint32_t kIndex = 42;
expected_index_ = kIndex;
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillOnce(Invoke(this, &GsmSMSClientTest::OnDelete));
base::MockCallback<GsmSMSClient::DeleteCallback> callback;
EXPECT_CALL(callback, Run()).Times(1);
......@@ -233,7 +233,7 @@ TEST_F(GsmSMSClientTest, Get) {
// Set expectations.
const uint32_t kIndex = 42;
expected_index_ = kIndex;
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillOnce(Invoke(this, &GsmSMSClientTest::OnGet));
base::MockCallback<GsmSMSClient::GetCallback> callback;
EXPECT_CALL(callback, Run(_))
......@@ -269,7 +269,7 @@ TEST_F(GsmSMSClientTest, Get) {
TEST_F(GsmSMSClientTest, List) {
// Set expectations.
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillOnce(Invoke(this, &GsmSMSClientTest::OnList));
base::MockCallback<GsmSMSClient::ListCallback> callback;
EXPECT_CALL(callback, Run(_))
......
......@@ -97,7 +97,7 @@ class ModemMessagingClientTest : public testing::Test {
// Handles Delete method call.
void OnDelete(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
EXPECT_EQ(modemmanager::kModemManager1MessagingInterface,
method_call->GetInterface());
EXPECT_EQ(modemmanager::kSMSDeleteFunction, method_call->GetMember());
......@@ -107,22 +107,22 @@ class ModemMessagingClientTest : public testing::Test {
EXPECT_EQ(expected_sms_path_, sms_path);
EXPECT_FALSE(reader.HasMoreData());
message_loop_.task_runner()->PostTask(FROM_HERE,
base::Bind(callback, response_));
message_loop_.task_runner()->PostTask(
FROM_HERE, base::BindOnce(std::move(*callback), response_));
}
// Handles List method call.
void OnList(dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
EXPECT_EQ(modemmanager::kModemManager1MessagingInterface,
method_call->GetInterface());
EXPECT_EQ(modemmanager::kSMSListFunction, method_call->GetMember());
dbus::MessageReader reader(method_call);
EXPECT_FALSE(reader.HasMoreData());
message_loop_.task_runner()->PostTask(FROM_HERE,
base::Bind(callback, response_));
message_loop_.task_runner()->PostTask(
FROM_HERE, base::BindOnce(std::move(*callback), response_));
}
// Checks the results of List.
......@@ -195,7 +195,7 @@ TEST_F(ModemMessagingClientTest, Delete) {
// Set expectations.
const dbus::ObjectPath kSmsPath("/SMS/0");
expected_sms_path_ = kSmsPath;
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillOnce(Invoke(this, &ModemMessagingClientTest::OnDelete));
MockDeleteCallback callback;
EXPECT_CALL(callback, Run()).Times(1);
......@@ -213,7 +213,7 @@ TEST_F(ModemMessagingClientTest, Delete) {
TEST_F(ModemMessagingClientTest, List) {
// Set expectations.
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillOnce(Invoke(this, &ModemMessagingClientTest::OnList));
MockListCallback callback;
EXPECT_CALL(callback, Run(_))
......
......@@ -812,8 +812,9 @@ class PowerManagerClientImpl : public PowerManagerClient {
return;
}
power_manager_proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, callback);
power_manager_proxy_->CallMethod(&method_call,
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
std::move(callback));
}
// Registers suspend delays with the power manager. This is usually only
......
......@@ -75,7 +75,7 @@ MATCHER_P3(IsSuspendReadiness, method_name, suspend_id, delay_id, "") {
// bare pointer rather than an std::unique_ptr.
void RunResponseCallback(dbus::ObjectProxy::ResponseCallback callback,
std::unique_ptr<dbus::Response> response) {
callback.Run(response.get());
std::move(callback).Run(response.get());
}
// Stub implementation of PowerManagerClient::Observer.
......@@ -213,13 +213,14 @@ class PowerManagerClientTest : public testing::Test {
// delays.
EXPECT_CALL(
*proxy_.get(),
CallMethod(HasMember(power_manager::kRegisterSuspendDelayMethod), _, _))
DoCallMethod(HasMember(power_manager::kRegisterSuspendDelayMethod), _,
_))
.WillRepeatedly(
Invoke(this, &PowerManagerClientTest::RegisterSuspendDelay));
EXPECT_CALL(
*proxy_.get(),
CallMethod(HasMember(power_manager::kRegisterDarkSuspendDelayMethod), _,
_))
DoCallMethod(HasMember(power_manager::kRegisterDarkSuspendDelayMethod),
_, _))
.WillRepeatedly(
Invoke(this, &PowerManagerClientTest::RegisterSuspendDelay));
......@@ -269,8 +270,8 @@ class PowerManagerClientTest : public testing::Test {
int delay_id) {
EXPECT_CALL(
*proxy_.get(),
CallMethod(IsSuspendReadiness(method_name, suspend_id, delay_id), _,
_));
DoCallMethod(IsSuspendReadiness(method_name, suspend_id, delay_id), _,
_));
}
// Arbitrary delay IDs returned to |client_|.
......@@ -311,7 +312,7 @@ class PowerManagerClientTest : public testing::Test {
// Handles calls to |proxy_|'s CallMethod() method to register suspend delays.
void RegisterSuspendDelay(dbus::MethodCall* method_call,
int timeout_ms,
dbus::ObjectProxy::ResponseCallback callback) {
dbus::ObjectProxy::ResponseCallback* callback) {
power_manager::RegisterSuspendDelayReply proto;
proto.set_delay_id(method_call->GetMember() ==
power_manager::kRegisterDarkSuspendDelayMethod
......@@ -324,8 +325,8 @@ class PowerManagerClientTest : public testing::Test {
CHECK(dbus::MessageWriter(response.get()).AppendProtoAsArrayOfBytes(proto));
message_loop_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&RunResponseCallback, callback, base::Passed(&response)));
FROM_HERE, base::BindOnce(&RunResponseCallback, std::move(*callback),
base::Passed(&response)));
}
DISALLOW_COPY_AND_ASSIGN(PowerManagerClientTest);
......
......@@ -106,14 +106,14 @@ void ShillClientUnittestBase::SetUp() {
// Set an expectation so mock_proxy's CallMethod() will use OnCallMethod()
// to return responses.
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillRepeatedly(Invoke(this, &ShillClientUnittestBase::OnCallMethod));
// Set an expectation so mock_proxy's CallMethodWithErrorCallback() will use
// OnCallMethodWithErrorCallback() to return responses.
EXPECT_CALL(*mock_proxy_.get(), CallMethodWithErrorCallback(_, _, _, _))
EXPECT_CALL(*mock_proxy_.get(), DoCallMethodWithErrorCallback(_, _, _, _))
.WillRepeatedly(Invoke(
this, &ShillClientUnittestBase::OnCallMethodWithErrorCallback));
this, &ShillClientUnittestBase::OnCallMethodWithErrorCallback));
// Set an expectation so mock_proxy's ConnectToSignal() will use
// OnConnectToPropertyChanged() to run the callback.
......@@ -422,20 +422,20 @@ void ShillClientUnittestBase::OnConnectToPropertyChanged(
void ShillClientUnittestBase::OnCallMethod(
dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response_callback) {
dbus::ObjectProxy::ResponseCallback* response_callback) {
EXPECT_EQ(interface_name_, method_call->GetInterface());
EXPECT_EQ(expected_method_name_, method_call->GetMember());
dbus::MessageReader reader(method_call);
argument_checker_.Run(&reader);
message_loop_.task_runner()->PostTask(
FROM_HERE, base::Bind(response_callback, response_));
FROM_HERE, base::BindOnce(std::move(*response_callback), response_));
}
void ShillClientUnittestBase::OnCallMethodWithErrorCallback(
dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response_callback,
const dbus::ObjectProxy::ErrorCallback& error_callback) {
dbus::ObjectProxy::ResponseCallback* response_callback,
dbus::ObjectProxy::ErrorCallback* error_callback) {
OnCallMethod(method_call, timeout_ms, response_callback);
}
......
......@@ -207,18 +207,17 @@ class ShillClientUnittestBase : public testing::Test {
// Checks the content of the method call and returns the response.
// Used to implement the mock proxy.
void OnCallMethod(
dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response_callback);
void OnCallMethod(dbus::MethodCall* method_call,
int timeout_ms,
dbus::ObjectProxy::ResponseCallback* response_callback);
// Checks the content of the method call and returns the response.
// Used to implement the mock proxy.
void OnCallMethodWithErrorCallback(
dbus::MethodCall* method_call,
int timeout_ms,
const dbus::ObjectProxy::ResponseCallback& response_callback,
const dbus::ObjectProxy::ErrorCallback& error_callback);
dbus::ObjectProxy::ResponseCallback* response_callback,
dbus::ObjectProxy::ErrorCallback* error_callback);
// The interface name.
const std::string interface_name_;
......
......@@ -15,4 +15,19 @@ MockObjectProxy::MockObjectProxy(Bus* bus,
MockObjectProxy::~MockObjectProxy() {
}
void MockObjectProxy::CallMethod(MethodCall* method_call,
int timeout_ms,
ResponseCallback callback) {
DoCallMethod(method_call, timeout_ms, &callback);
}
void MockObjectProxy::CallMethodWithErrorCallback(
MethodCall* method_call,
int timeout_ms,
ResponseCallback callback,
ErrorCallback error_callback) {
DoCallMethodWithErrorCallback(method_call, timeout_ms, &callback,
&error_callback);
}
} // namespace dbus
......@@ -29,13 +29,30 @@ class MockObjectProxy : public ObjectProxy {
MOCK_METHOD2(CallMethodAndBlock,
std::unique_ptr<Response>(MethodCall* method_call,
int timeout_ms));
MOCK_METHOD3(CallMethod, void(MethodCall* method_call,
int timeout_ms,
ResponseCallback callback));
MOCK_METHOD4(CallMethodWithErrorCallback, void(MethodCall* method_call,
int timeout_ms,
ResponseCallback callback,
ErrorCallback error_callback));
// This method is not mockable because it takes a move-only argument. To work
// around this, CallMethod() implementation here calls DoCallMethod() which is
// mockable.
void CallMethod(MethodCall* method_call,
int timeout_ms,
ResponseCallback callback) override;
MOCK_METHOD3(DoCallMethod,
void(MethodCall* method_call,
int timeout_ms,
ResponseCallback* callback));
// This method is not mockable because it takes a move-only argument. To work
// around this, CallMethodWithErrorCallback() implementation here calls
// DoCallMethodWithErrorCallback() which is mockable.
void CallMethodWithErrorCallback(MethodCall* method_call,
int timeout_ms,
ResponseCallback callback,
ErrorCallback error_callback) override;
MOCK_METHOD4(DoCallMethodWithErrorCallback,
void(MethodCall* method_call,
int timeout_ms,
ResponseCallback* callback,
ErrorCallback* error_callback));
MOCK_METHOD4(ConnectToSignal,
void(const std::string& interface_name,
const std::string& signal_name,
......
......@@ -54,8 +54,9 @@ class MockTest : public testing::Test {
// Set an expectation so mock_proxy's CallMethod() will use
// HandleMockProxyResponseWithMessageLoop() to return responses.
EXPECT_CALL(*mock_proxy_.get(), CallMethod(_, _, _)).WillRepeatedly(
Invoke(this, &MockTest::HandleMockProxyResponseWithMessageLoop));
EXPECT_CALL(*mock_proxy_.get(), DoCallMethod(_, _, _))
.WillRepeatedly(
Invoke(this, &MockTest::HandleMockProxyResponseWithMessageLoop));
// Set an expectation so mock_bus's GetObjectProxy() for the given
// service name and the object path will return mock_proxy_.
......@@ -120,20 +121,20 @@ class MockTest : public testing::Test {
void HandleMockProxyResponseWithMessageLoop(
MethodCall* method_call,
int timeout_ms,
ObjectProxy::ResponseCallback response_callback) {
ObjectProxy::ResponseCallback* response_callback) {
std::unique_ptr<Response> response =
CreateMockProxyResponse(method_call, timeout_ms);
message_loop_.task_runner()->PostTask(
FROM_HERE,
base::Bind(&MockTest::RunResponseCallback, base::Unretained(this),
response_callback, base::Passed(&response)));
base::BindOnce(&MockTest::RunResponseCallback, base::Unretained(this),
std::move(*response_callback), base::Passed(&response)));
}
// Runs the given response callback with the given response.
void RunResponseCallback(
ObjectProxy::ResponseCallback response_callback,
std::unique_ptr<Response> response) {
response_callback.Run(response.get());
std::move(response_callback).Run(response.get());
}
};
......
This diff is collapsed.
......@@ -68,30 +68,30 @@ class CHROME_DBUS_EXPORT ObjectProxy
// Called when an error response is returned or no response is returned.
// Used for CallMethodWithErrorCallback().
typedef base::Callback<void(ErrorResponse*)> ErrorCallback;
using ErrorCallback = base::OnceCallback<void(ErrorResponse*)>;
// Called when the response is returned. Used for CallMethod().
typedef base::Callback<void(Response*)> ResponseCallback;
using ResponseCallback = base::OnceCallback<void(Response*)>;
// Called when a signal is received. Signal* is the incoming signal.
typedef base::Callback<void (Signal*)> SignalCallback;
using SignalCallback = base::Callback<void(Signal*)>;
// Called when NameOwnerChanged signal is received.
typedef base::Callback<void(
const std::string& old_owner,
const std::string& new_owner)> NameOwnerChangedCallback;
using NameOwnerChangedCallback =
base::Callback<void(const std::string& old_owner,
const std::string& new_owner)>;
// Called when the service becomes available.
typedef base::Callback<void(
bool service_is_available)> WaitForServiceToBeAvailableCallback;
using WaitForServiceToBeAvailableCallback =
base::Callback<void(bool service_is_available)>;
// Called when the object proxy is connected to the signal.
// Parameters:
// - the interface name.
// - the signal name.
// - whether it was successful or not.
typedef base::Callback<void (const std::string&, const std::string&, bool)>
OnConnectedCallback;
using OnConnectedCallback =
base::Callback<void(const std::string&, const std::string&, bool)>;
// Calls the method of the remote object and blocks until the response
// is returned. Returns NULL on error with the error details specified
......@@ -201,40 +201,45 @@ class CHROME_DBUS_EXPORT ObjectProxy
private:
friend class base::RefCountedThreadSafe<ObjectProxy>;
using CallMethodInternalCallback =
base::OnceCallback<void(Response* response,
ErrorResponse* error_response)>;
// Struct of data we'll be passing from StartAsyncMethodCall() to
// OnPendingCallIsCompleteThunk().
struct OnPendingCallIsCompleteData {
OnPendingCallIsCompleteData(ObjectProxy* in_object_proxy,
ResponseCallback in_response_callback,
ErrorCallback error_callback,
CallMethodInternalCallback callback,
base::TimeTicks start_time);
~OnPendingCallIsCompleteData();
ObjectProxy* object_proxy;
ResponseCallback response_callback;
ErrorCallback error_callback;
CallMethodInternalCallback callback;
base::TimeTicks start_time;
};
// This is a helpr function to implement CallMethod() and
// CallMethodWithErrorCallback().
void CallMethodInternal(MethodCall* method_call,
int timeout_ms,
CallMethodInternalCallback callback);
// Starts the async method call. This is a helper function to implement
// CallMethod().
void StartAsyncMethodCall(int timeout_ms,
DBusMessage* request_message,
ResponseCallback response_callback,
ErrorCallback error_callback,
CallMethodInternalCallback callback,
base::TimeTicks start_time);
// Called when the pending call is complete.
void OnPendingCallIsComplete(DBusPendingCall* pending_call,
ResponseCallback response_callback,
ErrorCallback error_callback,
CallMethodInternalCallback callback,
base::TimeTicks start_time);
// Runs the response callback with the given response object.
void RunResponseCallback(ResponseCallback response_callback,
ErrorCallback error_callback,
base::TimeTicks start_time,
DBusMessage* response_message);
// Runs the CallMethodInternalCallback with the given response object.
void RunCallMethodInternalCallback(CallMethodInternalCallback callback,
base::TimeTicks start_time,
DBusMessage* response_message);
// Redirects the function call to OnPendingCallIsComplete().
static void OnPendingCallIsCompleteThunk(DBusPendingCall* pending_call,
......@@ -272,11 +277,14 @@ class CHROME_DBUS_EXPORT ObjectProxy
const base::StringPiece& error_name,
const base::StringPiece& error_message) const;
// Used as ErrorCallback by CallMethod().
void OnCallMethodError(const std::string& interface_name,
const std::string& method_name,
ResponseCallback response_callback,
ErrorResponse* error_response);
// Used as CallMethodInternalCallback by CallMethod(). (i.e. ErrorCallback
// wasn't provided, hence response_callback will be used for handling the
// error response).
void OnCallMethod(const std::string& interface_name,
const std::string& method_name,
ResponseCallback response_callback,
Response* response,
ErrorResponse* error_response);
// Adds the match rule to the bus and associate the callback with the signal.
bool AddMatchRuleWithCallback(const std::string& match_rule,
......@@ -310,7 +318,7 @@ class CHROME_DBUS_EXPORT ObjectProxy
// The method table where keys are absolute signal names (i.e. interface
// name + signal name), and values are lists of the corresponding callbacks.
typedef std::map<std::string, std::vector<SignalCallback> > MethodTable;
using MethodTable = std::map<std::string, std::vector<SignalCallback>>;
MethodTable method_table_;
// The callback called when NameOwnerChanged signal is received.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment