Commit 15510147 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Refactor chromeos::PermissionBrokerClient to use base::OnceCallback

Call sites are also updated to use base::BindOnce() instead of Bind()
or BindRepeating(), and remove AdaptCallbackForRepeating() where
possible.

Bug: 950118
Change-Id: I98449b98842a9c75f4ec670777cf245a51c683fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1555854
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649156}
parent 53c17cbf
...@@ -29,8 +29,8 @@ FakePermissionBrokerClient* g_instance = nullptr; ...@@ -29,8 +29,8 @@ FakePermissionBrokerClient* g_instance = nullptr;
// permission broker by opening the path specified and returning the resulting // permission broker by opening the path specified and returning the resulting
// file descriptor. // file descriptor.
void OpenPath(const std::string& path, void OpenPath(const std::string& path,
const PermissionBrokerClient::OpenPathCallback& callback, PermissionBrokerClient::OpenPathCallback callback,
const PermissionBrokerClient::ErrorCallback& error_callback, PermissionBrokerClient::ErrorCallback error_callback,
scoped_refptr<base::TaskRunner> task_runner) { scoped_refptr<base::TaskRunner> task_runner) {
base::ScopedFD fd(HANDLE_EINTR(open(path.c_str(), O_RDWR))); base::ScopedFD fd(HANDLE_EINTR(open(path.c_str(), O_RDWR)));
if (!fd.is_valid()) { if (!fd.is_valid()) {
...@@ -38,14 +38,15 @@ void OpenPath(const std::string& path, ...@@ -38,14 +38,15 @@ void OpenPath(const std::string& path,
task_runner->PostTask( task_runner->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
error_callback, kOpenFailedError, std::move(error_callback), kOpenFailedError,
base::StringPrintf( base::StringPrintf(
"Failed to open '%s': %s", path.c_str(), "Failed to open '%s': %s", path.c_str(),
logging::SystemErrorCodeToString(error_code).c_str()))); logging::SystemErrorCodeToString(error_code).c_str())));
return; return;
} }
task_runner->PostTask(FROM_HERE, base::BindOnce(callback, std::move(fd))); task_runner->PostTask(FROM_HERE,
base::BindOnce(std::move(callback), std::move(fd)));
} }
} // namespace } // namespace
...@@ -66,19 +67,19 @@ FakePermissionBrokerClient* FakePermissionBrokerClient::Get() { ...@@ -66,19 +67,19 @@ FakePermissionBrokerClient* FakePermissionBrokerClient::Get() {
return g_instance; return g_instance;
} }
void FakePermissionBrokerClient::CheckPathAccess( void FakePermissionBrokerClient::CheckPathAccess(const std::string& path,
const std::string& path, ResultCallback callback) {
const ResultCallback& callback) { std::move(callback).Run(true);
callback.Run(true);
} }
void FakePermissionBrokerClient::OpenPath(const std::string& path, void FakePermissionBrokerClient::OpenPath(const std::string& path,
const OpenPathCallback& callback, OpenPathCallback callback,
const ErrorCallback& error_callback) { ErrorCallback error_callback) {
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, FROM_HERE,
{base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::BindOnce(&chromeos::OpenPath, path, callback, error_callback, base::BindOnce(&chromeos::OpenPath, path, std::move(callback),
std::move(error_callback),
base::ThreadTaskRunnerHandle::Get())); base::ThreadTaskRunnerHandle::Get()));
} }
...@@ -86,8 +87,8 @@ void FakePermissionBrokerClient::RequestTcpPortAccess( ...@@ -86,8 +87,8 @@ void FakePermissionBrokerClient::RequestTcpPortAccess(
uint16_t port, uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) { ResultCallback callback) {
callback.Run( std::move(callback).Run(
RequestPortImpl(port, interface, tcp_deny_rule_set_, &tcp_hole_set_)); RequestPortImpl(port, interface, tcp_deny_rule_set_, &tcp_hole_set_));
} }
...@@ -95,23 +96,21 @@ void FakePermissionBrokerClient::RequestUdpPortAccess( ...@@ -95,23 +96,21 @@ void FakePermissionBrokerClient::RequestUdpPortAccess(
uint16_t port, uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) { ResultCallback callback) {
callback.Run( std::move(callback).Run(
RequestPortImpl(port, interface, udp_deny_rule_set_, &udp_hole_set_)); RequestPortImpl(port, interface, udp_deny_rule_set_, &udp_hole_set_));
} }
void FakePermissionBrokerClient::ReleaseTcpPort( void FakePermissionBrokerClient::ReleaseTcpPort(uint16_t port,
uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) { ResultCallback callback) {
callback.Run(tcp_hole_set_.erase(std::make_pair(port, interface))); std::move(callback).Run(tcp_hole_set_.erase(std::make_pair(port, interface)));
} }
void FakePermissionBrokerClient::ReleaseUdpPort( void FakePermissionBrokerClient::ReleaseUdpPort(uint16_t port,
uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) { ResultCallback callback) {
callback.Run(udp_hole_set_.erase(std::make_pair(port, interface))); std::move(callback).Run(udp_hole_set_.erase(std::make_pair(port, interface)));
} }
void FakePermissionBrokerClient::AddTcpDenyRule(uint16_t port, void FakePermissionBrokerClient::AddTcpDenyRule(uint16_t port,
......
...@@ -27,24 +27,24 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) FakePermissionBrokerClient ...@@ -27,24 +27,24 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) FakePermissionBrokerClient
static FakePermissionBrokerClient* Get(); static FakePermissionBrokerClient* Get();
void CheckPathAccess(const std::string& path, void CheckPathAccess(const std::string& path,
const ResultCallback& callback) override; ResultCallback callback) override;
void OpenPath(const std::string& path, void OpenPath(const std::string& path,
const OpenPathCallback& callback, OpenPathCallback callback,
const ErrorCallback& error_callback) override; ErrorCallback error_callback) override;
void RequestTcpPortAccess(uint16_t port, void RequestTcpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) override; ResultCallback callback) override;
void RequestUdpPortAccess(uint16_t port, void RequestUdpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) override; ResultCallback callback) override;
void ReleaseTcpPort(uint16_t port, void ReleaseTcpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) override; ResultCallback callback) override;
void ReleaseUdpPort(uint16_t port, void ReleaseUdpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) override; ResultCallback callback) override;
// Add a rule to have RequestTcpPortAccess fail. // Add a rule to have RequestTcpPortAccess fail.
void AddTcpDenyRule(uint16_t port, const std::string& interface); void AddTcpDenyRule(uint16_t port, const std::string& interface);
......
...@@ -42,34 +42,35 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -42,34 +42,35 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
~PermissionBrokerClientImpl() override = default; ~PermissionBrokerClientImpl() override = default;
void CheckPathAccess(const std::string& path, void CheckPathAccess(const std::string& path,
const ResultCallback& callback) override { ResultCallback callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, kCheckPathAccess); dbus::MethodCall method_call(kPermissionBrokerInterface, kCheckPathAccess);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendString(path); writer.AppendString(path);
proxy_->CallMethod( proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnResponse, base::BindOnce(&PermissionBrokerClientImpl::OnResponse,
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void OpenPath(const std::string& path, void OpenPath(const std::string& path,
const OpenPathCallback& callback, OpenPathCallback callback,
const ErrorCallback& error_callback) override { ErrorCallback error_callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, kOpenPath); dbus::MethodCall method_call(kPermissionBrokerInterface, kOpenPath);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendString(path); writer.AppendString(path);
proxy_->CallMethodWithErrorCallback( proxy_->CallMethodWithErrorCallback(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnOpenPathResponse, base::BindOnce(&PermissionBrokerClientImpl::OnOpenPathResponse,
weak_ptr_factory_.GetWeakPtr(), callback), weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
base::BindOnce(&PermissionBrokerClientImpl::OnError, base::BindOnce(&PermissionBrokerClientImpl::OnError,
weak_ptr_factory_.GetWeakPtr(), error_callback)); weak_ptr_factory_.GetWeakPtr(),
std::move(error_callback)));
} }
void RequestTcpPortAccess(uint16_t port, void RequestTcpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) override { ResultCallback callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, dbus::MethodCall method_call(kPermissionBrokerInterface,
kRequestTcpPortAccess); kRequestTcpPortAccess);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
...@@ -79,13 +80,13 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -79,13 +80,13 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
proxy_->CallMethod( proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnResponse, base::BindOnce(&PermissionBrokerClientImpl::OnResponse,
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void RequestUdpPortAccess(uint16_t port, void RequestUdpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) override { ResultCallback callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, dbus::MethodCall method_call(kPermissionBrokerInterface,
kRequestUdpPortAccess); kRequestUdpPortAccess);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
...@@ -95,12 +96,12 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -95,12 +96,12 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
proxy_->CallMethod( proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnResponse, base::BindOnce(&PermissionBrokerClientImpl::OnResponse,
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void ReleaseTcpPort(uint16_t port, void ReleaseTcpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) override { ResultCallback callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, kReleaseTcpPort); dbus::MethodCall method_call(kPermissionBrokerInterface, kReleaseTcpPort);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendUint16(port); writer.AppendUint16(port);
...@@ -108,12 +109,12 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -108,12 +109,12 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
proxy_->CallMethod( proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnResponse, base::BindOnce(&PermissionBrokerClientImpl::OnResponse,
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void ReleaseUdpPort(uint16_t port, void ReleaseUdpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) override { ResultCallback callback) override {
dbus::MethodCall method_call(kPermissionBrokerInterface, kReleaseUdpPort); dbus::MethodCall method_call(kPermissionBrokerInterface, kReleaseUdpPort);
dbus::MessageWriter writer(&method_call); dbus::MessageWriter writer(&method_call);
writer.AppendUint16(port); writer.AppendUint16(port);
...@@ -121,7 +122,7 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -121,7 +122,7 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
proxy_->CallMethod( proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&PermissionBrokerClientImpl::OnResponse, base::BindOnce(&PermissionBrokerClientImpl::OnResponse,
weak_ptr_factory_.GetWeakPtr(), callback)); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void Init(dbus::Bus* bus) { void Init(dbus::Bus* bus) {
...@@ -133,10 +134,10 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -133,10 +134,10 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
private: private:
// Handle a DBus response from the permission broker, invoking the callback // Handle a DBus response from the permission broker, invoking the callback
// that the method was originally called with with the success response. // that the method was originally called with with the success response.
void OnResponse(const ResultCallback& callback, dbus::Response* response) { void OnResponse(ResultCallback callback, dbus::Response* response) {
if (!response) { if (!response) {
LOG(WARNING) << "Access request method call failed."; LOG(WARNING) << "Access request method call failed.";
callback.Run(false); std::move(callback).Run(false);
return; return;
} }
...@@ -144,19 +145,18 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -144,19 +145,18 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
dbus::MessageReader reader(response); dbus::MessageReader reader(response);
if (!reader.PopBool(&result)) if (!reader.PopBool(&result))
LOG(WARNING) << "Could not parse response: " << response->ToString(); LOG(WARNING) << "Could not parse response: " << response->ToString();
callback.Run(result); std::move(callback).Run(result);
} }
void OnOpenPathResponse(const OpenPathCallback& callback, void OnOpenPathResponse(OpenPathCallback callback, dbus::Response* response) {
dbus::Response* response) {
base::ScopedFD fd; base::ScopedFD fd;
dbus::MessageReader reader(response); dbus::MessageReader reader(response);
if (!reader.PopFileDescriptor(&fd)) if (!reader.PopFileDescriptor(&fd))
LOG(WARNING) << "Could not parse response: " << response->ToString(); LOG(WARNING) << "Could not parse response: " << response->ToString();
callback.Run(std::move(fd)); std::move(callback).Run(std::move(fd));
} }
void OnError(const ErrorCallback& callback, dbus::ErrorResponse* response) { void OnError(ErrorCallback callback, dbus::ErrorResponse* response) {
std::string error_name; std::string error_name;
std::string error_message; std::string error_message;
if (response) { if (response) {
...@@ -166,7 +166,7 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient { ...@@ -166,7 +166,7 @@ class PermissionBrokerClientImpl : public PermissionBrokerClient {
} else { } else {
error_name = kNoResponseError; error_name = kNoResponseError;
} }
callback.Run(error_name, error_message); std::move(callback).Run(error_name, error_message);
} }
dbus::ObjectProxy* proxy_ = nullptr; dbus::ObjectProxy* proxy_ = nullptr;
......
...@@ -32,16 +32,15 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient { ...@@ -32,16 +32,15 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient {
// The ResultCallback is used for both the RequestPathAccess and // The ResultCallback is used for both the RequestPathAccess and
// RequestUsbAccess methods. Its boolean parameter represents the result of // RequestUsbAccess methods. Its boolean parameter represents the result of
// the operation that it was submitted alongside. // the operation that it was submitted alongside.
typedef base::Callback<void(bool)> ResultCallback; using ResultCallback = base::OnceCallback<void(bool)>;
// An OpenPathCallback callback is run when an OpenPath request is completed. // An OpenPathCallback callback is run when an OpenPath request is completed.
typedef base::Callback<void(base::ScopedFD)> OpenPathCallback; using OpenPathCallback = base::OnceCallback<void(base::ScopedFD)>;
// An ErrorCallback callback is run when an error is returned by the // An ErrorCallback callback is run when an error is returned by the
// permission broker. // permission broker.
typedef base::Callback<void(const std::string& error_name, using ErrorCallback = base::OnceCallback<void(const std::string& error_name,
const std::string& message)> const std::string& message)>;
ErrorCallback;
// Creates and initializes the global instance. |bus| must not be null. // Creates and initializes the global instance. |bus| must not be null.
static void Initialize(dbus::Bus* bus); static void Initialize(dbus::Bus* bus);
...@@ -60,14 +59,14 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient { ...@@ -60,14 +59,14 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient {
// the |interface_id| value passed to RequestPathAccess will be // the |interface_id| value passed to RequestPathAccess will be
// UsbDevicePermissionsData::ANY_INTERFACE). // UsbDevicePermissionsData::ANY_INTERFACE).
virtual void CheckPathAccess(const std::string& path, virtual void CheckPathAccess(const std::string& path,
const ResultCallback& callback) = 0; ResultCallback callback) = 0;
// OpenPath requests that the permission broker open the device node // OpenPath requests that the permission broker open the device node
// identified by |path| and return the resulting file descriptor. One of // identified by |path| and return the resulting file descriptor. One of
// |callback| or |error_callback| is called. // |callback| or |error_callback| is called.
virtual void OpenPath(const std::string& path, virtual void OpenPath(const std::string& path,
const OpenPathCallback& callback, OpenPathCallback callback,
const ErrorCallback& error_callback) = 0; ErrorCallback error_callback) = 0;
// Requests the |port| be opened on the firewall for incoming TCP/IP // Requests the |port| be opened on the firewall for incoming TCP/IP
// connections received on |interface| (an empty string indicates all // connections received on |interface| (an empty string indicates all
...@@ -78,7 +77,7 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient { ...@@ -78,7 +77,7 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient {
virtual void RequestTcpPortAccess(uint16_t port, virtual void RequestTcpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) = 0; ResultCallback callback) = 0;
// Requests the |port| be opened on the firewall for incoming UDP packets // Requests the |port| be opened on the firewall for incoming UDP packets
// received on |interface| (an empty string indicates all interfaces). One end // received on |interface| (an empty string indicates all interfaces). One end
...@@ -89,21 +88,21 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient { ...@@ -89,21 +88,21 @@ class COMPONENT_EXPORT(PERMISSION_BROKER) PermissionBrokerClient {
virtual void RequestUdpPortAccess(uint16_t port, virtual void RequestUdpPortAccess(uint16_t port,
const std::string& interface, const std::string& interface,
int lifeline_fd, int lifeline_fd,
const ResultCallback& callback) = 0; ResultCallback callback) = 0;
// Releases a request for an open firewall port for TCP/IP connections. The // Releases a request for an open firewall port for TCP/IP connections. The
// |port| and |interface| parameters must be the same as a previous call to // |port| and |interface| parameters must be the same as a previous call to
// RequestTcpPortAccess. // RequestTcpPortAccess.
virtual void ReleaseTcpPort(uint16_t port, virtual void ReleaseTcpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) = 0; ResultCallback callback) = 0;
// Releases a request for an open firewall port for UDP packets. The |port| // Releases a request for an open firewall port for UDP packets. The |port|
// and |interface| parameters must be the same as a previous call to // and |interface| parameters must be the same as a previous call to
// RequestUdpPortAccess. // RequestUdpPortAccess.
virtual void ReleaseUdpPort(uint16_t port, virtual void ReleaseUdpPort(uint16_t port,
const std::string& interface, const std::string& interface,
const ResultCallback& callback) = 0; ResultCallback callback) = 0;
protected: protected:
// Initialize/Shutdown should be used instead. // Initialize/Shutdown should be used instead.
......
...@@ -60,9 +60,9 @@ void FirewallHole::Open(PortType type, ...@@ -60,9 +60,9 @@ void FirewallHole::Open(PortType type,
base::ScopedFD lifeline_local(lifeline[0]); base::ScopedFD lifeline_local(lifeline[0]);
base::ScopedFD lifeline_remote(lifeline[1]); base::ScopedFD lifeline_remote(lifeline[1]);
base::Callback<void(bool)> access_granted_closure = base::OnceCallback<void(bool)> access_granted_closure =
base::Bind(&FirewallHole::PortAccessGranted, type, port, interface, base::BindOnce(&FirewallHole::PortAccessGranted, type, port, interface,
base::Passed(&lifeline_local), callback); std::move(lifeline_local), callback);
PermissionBrokerClient* client = PermissionBrokerClient::Get(); PermissionBrokerClient* client = PermissionBrokerClient::Get();
DCHECK(client) << "Could not get permission broker client."; DCHECK(client) << "Could not get permission broker client.";
...@@ -70,27 +70,29 @@ void FirewallHole::Open(PortType type, ...@@ -70,27 +70,29 @@ void FirewallHole::Open(PortType type,
switch (type) { switch (type) {
case PortType::TCP: case PortType::TCP:
client->RequestTcpPortAccess(port, interface, lifeline_remote.get(), client->RequestTcpPortAccess(port, interface, lifeline_remote.get(),
access_granted_closure); std::move(access_granted_closure));
return; return;
case PortType::UDP: case PortType::UDP:
client->RequestUdpPortAccess(port, interface, lifeline_remote.get(), client->RequestUdpPortAccess(port, interface, lifeline_remote.get(),
access_granted_closure); std::move(access_granted_closure));
return; return;
} }
} }
FirewallHole::~FirewallHole() { FirewallHole::~FirewallHole() {
base::Callback<void(bool)> port_released_closure = base::Bind( base::OnceCallback<void(bool)> port_released_closure = base::BindOnce(
&PortReleased, type_, port_, interface_, base::Passed(&lifeline_fd_)); &PortReleased, type_, port_, interface_, std::move(lifeline_fd_));
PermissionBrokerClient* client = PermissionBrokerClient::Get(); PermissionBrokerClient* client = PermissionBrokerClient::Get();
DCHECK(client) << "Could not get permission broker client."; DCHECK(client) << "Could not get permission broker client.";
switch (type_) { switch (type_) {
case PortType::TCP: case PortType::TCP:
client->ReleaseTcpPort(port_, interface_, port_released_closure); client->ReleaseTcpPort(port_, interface_,
std::move(port_released_closure));
return; return;
case PortType::UDP: case PortType::UDP:
client->ReleaseUdpPort(port_, interface_, port_released_closure); client->ReleaseUdpPort(port_, interface_,
std::move(port_released_closure));
return; return;
} }
} }
......
...@@ -159,8 +159,9 @@ void ArcUsbHostBridge::OpenDevice(const std::string& guid, ...@@ -159,8 +159,9 @@ void ArcUsbHostBridge::OpenDevice(const std::string& guid,
auto repeating_callback = auto repeating_callback =
base::AdaptCallbackForRepeating(std::move(callback)); base::AdaptCallbackForRepeating(std::move(callback));
chromeos::PermissionBrokerClient::Get()->OpenPath( chromeos::PermissionBrokerClient::Get()->OpenPath(
device->device_path(), base::Bind(&OnDeviceOpened, repeating_callback), device->device_path(),
base::Bind(&OnDeviceOpenError, repeating_callback)); base::BindOnce(&OnDeviceOpened, repeating_callback),
base::BindOnce(&OnDeviceOpenError, repeating_callback));
} }
void ArcUsbHostBridge::OpenDeviceDeprecated( void ArcUsbHostBridge::OpenDeviceDeprecated(
......
...@@ -97,9 +97,9 @@ void DeviceManagerImpl::OpenFileDescriptor( ...@@ -97,9 +97,9 @@ void DeviceManagerImpl::OpenFileDescriptor(
static_cast<device::UsbDeviceLinux*>(device.get())->device_path(); static_cast<device::UsbDeviceLinux*>(device.get())->device_path();
chromeos::PermissionBrokerClient::Get()->OpenPath( chromeos::PermissionBrokerClient::Get()->OpenPath(
devpath, devpath,
base::BindRepeating(&DeviceManagerImpl::OnOpenFileDescriptor, base::BindOnce(&DeviceManagerImpl::OnOpenFileDescriptor,
weak_factory_.GetWeakPtr(), copyable_callback), weak_factory_.GetWeakPtr(), copyable_callback),
base::BindRepeating(&DeviceManagerImpl::OnOpenFileDescriptorError, base::BindOnce(&DeviceManagerImpl::OnOpenFileDescriptorError,
weak_factory_.GetWeakPtr(), copyable_callback)); weak_factory_.GetWeakPtr(), copyable_callback));
} }
} }
......
...@@ -48,8 +48,8 @@ UsbDeviceLinux::~UsbDeviceLinux() = default; ...@@ -48,8 +48,8 @@ UsbDeviceLinux::~UsbDeviceLinux() = default;
void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) { void UsbDeviceLinux::CheckUsbAccess(ResultCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
chromeos::PermissionBrokerClient::Get()->CheckPathAccess( chromeos::PermissionBrokerClient::Get()->CheckPathAccess(device_path_,
device_path_, base::AdaptCallbackForRepeating(std::move(callback))); std::move(callback));
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -61,9 +61,10 @@ void UsbDeviceLinux::Open(OpenCallback callback) { ...@@ -61,9 +61,10 @@ void UsbDeviceLinux::Open(OpenCallback callback) {
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback)); auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
chromeos::PermissionBrokerClient::Get()->OpenPath( chromeos::PermissionBrokerClient::Get()->OpenPath(
device_path_, device_path_,
base::Bind(&UsbDeviceLinux::OnOpenRequestComplete, this, base::BindOnce(&UsbDeviceLinux::OnOpenRequestComplete, this,
copyable_callback), copyable_callback),
base::Bind(&UsbDeviceLinux::OnOpenRequestError, this, copyable_callback)); base::BindOnce(&UsbDeviceLinux::OnOpenRequestError, this,
copyable_callback));
#else #else
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = scoped_refptr<base::SequencedTaskRunner> blocking_task_runner =
UsbService::CreateBlockingTaskRunner(); UsbService::CreateBlockingTaskRunner();
......
...@@ -262,8 +262,8 @@ class HidDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt, ...@@ -262,8 +262,8 @@ class HidDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
chromeos::PermissionBrokerClient::Get()->CheckPathAccess( chromeos::PermissionBrokerClient::Get()->CheckPathAccess(
device_info.get()->device()->device_node, device_info.get()->device()->device_node,
base::Bind(&HidDevicePermissionsPrompt::AddCheckedDevice, this, base::BindOnce(&HidDevicePermissionsPrompt::AddCheckedDevice, this,
base::Passed(&device_info))); std::move(device_info)));
#else #else
AddCheckedDevice(std::move(device_info), true); AddCheckedDevice(std::move(device_info), true);
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
......
...@@ -225,12 +225,12 @@ void HidServiceLinux::Connect(const std::string& device_guid, ...@@ -225,12 +225,12 @@ void HidServiceLinux::Connect(const std::string& device_guid,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
chromeos::PermissionBrokerClient::ErrorCallback error_callback = chromeos::PermissionBrokerClient::ErrorCallback error_callback =
base::Bind(&HidServiceLinux::OnPathOpenError, base::BindOnce(&HidServiceLinux::OnPathOpenError,
params->device_info->device_node(), params->callback); params->device_info->device_node(), params->callback);
chromeos::PermissionBrokerClient::Get()->OpenPath( chromeos::PermissionBrokerClient::Get()->OpenPath(
device_info->device_node(), device_info->device_node(),
base::Bind(&HidServiceLinux::OnPathOpenComplete, base::Passed(&params)), base::BindOnce(&HidServiceLinux::OnPathOpenComplete, std::move(params)),
error_callback); std::move(error_callback));
#else #else
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner = scoped_refptr<base::SequencedTaskRunner> blocking_task_runner =
params->blocking_task_runner; params->blocking_task_runner;
......
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