Chromium Code Reviews| Index: chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc |
| diff --git a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc |
| index 5739710383dceb519f03c0051fd71f11a875efd0..0aeb86756db329c2c61e2ec3f7b6b0fbeeb9ed98 100644 |
| --- a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc |
| +++ b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc |
| @@ -43,8 +43,8 @@ class BrlapiConnectionImpl : public BrlapiConnection, |
| bool Connected() override { return handle_ != nullptr; } |
| brlapi_error_t* BrlapiError() override; |
| std::string BrlapiStrError() override; |
| - bool GetDisplaySize(size_t* size) override; |
| - bool WriteDots(const unsigned char* cells) override; |
| + bool GetDisplaySize(unsigned int* rows, unsigned int* columns) override; |
| + bool WriteDots(const std::vector<std::vector<unsigned char>> cells) override; |
| int ReadKey(brlapi_keyCode_t* keyCode) override; |
| // MessageLoopForIO::Watcher |
| @@ -101,9 +101,9 @@ BrlapiConnection::ConnectResult BrlapiConnectionImpl::Connect( |
| Disconnect(); |
| return CONNECT_ERROR_RETRY; |
| } |
| + unsigned int rows, columns; |
| - size_t size; |
| - if (!GetDisplaySize(&size)) { |
| + if (!GetDisplaySize(&rows, &columns)) { |
| // Error already logged. |
| Disconnect(); |
| return CONNECT_ERROR_RETRY; |
| @@ -112,7 +112,7 @@ BrlapiConnection::ConnectResult BrlapiConnectionImpl::Connect( |
| // A display size of 0 means no display connected. We can't reliably |
| // detect when a display gets connected, so fail and let the caller |
| // retry connecting. |
| - if (size == 0) { |
| + if (rows * columns == 0) { |
| VLOG(1) << "No braille display connected"; |
| Disconnect(); |
| return CONNECT_ERROR_RETRY; |
| @@ -162,24 +162,25 @@ std::string BrlapiConnectionImpl::BrlapiStrError() { |
| return libbrlapi_loader_->brlapi_strerror(BrlapiError()); |
| } |
| -bool BrlapiConnectionImpl::GetDisplaySize(size_t* size) { |
| +bool BrlapiConnectionImpl::GetDisplaySize(unsigned int* rows, |
| + unsigned int* columns) { |
| if (!CheckConnected()) { |
| return false; |
| } |
| - unsigned int columns, rows; |
| if (libbrlapi_loader_->brlapi__getDisplaySize( |
| - handle_.get(), &columns, &rows) < 0) { |
| + handle_.get(), columns, rows) < 0) { |
| LOG(ERROR) << "Couldn't get braille display size " << BrlapiStrError(); |
| return false; |
| } |
| - *size = columns * rows; |
| return true; |
| } |
| -bool BrlapiConnectionImpl::WriteDots(const unsigned char* cells) { |
| +bool BrlapiConnectionImpl::WriteDots( |
| + const std::vector<std::vector<unsigned char>> cells) { |
|
dmazzoni
2016/10/11 17:15:39
This should be indented 4 spaces
ultimatedbz
2016/10/16 01:12:39
Done.
|
| + // Cells is a 2D vector, but for now, we are just displaying the first row. |
| if (!CheckConnected()) |
| return false; |
| - if (libbrlapi_loader_->brlapi__writeDots(handle_.get(), cells) < 0) { |
| + if (libbrlapi_loader_->brlapi__writeDots(handle_.get(), &cells[0][0]) < 0) { |
|
dmazzoni
2016/10/11 17:15:39
I could be wrong but I think it just wants a singl
ultimatedbz
2016/10/16 01:12:39
Done.
|
| VLOG(1) << "Couldn't write to brlapi: " << BrlapiStrError(); |
| return false; |
| } |