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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROLLER _BRLAPI_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROLLER _BRLAPI_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROLLER _BRLAPI_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROLLER _BRLAPI_H_
7 7
8 #include <memory>
9
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/file_path_watcher.h" 11 #include "base/files/file_path_watcher.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h" 15 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h"
15 #include "chrome/browser/extensions/api/braille_display_private/brlapi_connectio n.h" 16 #include "chrome/browser/extensions/api/braille_display_private/brlapi_connectio n.h"
16 #include "library_loaders/libbrlapi.h" 17 #include "library_loaders/libbrlapi.h"
17 18
18 namespace extensions { 19 namespace extensions {
19 namespace api { 20 namespace api {
20 namespace braille_display_private { 21 namespace braille_display_private {
21 22
22 // BrailleController implementation based on libbrlapi from brltty. 23 // BrailleController implementation based on libbrlapi from brltty.
23 class BrailleControllerImpl : public BrailleController { 24 class BrailleControllerImpl : public BrailleController {
24 public: 25 public:
25 static BrailleControllerImpl* GetInstance(); 26 static BrailleControllerImpl* GetInstance();
26 scoped_ptr<DisplayState> GetDisplayState() override; 27 std::unique_ptr<DisplayState> GetDisplayState() override;
27 void WriteDots(const std::vector<char>& cells) override; 28 void WriteDots(const std::vector<char>& cells) override;
28 void AddObserver(BrailleObserver* observer) override; 29 void AddObserver(BrailleObserver* observer) override;
29 void RemoveObserver(BrailleObserver* observer) override; 30 void RemoveObserver(BrailleObserver* observer) override;
30 31
31 private: 32 private:
32 // For the unit tests. 33 // For the unit tests.
33 friend class BrailleDisplayPrivateApiTest; 34 friend class BrailleDisplayPrivateApiTest;
34 friend class MockBrlapiConnection; 35 friend class MockBrlapiConnection;
35 36
36 BrailleControllerImpl(); 37 BrailleControllerImpl();
37 ~BrailleControllerImpl() override; 38 ~BrailleControllerImpl() override;
38 void TryLoadLibBrlApi(); 39 void TryLoadLibBrlApi();
39 40
40 typedef base::Callback<scoped_ptr<BrlapiConnection>()> 41 typedef base::Callback<std::unique_ptr<BrlapiConnection>()>
41 CreateBrlapiConnectionFunction; 42 CreateBrlapiConnectionFunction;
42 43
43 // For dependency injection in tests. Sets the function used to create 44 // For dependency injection in tests. Sets the function used to create
44 // brlapi connections. 45 // brlapi connections.
45 void SetCreateBrlapiConnectionForTesting( 46 void SetCreateBrlapiConnectionForTesting(
46 const CreateBrlapiConnectionFunction& callback); 47 const CreateBrlapiConnectionFunction& callback);
47 48
48 // Makes the controller try to reconnect (if disconnected) as if the brlapi 49 // Makes the controller try to reconnect (if disconnected) as if the brlapi
49 // socket directory had changed. 50 // socket directory had changed.
50 void PokeSocketDirForTesting(); 51 void PokeSocketDirForTesting();
51 52
52 // Tries to connect and starts watching for new brlapi servers. 53 // Tries to connect and starts watching for new brlapi servers.
53 // No-op if already called. 54 // No-op if already called.
54 void StartConnecting(); 55 void StartConnecting();
55 void StartWatchingSocketDirOnFileThread(); 56 void StartWatchingSocketDirOnFileThread();
56 void OnSocketDirChangedOnFileThread(const base::FilePath& path, bool error); 57 void OnSocketDirChangedOnFileThread(const base::FilePath& path, bool error);
57 void OnSocketDirChangedOnIOThread(); 58 void OnSocketDirChangedOnIOThread();
58 void TryToConnect(); 59 void TryToConnect();
59 void ResetRetryConnectHorizon(); 60 void ResetRetryConnectHorizon();
60 void ScheduleTryToConnect(); 61 void ScheduleTryToConnect();
61 void Disconnect(); 62 void Disconnect();
62 scoped_ptr<BrlapiConnection> CreateBrlapiConnection(); 63 std::unique_ptr<BrlapiConnection> CreateBrlapiConnection();
63 void DispatchKeys(); 64 void DispatchKeys();
64 void DispatchKeyEvent(scoped_ptr<KeyEvent> event); 65 void DispatchKeyEvent(std::unique_ptr<KeyEvent> event);
65 void DispatchOnDisplayStateChanged(scoped_ptr<DisplayState> new_state); 66 void DispatchOnDisplayStateChanged(std::unique_ptr<DisplayState> new_state);
66 67
67 CreateBrlapiConnectionFunction create_brlapi_connection_function_; 68 CreateBrlapiConnectionFunction create_brlapi_connection_function_;
68 69
69 // Manipulated on the IO thread. 70 // Manipulated on the IO thread.
70 LibBrlapiLoader libbrlapi_loader_; 71 LibBrlapiLoader libbrlapi_loader_;
71 scoped_ptr<BrlapiConnection> connection_; 72 std::unique_ptr<BrlapiConnection> connection_;
72 bool started_connecting_; 73 bool started_connecting_;
73 bool connect_scheduled_; 74 bool connect_scheduled_;
74 base::Time retry_connect_horizon_; 75 base::Time retry_connect_horizon_;
75 76
76 // Manipulated on the UI thread. 77 // Manipulated on the UI thread.
77 base::ObserverList<BrailleObserver> observers_; 78 base::ObserverList<BrailleObserver> observers_;
78 79
79 // Manipulated on the FILE thread. 80 // Manipulated on the FILE thread.
80 base::FilePathWatcher file_path_watcher_; 81 base::FilePathWatcher file_path_watcher_;
81 82
82 friend struct base::DefaultSingletonTraits<BrailleControllerImpl>; 83 friend struct base::DefaultSingletonTraits<BrailleControllerImpl>;
83 84
84 DISALLOW_COPY_AND_ASSIGN(BrailleControllerImpl); 85 DISALLOW_COPY_AND_ASSIGN(BrailleControllerImpl);
85 }; 86 };
86 87
87 } // namespace braille_display_private 88 } // namespace braille_display_private
88 } // namespace api 89 } // namespace api
89 } // namespace extensions 90 } // namespace extensions
90 91
91 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROL LER_BRLAPI_H_ 92 #endif // CHROME_BROWSER_EXTENSIONS_API_BRAILLE_DISPLAY_PRIVATE_BRAILLE_CONTROL LER_BRLAPI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698