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