| 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);
|
| }
|
|
|
|
|