forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdbus_method_call_status.h
61 lines (44 loc) · 1.94 KB
/
dbus_method_call_status.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 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 CHROMEOS_DBUS_DBUS_METHOD_CALL_STATUS_H_
#define CHROMEOS_DBUS_DBUS_METHOD_CALL_STATUS_H_
// TODO(hidehiko): Rename this file to dbus_callback.h, when we fully
// get rid of DBusMethodCallStatus enum defined below.
#include <string>
#include "base/callback.h"
#include "base/component_export.h"
#include "base/optional.h"
namespace dbus {
class ObjectPath;
} // namespace dbus
namespace chromeos {
// DEPRECATED. Migrating to DBusMethodCallback style.
// TODO(hidehiko): Remove this when migration is completed.
// An enum to describe whether or not a DBus method call succeeded.
enum DBusMethodCallStatus {
DBUS_METHOD_CALL_FAILURE,
DBUS_METHOD_CALL_SUCCESS,
};
// Callback to handle response of methods with result.
// If the method returns multiple values, std::tuple<...> will be used.
// In case of error, nullopt should be passed.
template <typename ResultType>
using DBusMethodCallback =
base::OnceCallback<void(base::Optional<ResultType> result)>;
// Callback to handle response of methods without result.
// |result| is true if the method call is successfully completed, otherwise
// false.
using VoidDBusMethodCallback = base::OnceCallback<void(bool result)>;
// TODO(crbug.com/739622): Use OnceCallback in following definition, too.
// A callback to handle responses of methods returning a ObjectPath value that
// doesn't get call status.
typedef base::Callback<void(const dbus::ObjectPath& result)> ObjectPathCallback;
// Called when service becomes available.
using WaitForServiceToBeAvailableCallback =
base::OnceCallback<void(bool service_is_available)>;
// Returns an empty callback that does nothing.
COMPONENT_EXPORT(CHROMEOS_DBUS)
VoidDBusMethodCallback EmptyVoidDBusMethodCallback();
} // namespace chromeos
#endif // CHROMEOS_DBUS_DBUS_METHOD_CALL_STATUS_H_