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

Side by Side Diff: remoting/host/touch_injector_win.h

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 REMOTING_HOST_TOUCH_INJECTOR_WIN_H_ 5 #ifndef REMOTING_HOST_TOUCH_INJECTOR_WIN_H_
6 #define REMOTING_HOST_TOUCH_INJECTOR_WIN_H_ 6 #define REMOTING_HOST_TOUCH_INJECTOR_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <map> 10 #include <map>
11 #include <memory>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/scoped_native_library.h" 15 #include "base/scoped_native_library.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 namespace protocol { 19 namespace protocol {
20 20
21 class TouchEvent; 21 class TouchEvent;
22 22
23 } // namespace protocol 23 } // namespace protocol
24 24
25 // This class calls InitializeTouchInjection() and InjectTouchInput() functions. 25 // This class calls InitializeTouchInjection() and InjectTouchInput() functions.
26 // The methods are virtual for mocking. 26 // The methods are virtual for mocking.
27 class TouchInjectorWinDelegate { 27 class TouchInjectorWinDelegate {
28 public: 28 public:
29 virtual ~TouchInjectorWinDelegate(); 29 virtual ~TouchInjectorWinDelegate();
30 30
31 // Determines whether Windows touch injection functions can be used. 31 // Determines whether Windows touch injection functions can be used.
32 // Returns a non-null TouchInjectorWinDelegate on success. 32 // Returns a non-null TouchInjectorWinDelegate on success.
33 static scoped_ptr<TouchInjectorWinDelegate> Create(); 33 static std::unique_ptr<TouchInjectorWinDelegate> Create();
34 34
35 // These match the functions in MSDN. 35 // These match the functions in MSDN.
36 virtual BOOL InitializeTouchInjection(UINT32 max_count, DWORD dw_mode); 36 virtual BOOL InitializeTouchInjection(UINT32 max_count, DWORD dw_mode);
37 virtual DWORD InjectTouchInput(UINT32 count, 37 virtual DWORD InjectTouchInput(UINT32 count,
38 const POINTER_TOUCH_INFO* contacts); 38 const POINTER_TOUCH_INFO* contacts);
39 39
40 protected: 40 protected:
41 // Ctor in protected scope for mocking. 41 // Ctor in protected scope for mocking.
42 // This object takes ownership of the |library|. 42 // This object takes ownership of the |library|.
43 TouchInjectorWinDelegate( 43 TouchInjectorWinDelegate(
(...skipping 24 matching lines...) Expand all
68 // Returns false if initialization of touch injection APIs fails. 68 // Returns false if initialization of touch injection APIs fails.
69 bool Init(); 69 bool Init();
70 70
71 // Deinitializes the object so that it can be reinitialized. 71 // Deinitializes the object so that it can be reinitialized.
72 void Deinitialize(); 72 void Deinitialize();
73 73
74 // Inject touch events. 74 // Inject touch events.
75 void InjectTouchEvent(const protocol::TouchEvent& event); 75 void InjectTouchEvent(const protocol::TouchEvent& event);
76 76
77 void SetInjectorDelegateForTest( 77 void SetInjectorDelegateForTest(
78 scoped_ptr<TouchInjectorWinDelegate> functions); 78 std::unique_ptr<TouchInjectorWinDelegate> functions);
79 79
80 private: 80 private:
81 // Helper methods called from InjectTouchEvent(). 81 // Helper methods called from InjectTouchEvent().
82 // These helpers adapt Chromoting touch events, which convey changes to touch 82 // These helpers adapt Chromoting touch events, which convey changes to touch
83 // points, to Windows touch descriptions, which must include descriptions for 83 // points, to Windows touch descriptions, which must include descriptions for
84 // all currently-active touch points, not just the changed ones. 84 // all currently-active touch points, not just the changed ones.
85 void AddNewTouchPoints(const protocol::TouchEvent& event); 85 void AddNewTouchPoints(const protocol::TouchEvent& event);
86 void MoveTouchPoints(const protocol::TouchEvent& event); 86 void MoveTouchPoints(const protocol::TouchEvent& event);
87 void EndTouchPoints(const protocol::TouchEvent& event); 87 void EndTouchPoints(const protocol::TouchEvent& event);
88 void CancelTouchPoints(const protocol::TouchEvent& event); 88 void CancelTouchPoints(const protocol::TouchEvent& event);
89 89
90 // Set to null if touch injection is not available from the OS. 90 // Set to null if touch injection is not available from the OS.
91 scoped_ptr<TouchInjectorWinDelegate> delegate_; 91 std::unique_ptr<TouchInjectorWinDelegate> delegate_;
92 92
93 // TODO(rkuroiwa): crbug.com/470203 93 // TODO(rkuroiwa): crbug.com/470203
94 // This is a naive implementation. Check if we can achieve 94 // This is a naive implementation. Check if we can achieve
95 // better performance by reducing the number of copies. 95 // better performance by reducing the number of copies.
96 // To reduce the number of copies, we can have a vector of 96 // To reduce the number of copies, we can have a vector of
97 // POINTER_TOUCH_INFO and a map from touch ID to index in the vector. 97 // POINTER_TOUCH_INFO and a map from touch ID to index in the vector.
98 // When removing points from the vector, just swap it with the last element 98 // When removing points from the vector, just swap it with the last element
99 // and resize the vector. 99 // and resize the vector.
100 // All the POINTER_TOUCH_INFOs are stored as "move" points. 100 // All the POINTER_TOUCH_INFOs are stored as "move" points.
101 std::map<uint32_t, POINTER_TOUCH_INFO> touches_in_contact_; 101 std::map<uint32_t, POINTER_TOUCH_INFO> touches_in_contact_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(TouchInjectorWin); 103 DISALLOW_COPY_AND_ASSIGN(TouchInjectorWin);
104 }; 104 };
105 105
106 } // namespace remoting 106 } // namespace remoting
107 107
108 #endif // REMOTING_HOST_TOUCH_INJECTOR_WIN_H_ 108 #endif // REMOTING_HOST_TOUCH_INJECTOR_WIN_H_
OLDNEW
« no previous file with comments | « remoting/host/token_validator_factory_impl_unittest.cc ('k') | remoting/host/touch_injector_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698