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_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
7 | 7 |
8 #include "remoting/host/security_key/remote_security_key_ipc_server.h" | 8 #include "remoting/host/security_key/remote_security_key_ipc_server.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
18 | 18 |
19 namespace IPC { | 19 namespace IPC { |
20 class Channel; | 20 class Channel; |
21 class Message; | 21 class Message; |
22 } // IPC | 22 } // IPC |
23 | 23 |
24 namespace remoting { | 24 namespace remoting { |
25 | 25 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Used to forward security key requests to the remote client. | 83 // Used to forward security key requests to the remote client. |
84 GnubbyAuthHandler::SendMessageCallback send_message_callback_; | 84 GnubbyAuthHandler::SendMessageCallback send_message_callback_; |
85 | 85 |
86 // Signaled when the IPC channel is closed. | 86 // Signaled when the IPC channel is closed. |
87 base::Closure channel_closed_callback_; | 87 base::Closure channel_closed_callback_; |
88 | 88 |
89 // Signaled when a security key response message is received. | 89 // Signaled when a security key response message is received. |
90 base::Closure send_response_callback_; | 90 base::Closure send_response_callback_; |
91 | 91 |
92 // Used for sending/receiving security key messages between processes. | 92 // Used for sending/receiving security key messages between processes. |
93 scoped_ptr<IPC::Channel> ipc_channel_; | 93 std::unique_ptr<IPC::Channel> ipc_channel_; |
94 | 94 |
95 // NOTE: Weak pointers must be invalidated before all other member variables. | 95 // NOTE: Weak pointers must be invalidated before all other member variables. |
96 base::WeakPtrFactory<FakeRemoteSecurityKeyIpcServer> weak_factory_; | 96 base::WeakPtrFactory<FakeRemoteSecurityKeyIpcServer> weak_factory_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServer); | 98 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServer); |
99 }; | 99 }; |
100 | 100 |
101 // Used to create FakeRemoteSecurityKeyIpcServer instances for testing. | 101 // Used to create FakeRemoteSecurityKeyIpcServer instances for testing. |
102 // Provides a method which will return a WeakPtr reference to each instance | 102 // Provides a method which will return a WeakPtr reference to each instance |
103 // this factory creates. This allows tests to inject/retrieve messages and | 103 // this factory creates. This allows tests to inject/retrieve messages and |
104 // verify the backing instance is destroyed at the appropriate time. | 104 // verify the backing instance is destroyed at the appropriate time. |
105 class FakeRemoteSecurityKeyIpcServerFactory | 105 class FakeRemoteSecurityKeyIpcServerFactory |
106 : public RemoteSecurityKeyIpcServerFactory { | 106 : public RemoteSecurityKeyIpcServerFactory { |
107 public: | 107 public: |
108 FakeRemoteSecurityKeyIpcServerFactory(); | 108 FakeRemoteSecurityKeyIpcServerFactory(); |
109 ~FakeRemoteSecurityKeyIpcServerFactory() override; | 109 ~FakeRemoteSecurityKeyIpcServerFactory() override; |
110 | 110 |
111 // RemoteSecurityKeyIpcServerFactory implementation. | 111 // RemoteSecurityKeyIpcServerFactory implementation. |
112 scoped_ptr<RemoteSecurityKeyIpcServer> Create( | 112 std::unique_ptr<RemoteSecurityKeyIpcServer> Create( |
113 int connection_id, | 113 int connection_id, |
114 base::TimeDelta initial_connect_timeout, | 114 base::TimeDelta initial_connect_timeout, |
115 const GnubbyAuthHandler::SendMessageCallback& message_callback, | 115 const GnubbyAuthHandler::SendMessageCallback& message_callback, |
116 const base::Closure& done_callback) override; | 116 const base::Closure& done_callback) override; |
117 | 117 |
118 // Provide a WeakPtr reference to the FakeRemoteSecurityKeyIpcServer object | 118 // Provide a WeakPtr reference to the FakeRemoteSecurityKeyIpcServer object |
119 // created for the |connection_id| IPC channel. | 119 // created for the |connection_id| IPC channel. |
120 base::WeakPtr<FakeRemoteSecurityKeyIpcServer> GetIpcServerObject( | 120 base::WeakPtr<FakeRemoteSecurityKeyIpcServer> GetIpcServerObject( |
121 int connection_id); | 121 int connection_id); |
122 | 122 |
123 private: | 123 private: |
124 // Tracks each FakeRemoteSecurityKeyIpcServer instance created by this | 124 // Tracks each FakeRemoteSecurityKeyIpcServer instance created by this |
125 // factory which allows them to be retrieved and queried for tests. | 125 // factory which allows them to be retrieved and queried for tests. |
126 std::map<int, base::WeakPtr<FakeRemoteSecurityKeyIpcServer>> ipc_server_map_; | 126 std::map<int, base::WeakPtr<FakeRemoteSecurityKeyIpcServer>> ipc_server_map_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServerFactory); | 128 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcServerFactory); |
129 }; | 129 }; |
130 | 130 |
131 } // namespace remoting | 131 } // namespace remoting |
132 | 132 |
133 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ | 133 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_SERVER_H_ |
OLD | NEW |