diff options
author | reillyg <reillyg@chromium.org> | 2016-02-09 17:53:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-10 01:54:06 +0000 |
commit | ef3511f30c78a2e286c7dc427b2af18ec54cb0c9 (patch) | |
tree | 94a65626c095623eace0cc194b30b3304bdf0764 /device/serial | |
parent | 3c445925095b8b5620c590a199f512ca3b652613 (diff) | |
download | chromium_src-ef3511f30c78a2e286c7dc427b2af18ec54cb0c9.zip chromium_src-ef3511f30c78a2e286c7dc427b2af18ec54cb0c9.tar.gz chromium_src-ef3511f30c78a2e286c7dc427b2af18ec54cb0c9.tar.bz2 |
Add path open errors from the permission broker to the device log.
This change adds an additional ErrorCallback parameter to the permission
broker client so that the caller can get a better log message when its
request to open a device node fails.
This will hopefully help to determine the cause of the many "Did not get
valid device handle from permission broker" errors that some users are
seeing.
BUG=570784
Review URL: https://codereview.chromium.org/1681383002
Cr-Commit-Position: refs/heads/master@{#374571}
Diffstat (limited to 'device/serial')
-rw-r--r-- | device/serial/serial_io_handler.cc | 34 | ||||
-rw-r--r-- | device/serial/serial_io_handler.h | 10 |
2 files changed, 38 insertions, 6 deletions
diff --git a/device/serial/serial_io_handler.cc b/device/serial/serial_io_handler.cc index 35b41f7..a5257ed 100644 --- a/device/serial/serial_io_handler.cc +++ b/device/serial/serial_io_handler.cc @@ -54,12 +54,15 @@ void SerialIoHandler::Open(const std::string& port, chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); DCHECK(client) << "Could not get permission_broker client."; // PermissionBrokerClient should be called on the UI thread. + scoped_refptr<base::SingleThreadTaskRunner> task_runner = + base::ThreadTaskRunnerHandle::Get(); ui_thread_task_runner_->PostTask( - FROM_HERE, base::Bind(&chromeos::PermissionBrokerClient::OpenPath, - base::Unretained(client), port, - base::Bind(&SerialIoHandler::OnPathOpened, this, - file_thread_task_runner_, - base::ThreadTaskRunnerHandle::Get()))); + FROM_HERE, + base::Bind( + &chromeos::PermissionBrokerClient::OpenPath, base::Unretained(client), + port, base::Bind(&SerialIoHandler::OnPathOpened, this, + file_thread_task_runner_, task_runner), + base::Bind(&SerialIoHandler::OnPathOpenError, this, task_runner))); #else file_thread_task_runner_->PostTask( FROM_HERE, base::Bind(&SerialIoHandler::StartOpen, this, port, @@ -73,12 +76,20 @@ void SerialIoHandler::OnPathOpened( scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, dbus::FileDescriptor fd) { - DCHECK(CalledOnValidThread()); file_thread_task_runner->PostTask( FROM_HERE, base::Bind(&SerialIoHandler::ValidateOpenPort, this, io_thread_task_runner, base::Passed(&fd))); } +void SerialIoHandler::OnPathOpenError( + scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, + const std::string& error_name, + const std::string& error_message) { + io_thread_task_runner->PostTask( + FROM_HERE, base::Bind(&SerialIoHandler::ReportPathOpenError, this, + error_name, error_message)); +} + void SerialIoHandler::ValidateOpenPort( scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, dbus::FileDescriptor fd) { @@ -93,6 +104,17 @@ void SerialIoHandler::ValidateOpenPort( base::Bind(&SerialIoHandler::FinishOpen, this, base::Passed(&file))); } +void SerialIoHandler::ReportPathOpenError(const std::string& error_name, + const std::string& error_message) { + DCHECK(CalledOnValidThread()); + DCHECK(!open_complete_.is_null()); + LOG(ERROR) << "Permission broker failed to open '" << port_ + << "': " << error_name << ": " << error_message; + OpenCompleteCallback callback = open_complete_; + open_complete_.Reset(); + callback.Run(false); +} + #endif void SerialIoHandler::MergeConnectionOptions( diff --git a/device/serial/serial_io_handler.h b/device/serial/serial_io_handler.h index f494743..d1a4827 100644 --- a/device/serial/serial_io_handler.h +++ b/device/serial/serial_io_handler.h @@ -50,10 +50,20 @@ class SerialIoHandler : public base::NonThreadSafe, scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, dbus::FileDescriptor fd); + // Signals that the permission broker failed to open the port. + void OnPathOpenError( + scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, + const std::string& error_name, + const std::string& error_message); + // Validates the file descriptor provided by the permission broker. void ValidateOpenPort( scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, dbus::FileDescriptor fd); + + // Reports the open error from the permission broker. + void ReportPathOpenError(const std::string& error_name, + const std::string& error_message); #endif // defined(OS_CHROMEOS) // Performs an async Read operation. Behavior is undefined if this is called |