OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ |
6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/files/file.h" | 12 #include "base/files/file.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "remoting/host/security_key/security_key_message.h" | 15 #include "remoting/host/security_key/security_key_message.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 class RemoteSecurityKeyIpcClient; | 19 class RemoteSecurityKeyIpcClient; |
20 class RemoteSecurityKeyMessageReader; | 20 class RemoteSecurityKeyMessageReader; |
21 class RemoteSecurityKeyMessageWriter; | 21 class RemoteSecurityKeyMessageWriter; |
22 | 22 |
23 // Routes security key messages to the remote client and receives response from | 23 // Routes security key messages to the remote client and receives response from |
24 // the remote client and forwards them to the local security key tools. | 24 // the remote client and forwards them to the local security key tools. |
25 class RemoteSecurityKeyMessageHandler { | 25 class RemoteSecurityKeyMessageHandler { |
26 public: | 26 public: |
27 RemoteSecurityKeyMessageHandler(); | 27 RemoteSecurityKeyMessageHandler(); |
28 ~RemoteSecurityKeyMessageHandler(); | 28 ~RemoteSecurityKeyMessageHandler(); |
29 | 29 |
30 // Sets up the handler to begin receiving and processing messages. | 30 // Sets up the handler to begin receiving and processing messages. |
31 void Start(base::File message_read_stream, | 31 void Start(base::File message_read_stream, |
32 base::File message_write_stream, | 32 base::File message_write_stream, |
33 scoped_ptr<RemoteSecurityKeyIpcClient> ipc_client, | 33 std::unique_ptr<RemoteSecurityKeyIpcClient> ipc_client, |
34 const base::Closure& error_callback); | 34 const base::Closure& error_callback); |
35 | 35 |
36 // Sets |reader_| to the instance passed in via |reader|. This method should | 36 // Sets |reader_| to the instance passed in via |reader|. This method should |
37 // be called before Start(). | 37 // be called before Start(). |
38 void SetRemoteSecurityKeyMessageReaderForTest( | 38 void SetRemoteSecurityKeyMessageReaderForTest( |
39 scoped_ptr<RemoteSecurityKeyMessageReader> reader); | 39 std::unique_ptr<RemoteSecurityKeyMessageReader> reader); |
40 | 40 |
41 // Sets |writer_| to the instance passed in via |writer|. This method should | 41 // Sets |writer_| to the instance passed in via |writer|. This method should |
42 // be called before Start(). | 42 // be called before Start(). |
43 void SetRemoteSecurityKeyMessageWriterForTest( | 43 void SetRemoteSecurityKeyMessageWriterForTest( |
44 scoped_ptr<RemoteSecurityKeyMessageWriter> writer); | 44 std::unique_ptr<RemoteSecurityKeyMessageWriter> writer); |
45 | 45 |
46 private: | 46 private: |
47 // RemoteSecurityKeyMessage handler. | 47 // RemoteSecurityKeyMessage handler. |
48 void ProcessRemoteSecurityKeyMessage(scoped_ptr<SecurityKeyMessage> message); | 48 void ProcessRemoteSecurityKeyMessage( |
| 49 std::unique_ptr<SecurityKeyMessage> message); |
49 | 50 |
50 // Cleans up resources when an error occurs. | 51 // Cleans up resources when an error occurs. |
51 void OnError(); | 52 void OnError(); |
52 | 53 |
53 // Writes the passed in message data using |writer_|. | 54 // Writes the passed in message data using |writer_|. |
54 void SendMessage(RemoteSecurityKeyMessageType message_type); | 55 void SendMessage(RemoteSecurityKeyMessageType message_type); |
55 void SendMessageWithPayload(RemoteSecurityKeyMessageType message_type, | 56 void SendMessageWithPayload(RemoteSecurityKeyMessageType message_type, |
56 const std::string& message_payload); | 57 const std::string& message_payload); |
57 | 58 |
58 // Used to respond to IPC connection changes. | 59 // Used to respond to IPC connection changes. |
59 void HandleIpcConnectionChange(bool connection_established); | 60 void HandleIpcConnectionChange(bool connection_established); |
60 | 61 |
61 // Handles responses received from the remote client. | 62 // Handles responses received from the remote client. |
62 void HandleSecurityKeyResponse(const std::string& response_data); | 63 void HandleSecurityKeyResponse(const std::string& response_data); |
63 | 64 |
64 // Handles requests to establich a connection with the Chromoting host. | 65 // Handles requests to establich a connection with the Chromoting host. |
65 void HandleConnectRequest(const std::string& message_payload); | 66 void HandleConnectRequest(const std::string& message_payload); |
66 | 67 |
67 // handles security key requests by forwrding them to the remote client. | 68 // handles security key requests by forwrding them to the remote client. |
68 void HandleSecurityKeyRequest(const std::string& message_payload); | 69 void HandleSecurityKeyRequest(const std::string& message_payload); |
69 | 70 |
70 // Used to communicate with the remote security key. | 71 // Used to communicate with the remote security key. |
71 scoped_ptr<RemoteSecurityKeyIpcClient> ipc_client_; | 72 std::unique_ptr<RemoteSecurityKeyIpcClient> ipc_client_; |
72 | 73 |
73 // Used to listen for security key messages. | 74 // Used to listen for security key messages. |
74 scoped_ptr<RemoteSecurityKeyMessageReader> reader_; | 75 std::unique_ptr<RemoteSecurityKeyMessageReader> reader_; |
75 | 76 |
76 // Used to write security key messages to local security key tools. | 77 // Used to write security key messages to local security key tools. |
77 scoped_ptr<RemoteSecurityKeyMessageWriter> writer_; | 78 std::unique_ptr<RemoteSecurityKeyMessageWriter> writer_; |
78 | 79 |
79 // Signaled when an error occurs. | 80 // Signaled when an error occurs. |
80 base::Closure error_callback_; | 81 base::Closure error_callback_; |
81 | 82 |
82 base::ThreadChecker thread_checker_; | 83 base::ThreadChecker thread_checker_; |
83 | 84 |
84 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageHandler); | 85 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageHandler); |
85 }; | 86 }; |
86 | 87 |
87 } // namespace remoting | 88 } // namespace remoting |
88 | 89 |
89 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ | 90 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_HANDLER_H_ |
OLD | NEW |