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_IPC_SERVER_IMPL_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_IPC_SERVER_IMPL_H_ |
| 7 |
| 8 #include "remoting/host/security_key/remote_security_key_ipc_server.h" |
| 9 |
| 10 #include <cstdint> |
| 11 #include <memory> |
| 12 #include <string> |
| 13 |
| 14 #include "base/callback.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" |
| 17 #include "base/time/time.h" |
| 18 #include "base/timer/timer.h" |
| 19 #include "ipc/ipc_listener.h" |
| 20 |
| 21 namespace base { |
| 22 class TimeDelta; |
| 23 } // base |
| 24 |
| 25 namespace IPC { |
| 26 class Channel; |
| 27 class Message; |
| 28 } // IPC |
| 29 |
| 30 namespace remoting { |
| 31 |
| 32 // Responsible for handing the server end of the IPC channel between the |
| 33 // the network process and the local remote_security_key process. |
| 34 class RemoteSecurityKeyIpcServerImpl : public RemoteSecurityKeyIpcServer, |
| 35 public IPC::Listener { |
| 36 public: |
| 37 RemoteSecurityKeyIpcServerImpl( |
| 38 int connection_id, |
| 39 uint32_t peer_session_id, |
| 40 base::TimeDelta initial_connect_timeout, |
| 41 const GnubbyAuthHandler::SendMessageCallback& message_callback, |
| 42 const base::Closure& done_callback); |
| 43 ~RemoteSecurityKeyIpcServerImpl() override; |
| 44 |
| 45 // RemoteSecurityKeyIpcServer implementation. |
| 46 bool CreateChannel(const std::string& channel_name, |
| 47 base::TimeDelta request_timeout) override; |
| 48 bool SendResponse(const std::string& message_data) override; |
| 49 |
| 50 private: |
| 51 // IPC::Listener implementation. |
| 52 bool OnMessageReceived(const IPC::Message& message) override; |
| 53 void OnChannelConnected(int32_t peer_pid) override; |
| 54 void OnChannelError() override; |
| 55 |
| 56 // Handles security key resquest IPC messages. |
| 57 void OnSecurityKeyRequest(const std::string& request); |
| 58 |
| 59 // The value assigned to identify the current IPC channel. |
| 60 int connection_id_; |
| 61 |
| 62 // The expected session id of the process connecting to the IPC channel. |
| 63 uint32_t peer_session_id_; |
| 64 |
| 65 // Tracks whether the connection is in the process of being closed. |
| 66 bool connection_close_pending_ = false; |
| 67 |
| 68 // Timeout for disconnecting the IPC channel if there is no client activity. |
| 69 base::TimeDelta initial_connect_timeout_; |
| 70 |
| 71 // Timeout for disconnecting the IPC channel if there is no response from |
| 72 // the remote client after a security key request. |
| 73 base::TimeDelta security_key_request_timeout_; |
| 74 |
| 75 // Used to detect timeouts and disconnect the IPC channel. |
| 76 base::OneShotTimer timer_; |
| 77 |
| 78 // Used to signal that the IPC channel should be disconnected. |
| 79 base::Closure done_callback_; |
| 80 |
| 81 // Used to pass a security key request on to the remote client. |
| 82 GnubbyAuthHandler::SendMessageCallback message_callback_; |
| 83 |
| 84 // Used for sending/receiving security key messages between processes. |
| 85 std::unique_ptr<IPC::Channel> ipc_channel_; |
| 86 |
| 87 // Ensures RemoteSecurityKeyIpcServerImpl methods are called on the same |
| 88 // thread. |
| 89 base::ThreadChecker thread_checker_; |
| 90 |
| 91 base::WeakPtrFactory<RemoteSecurityKeyIpcServerImpl> weak_factory_; |
| 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyIpcServerImpl); |
| 94 }; |
| 95 |
| 96 } // namespace remoting |
| 97 |
| 98 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_IPC_SERVER_IMPL_H_ |
OLD | NEW |