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

Unified Diff: chromeos/dbus/fake_permission_broker_client.cc

Issue 2291983002: chromeos: Remove dbus::FileDescriptor from PermissionBrokerClient (Closed)
Patch Set: Address comments Created 4 years, 4 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 | « chromeos/dbus/fake_permission_broker_client.h ('k') | chromeos/dbus/mock_permission_broker_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_permission_broker_client.cc
diff --git a/chromeos/dbus/fake_permission_broker_client.cc b/chromeos/dbus/fake_permission_broker_client.cc
index b76865ba40c2e3ec3fe7d4d13666e038c6d93f0b..cead1d845004eea11325a9533c04f58713f57842 100644
--- a/chromeos/dbus/fake_permission_broker_client.cc
+++ b/chromeos/dbus/fake_permission_broker_client.cc
@@ -27,13 +27,12 @@ const char kOpenFailedError[] = "open_failed";
// function implements a simplified version of the method implemented by the
// permission broker by opening the path specified and returning the resulting
// file descriptor.
-void OpenPathAndValidate(
- const std::string& path,
- const PermissionBrokerClient::OpenPathCallback& callback,
- const PermissionBrokerClient::ErrorCallback& error_callback,
- scoped_refptr<base::TaskRunner> task_runner) {
- int fd = HANDLE_EINTR(open(path.c_str(), O_RDWR));
- if (fd < 0) {
+void OpenPath(const std::string& path,
+ const PermissionBrokerClient::OpenPathCallback& callback,
+ const PermissionBrokerClient::ErrorCallback& error_callback,
+ scoped_refptr<base::TaskRunner> task_runner) {
+ base::ScopedFD fd(HANDLE_EINTR(open(path.c_str(), O_RDWR)));
+ if (!fd.is_valid()) {
int error_code = logging::GetLastSystemErrorCode();
task_runner->PostTask(
FROM_HERE,
@@ -44,11 +43,7 @@ void OpenPathAndValidate(
return;
}
- dbus::FileDescriptor dbus_fd;
- dbus_fd.PutValue(fd);
- dbus_fd.CheckValidity();
- task_runner->PostTask(FROM_HERE,
- base::Bind(callback, base::Passed(&dbus_fd)));
+ task_runner->PostTask(FROM_HERE, base::Bind(callback, base::Passed(&fd)));
}
} // namespace
@@ -69,27 +64,24 @@ void FakePermissionBrokerClient::OpenPath(const std::string& path,
const OpenPathCallback& callback,
const ErrorCallback& error_callback) {
base::WorkerPool::PostTask(
- FROM_HERE,
- base::Bind(&OpenPathAndValidate, path, callback, error_callback,
- base::ThreadTaskRunnerHandle::Get()),
+ FROM_HERE, base::Bind(&chromeos::OpenPath, path, callback, error_callback,
+ base::ThreadTaskRunnerHandle::Get()),
false);
}
void FakePermissionBrokerClient::RequestTcpPortAccess(
uint16_t port,
const std::string& interface,
- const dbus::FileDescriptor& lifeline_fd,
+ int lifeline_fd,
const ResultCallback& callback) {
- DCHECK(lifeline_fd.is_valid());
callback.Run(true);
}
void FakePermissionBrokerClient::RequestUdpPortAccess(
uint16_t port,
const std::string& interface,
- const dbus::FileDescriptor& lifeline_fd,
+ int lifeline_fd,
const ResultCallback& callback) {
- DCHECK(lifeline_fd.is_valid());
callback.Run(true);
}
« no previous file with comments | « chromeos/dbus/fake_permission_broker_client.h ('k') | chromeos/dbus/mock_permission_broker_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698