| 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 #include "remoting/host/security_key/security_key_ipc_constants.h" | 5 #include "remoting/host/security_key/security_key_ipc_constants.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #endif // defined(OS_POSIX) | 14 #endif // defined(OS_POSIX) |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 base::LazyInstance<std::string> g_security_key_ipc_channel_name = | 17 base::LazyInstance<mojo::edk::NamedPlatformHandle> |
| 18 LAZY_INSTANCE_INITIALIZER; | 18 g_security_key_ipc_channel_name = LAZY_INSTANCE_INITIALIZER; |
| 19 | 19 |
| 20 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; | 20 constexpr char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 namespace remoting { | 24 namespace remoting { |
| 25 | 25 |
| 26 const char kSecurityKeyConnectionError[] = "ssh_connection_error"; | 26 const char kSecurityKeyConnectionError[] = "ssh_connection_error"; |
| 27 | 27 |
| 28 const std::string& GetSecurityKeyIpcChannelName() { | 28 const mojo::edk::NamedPlatformHandle& GetSecurityKeyIpcChannel() { |
| 29 if (g_security_key_ipc_channel_name.Get().empty()) { | 29 if (!g_security_key_ipc_channel_name.Get().is_valid()) { |
| 30 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; | 30 g_security_key_ipc_channel_name.Get() = |
| 31 mojo::edk::NamedPlatformHandle(kSecurityKeyIpcChannelName); |
| 31 } | 32 } |
| 32 | 33 |
| 33 return g_security_key_ipc_channel_name.Get(); | 34 return g_security_key_ipc_channel_name.Get(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { | 37 void SetSecurityKeyIpcChannelForTest( |
| 37 g_security_key_ipc_channel_name.Get() = channel_name; | 38 const mojo::edk::NamedPlatformHandle& channel_handle) { |
| 39 g_security_key_ipc_channel_name.Get() = channel_handle; |
| 38 } | 40 } |
| 39 | 41 |
| 40 std::string GetChannelNamePathPrefixForTest() { | 42 std::string GetChannelNamePathPrefixForTest() { |
| 41 std::string base_path; | 43 std::string base_path; |
| 42 #if defined(OS_POSIX) | 44 #if defined(OS_POSIX) |
| 43 base::FilePath base_file_path; | 45 base::FilePath base_file_path; |
| 44 if (base::GetTempDir(&base_file_path)) { | 46 if (base::GetTempDir(&base_file_path)) { |
| 45 base_path = base_file_path.AsEndingWithSeparator().value(); | 47 base_path = base_file_path.AsEndingWithSeparator().value(); |
| 46 } else { | 48 } else { |
| 47 LOG(ERROR) << "Failed to retrieve temporary directory."; | 49 LOG(ERROR) << "Failed to retrieve temporary directory."; |
| 48 } | 50 } |
| 49 #endif // defined(OS_POSIX) | 51 #endif // defined(OS_POSIX) |
| 50 return base_path; | 52 return base_path; |
| 51 } | 53 } |
| 52 | 54 |
| 53 } // namespace remoting | 55 } // namespace remoting |
| OLD | NEW |