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_SECURITY_KEY_IPC_SERVER_IMPL_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_IMPL_H_ |
6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_IMPL_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_IMPL_H_ |
7 | 7 |
8 #include "remoting/host/security_key/security_key_ipc_server.h" | 8 #include "remoting/host/security_key/security_key_ipc_server.h" |
9 | 9 |
10 #include <cstdint> | 10 #include <cstdint> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Responsible for handing the server end of the IPC channel between the | 32 // Responsible for handing the server end of the IPC channel between the |
33 // the network process and the local remote_security_key process. | 33 // the network process and the local remote_security_key process. |
34 class SecurityKeyIpcServerImpl : public SecurityKeyIpcServer, | 34 class SecurityKeyIpcServerImpl : public SecurityKeyIpcServer, |
35 public IPC::Listener { | 35 public IPC::Listener { |
36 public: | 36 public: |
37 SecurityKeyIpcServerImpl( | 37 SecurityKeyIpcServerImpl( |
38 int connection_id, | 38 int connection_id, |
39 ClientSessionDetails* client_session_details, | 39 ClientSessionDetails* client_session_details, |
40 base::TimeDelta initial_connect_timeout, | 40 base::TimeDelta initial_connect_timeout, |
41 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, | 41 const SecurityKeyAuthHandler::SendMessageCallback& message_callback, |
| 42 const base::Closure& connect_callback, |
42 const base::Closure& done_callback); | 43 const base::Closure& done_callback); |
43 ~SecurityKeyIpcServerImpl() override; | 44 ~SecurityKeyIpcServerImpl() override; |
44 | 45 |
45 // SecurityKeyIpcServer implementation. | 46 // SecurityKeyIpcServer implementation. |
46 bool CreateChannel(const std::string& channel_name, | 47 bool CreateChannel(const mojo::edk::NamedPlatformHandle& channel_handle, |
47 base::TimeDelta request_timeout) override; | 48 base::TimeDelta request_timeout) override; |
48 bool SendResponse(const std::string& message_data) override; | 49 bool SendResponse(const std::string& message_data) override; |
49 | 50 |
50 private: | 51 private: |
51 // IPC::Listener implementation. | 52 // IPC::Listener implementation. |
52 bool OnMessageReceived(const IPC::Message& message) override; | 53 bool OnMessageReceived(const IPC::Message& message) override; |
53 void OnChannelConnected(int32_t peer_pid) override; | 54 void OnChannelConnected(int32_t peer_pid) override; |
54 void OnChannelError() override; | 55 void OnChannelError() override; |
55 | 56 |
56 // Handles security key resquest IPC messages. | 57 // Handles security key resquest IPC messages. |
57 void OnSecurityKeyRequest(const std::string& request); | 58 void OnSecurityKeyRequest(const std::string& request); |
58 | 59 |
| 60 void CloseChannel(); |
| 61 |
59 // The value assigned to identify the current IPC channel. | 62 // The value assigned to identify the current IPC channel. |
60 int connection_id_; | 63 int connection_id_; |
61 | 64 |
62 // Interface which provides details about the client session. | 65 // Interface which provides details about the client session. |
63 ClientSessionDetails* client_session_details_ = nullptr; | 66 ClientSessionDetails* client_session_details_ = nullptr; |
64 | 67 |
65 // Tracks whether the connection is in the process of being closed. | 68 // Tracks whether the connection is in the process of being closed. |
66 bool connection_close_pending_ = false; | 69 bool connection_close_pending_ = false; |
67 | 70 |
68 // Timeout for disconnecting the IPC channel if there is no client activity. | 71 // Timeout for disconnecting the IPC channel if there is no client activity. |
69 base::TimeDelta initial_connect_timeout_; | 72 base::TimeDelta initial_connect_timeout_; |
70 | 73 |
71 // Timeout for disconnecting the IPC channel if there is no response from | 74 // Timeout for disconnecting the IPC channel if there is no response from |
72 // the remote client after a security key request. | 75 // the remote client after a security key request. |
73 base::TimeDelta security_key_request_timeout_; | 76 base::TimeDelta security_key_request_timeout_; |
74 | 77 |
75 // Used to detect timeouts and disconnect the IPC channel. | 78 // Used to detect timeouts and disconnect the IPC channel. |
76 base::OneShotTimer timer_; | 79 base::OneShotTimer timer_; |
77 | 80 |
| 81 // Used to signal that the IPC channel has been connected. |
| 82 base::Closure connect_callback_; |
| 83 |
78 // Used to signal that the IPC channel should be disconnected. | 84 // Used to signal that the IPC channel should be disconnected. |
79 base::Closure done_callback_; | 85 base::Closure done_callback_; |
80 | 86 |
81 // Used to pass a security key request on to the remote client. | 87 // Used to pass a security key request on to the remote client. |
82 SecurityKeyAuthHandler::SendMessageCallback message_callback_; | 88 SecurityKeyAuthHandler::SendMessageCallback message_callback_; |
83 | 89 |
84 // Used for sending/receiving security key messages between processes. | 90 // Used for sending/receiving security key messages between processes. |
85 std::unique_ptr<IPC::Channel> ipc_channel_; | 91 std::unique_ptr<IPC::Channel> ipc_channel_; |
86 | 92 |
| 93 // A token that can be used to close the underlying mojo connection. If no |
| 94 // connection exists, this is empty. |
| 95 std::string mojo_peer_token_; |
| 96 |
87 // Ensures SecurityKeyIpcServerImpl methods are called on the same thread. | 97 // Ensures SecurityKeyIpcServerImpl methods are called on the same thread. |
88 base::ThreadChecker thread_checker_; | 98 base::ThreadChecker thread_checker_; |
89 | 99 |
90 base::WeakPtrFactory<SecurityKeyIpcServerImpl> weak_factory_; | 100 base::WeakPtrFactory<SecurityKeyIpcServerImpl> weak_factory_; |
91 | 101 |
92 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcServerImpl); | 102 DISALLOW_COPY_AND_ASSIGN(SecurityKeyIpcServerImpl); |
93 }; | 103 }; |
94 | 104 |
95 } // namespace remoting | 105 } // namespace remoting |
96 | 106 |
97 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_IMPL_H_ | 107 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_IPC_SERVER_IMPL_H_ |
OLD | NEW |