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

Unified Diff: chromeos/dbus/fake_permission_broker_client.cc

Issue 1681383002: Add path open errors from the permission broker to the device log. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_request_access
Patch Set: Created 4 years, 10 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
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 548173b5f1b33910ec30405e510d2309549d8a2b..b1c3d6ae1522beae4833f6a90723956b5f508cfd 100644
--- a/chromeos/dbus/fake_permission_broker_client.cc
+++ b/chromeos/dbus/fake_permission_broker_client.cc
@@ -12,6 +12,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
+#include "base/strings/stringprintf.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
#include "dbus/file_descriptor.h"
@@ -27,17 +28,24 @@ namespace {
void OpenPathAndValidate(
const std::string& path,
const PermissionBrokerClient::OpenPathCallback& callback,
+ const PermissionBrokerClient::ErrorCallback& error_callback,
scoped_refptr<base::TaskRunner> task_runner) {
- dbus::FileDescriptor dbus_fd;
int fd = HANDLE_EINTR(open(path.c_str(), O_RDWR));
if (fd < 0) {
- PLOG(WARNING) << "Failed to open '" << path << "'";
+ int error_code = logging::GetLastSystemErrorCode();
+ task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(error_callback, "open_failed",
stevenjb 2016/02/09 23:16:51 nit: define 'open_failed' as a const, make availab
Reilly Grant (use Gerrit) 2016/02/09 23:54:03 Which header do you recommend? permission_broker_c
stevenjb 2016/02/10 00:01:01 Oh, I didn't notice this was the fake. In that cas
Reilly Grant (use Gerrit) 2016/02/10 00:16:32 Done.
+ base::StringPrintf(
+ "Failed to open '%s': %s", path.c_str(),
+ logging::SystemErrorCodeToString(error_code).c_str())));
stevenjb 2016/02/09 23:16:51 nit: return here, remove else
Reilly Grant (use Gerrit) 2016/02/10 00:16:32 Done.
} else {
+ 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(&dbus_fd)));
}
} // namespace
@@ -55,11 +63,13 @@ void FakePermissionBrokerClient::CheckPathAccess(
}
void FakePermissionBrokerClient::OpenPath(const std::string& path,
- const OpenPathCallback& callback) {
- base::WorkerPool::PostTask(FROM_HERE,
- base::Bind(&OpenPathAndValidate, path, callback,
- base::ThreadTaskRunnerHandle::Get()),
- false);
+ const OpenPathCallback& callback,
+ const ErrorCallback& error_callback) {
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&OpenPathAndValidate, path, callback, error_callback,
+ base::ThreadTaskRunnerHandle::Get()),
+ false);
}
void FakePermissionBrokerClient::RequestTcpPortAccess(

Powered by Google App Engine
This is Rietveld 408576698