Unreviewed changes
11 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: remoting/host/security_key/security_key_auth_handler_posix_unittest.cc
Insertions: 2, Deletions: 2.
@@ -82,8 +82,8 @@
auto file_task_runner = base::ThreadPool::CreateSequencedTaskRunner(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT});
- auth_handler_ = base::WrapUnique(new remoting::SecurityKeyAuthHandlerPosix(
- socket_path_, file_task_runner));
+ auth_handler_ = remoting::SecurityKeyAuthHandlerPosix::CreateForTesting(
+ socket_path_, file_task_runner);
auth_handler_->SetSendMessageCallback(send_message_callback_);
EXPECT_NE(auth_handler_.get(), nullptr);
}
```
```
The name of the file: remoting/host/security_key/security_key_auth_handler_posix.cc
Insertions: 9, Deletions: 0.
@@ -116,6 +116,15 @@
GetFileTaskRunnerRef() = nullptr;
}
+// static
+std::unique_ptr<SecurityKeyAuthHandlerPosix>
+SecurityKeyAuthHandlerPosix::CreateForTesting(
+ const base::FilePath& socket_name,
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner) {
+ return base::WrapUnique(new SecurityKeyAuthHandlerPosix(
+ socket_name, std::move(file_task_runner)));
+}
+
SecurityKeyAuthHandlerPosix::SecurityKeyAuthHandlerPosix()
: socket_name_(GetSecurityKeySocketName()),
file_task_runner_(GetFileTaskRunner()),
```
```
The name of the file: remoting/host/security_key/security_key_auth_handler_posix.h
Insertions: 6, Deletions: 5.
@@ -28,7 +28,6 @@
namespace remoting {
class SecurityKeySocket;
-class SecurityKeyAuthHandlerPosixTest;
class SecurityKeyAuthHandlerPosix : public SecurityKeyAuthHandler {
public:
@@ -44,6 +43,12 @@
// Resets the lazy task runner between unit tests to prevent stale delegates.
static void ResetTaskRunnerForTesting();
+ // Creates a SecurityKeyAuthHandlerPosix instance for testing, allowing
+ // injection of a custom socket path and task runner.
+ static std::unique_ptr<SecurityKeyAuthHandlerPosix> CreateForTesting(
+ const base::FilePath& socket_name,
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner);
+
SecurityKeyAuthHandlerPosix();
SecurityKeyAuthHandlerPosix(const SecurityKeyAuthHandlerPosix&) = delete;
@@ -63,10 +68,6 @@
void SetRequestTimeoutForTest(base::TimeDelta timeout) override;
private:
- friend class SecurityKeyAuthHandler;
- friend class SecurityKeyAuthHandlerPosixTest;
-
- // Private constructor for testing to inject dependencies.
SecurityKeyAuthHandlerPosix(
const base::FilePath& socket_name,
scoped_refptr<base::SequencedTaskRunner> file_task_runner);
```
Change information
Commit message:
remoting: More refactoring for security key
The main purpose of this CL is to eliminate the need to pass
host_context_->file_task_runner() into SecurityKeyAuthHandlerPosix so
that we don't need to add new parameters to ChromotingHost and
ClientSession. MAGI imposes more changes, which make sense, so I'm
keeping them in this CL.
- Instead of passing in the file task runner,
SecurityKeyAuthHandlerPosix will create an internal one.
- Converts the global g_use_mojo_handler flag to std::atomic<bool> to
guarantee thread-safe concurrent access across UI and Network threads.
- Protects the lazy initialization of the task runner and socket name
with a static base::Lock, preventing concurrent write races during
host startup in single-process mode.
- Changes GetSecurityKeySocketName() to return base::FilePath by value
instead of by reference, eliminating post-lock-release data races.
- Modernizes unit tests to use base::test::TaskEnvironment and
base::test::RunUntil, and uses ResetTaskRunnerForTesting() to clear
the lazy task runner between tests to prevent stale delegate errors.
Bug: 517007701
Change-Id: I73614137696759c2eb67682854a7098bab4648a6
Cr-Commit-Position: refs/heads/main@{#1652083}
Files:
- M remoting/host/BUILD.gn
- M remoting/host/desktop_process_unittest.cc
- M remoting/host/desktop_session_agent.cc
- M remoting/host/remoting_me2me_host.cc
- M remoting/host/security_key/security_key_auth_handler.cc
- M remoting/host/security_key/security_key_auth_handler.h
- M remoting/host/security_key/security_key_auth_handler_posix.cc
- M remoting/host/security_key/security_key_auth_handler_posix.h
- M remoting/host/security_key/security_key_auth_handler_posix_unittest.cc
- M remoting/host/security_key/security_key_extension.cc
- M remoting/host/security_key/security_key_extension.h
- M remoting/host/security_key/security_key_extension_session.cc
- M remoting/host/security_key/security_key_extension_session.h
- M remoting/host/security_key/security_key_extension_session_unittest.cc
Change size: L
Delta: 14 files changed, 187 insertions(+), 115 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Lambros Lambrou