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

Side by Side Diff: chrome/browser/extensions/api/braille_display_private/brlapi_connection.h

Issue 13355002: Implement chrome.brailleDisplayPrivate API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stylistic issues from last review round. Created 7 years, 3 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 unified diff | Download patch
OLDNEW
(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. See brlapi.h for more information
18 // about the semantics of the methods in this class.
19 class BrlapiConnection {
20 public:
21 typedef base::Closure OnDataReadyCallback;
22
23 static scoped_ptr<BrlapiConnection> Create(LibBrlapiLoader* loader);
24
25 virtual ~BrlapiConnection();
26
27 virtual bool Connect(const OnDataReadyCallback& onDataReady) = 0;
28
29 virtual void Disconnect() = 0;
30
31 virtual bool Connected() = 0;
32
33 // Gets the last brlapi error on this thread.
34 // This works ismilar to errno in C. There's one thread-local error
35 // value, meaning that this method should be called after any
36 // other method of this class that can return an error without calling
37 // another method in between. This class is not thread safe.
38 virtual brlapi_error_t* BrlapiError() = 0;
39
40 // Gets a description of the last brlapi error for this thread, useful
41 // for logging.
42 virtual std::string BrlapiStrError() = 0;
43
44 // Gets the total size of the display, which may be 0 if no display is
45 // present, returning true on success. Note that this is cached in the
46 // brlapi client so it is cheap.
47 virtual bool GetDisplaySize(size_t* size) = 0;
48
49 // Sends the specified cells to the display. The array size must
50 // be equal to what GetDisplaySize() last returned for this connection.
51 virtual bool WriteDots(const unsigned char* cells) = 0;
52
53 // Reads the next keyboard command, returning true on success.
54 // Returns < 0 on error, 0 if no more keys are pending and > 0
55 // on success, in which case keyCode will be set to the key command
56 // value.
57 virtual int ReadKey(brlapi_keyCode_t* keyCode) = 0;
58
59 protected:
60 BrlapiConnection();
61 DISALLOW_COPY_AND_ASSIGN(BrlapiConnection);
62 };
63
64 } // braille_display_private
65 } // api
66 } // extensions
67
68 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRLAPI_BRLAPI_CO NNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698