Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRLAPI_BRLAPI_CONN ECTION_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRLAPI_BRLLAPI_CON NECTION_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "library_loaders/libbrlapi.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 namespace api { | |
| 15 namespace braille_display_private { | |
| 16 | |
| 17 // A connection to the brlapi server. | |
| 18 class BrlapiConnection { | |
| 19 public: | |
| 20 typedef base::Closure OnDataReadyCallback; | |
| 21 | |
| 22 static scoped_ptr<BrlapiConnection> Create(LibBrlapiLoader* loader); | |
| 23 | |
| 24 virtual ~BrlapiConnection(); | |
| 25 | |
| 26 virtual bool Connect(const OnDataReadyCallback& onDataReady) = 0; | |
| 27 | |
| 28 virtual void Disconnect() = 0; | |
| 29 | |
| 30 virtual bool Connected() = 0; | |
| 31 | |
| 32 // Gets the last brlapi error on this thread. | |
|
dmazzoni
2013/09/10 19:50:08
What do you mean by thread here? How are there mul
| |
| 33 virtual brlapi_error_t* BrlapiError() = 0; | |
| 34 | |
| 35 // Gets a description of the last brlapi error for this thread, useful | |
| 36 // for logging. | |
| 37 virtual std::string BrlapiStrError() = 0; | |
| 38 | |
| 39 // Gets the total size of the display, which may be 0 if no display is | |
| 40 // present, returning true on success. Note that this is cached in the | |
| 41 // brlapi client so it is cheap. | |
| 42 virtual bool GetDisplaySize(size_t* size) = 0; | |
| 43 | |
| 44 // Sends the specified cells to the display. The array size must | |
| 45 // be equal to what GetDisplaySize() last returned for this connection. | |
| 46 virtual bool WriteDots(const unsigned char* cells) = 0; | |
| 47 | |
| 48 // Reads the next keyboard command, returning true on success. | |
| 49 // Returns < 0 on error, 0 if no more keys are pending and > 0 | |
| 50 // on success, in which case keyCode will be set to the key command | |
| 51 // value. | |
| 52 virtual int ReadKey(brlapi_keyCode_t* keyCode) = 0; | |
| 53 | |
| 54 protected: | |
| 55 BrlapiConnection(); | |
| 56 DISALLOW_COPY_AND_ASSIGN(BrlapiConnection); | |
| 57 }; | |
| 58 | |
| 59 } // braille_display_private | |
| 60 } // api | |
| 61 } // extensions | |
| 62 | |
| 63 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRLAPI_BRLAPI_CO NNECTION_H_ | |
| OLD | NEW |