Chromium Code Reviews| 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/environment.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | |
| 8 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | |
|
Lei Zhang
2016/07/19 22:55:04
It's great that you are trying to IWYU, but what i
joedow
2016/07/19 23:04:12
Done.
| |
| 9 | 11 |
| 10 namespace { | 12 namespace { |
| 11 base::LazyInstance<std::string> g_security_key_ipc_channel_name = | 13 base::LazyInstance<std::string> g_security_key_ipc_channel_name = |
| 12 LAZY_INSTANCE_INITIALIZER; | 14 LAZY_INSTANCE_INITIALIZER; |
| 13 | 15 |
| 14 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; | 16 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; |
| 15 | 17 |
| 16 } // namespace | 18 } // namespace |
| 17 | 19 |
| 18 namespace remoting { | 20 namespace remoting { |
| 19 | 21 |
| 20 extern const char kSecurityKeyConnectionError[] = "ssh_connection_error"; | 22 const char kSecurityKeyConnectionError[] = "ssh_connection_error"; |
| 21 | 23 |
| 22 const std::string& GetSecurityKeyIpcChannelName() { | 24 const std::string& GetSecurityKeyIpcChannelName() { |
| 23 if (g_security_key_ipc_channel_name.Get().empty()) { | 25 if (g_security_key_ipc_channel_name.Get().empty()) { |
| 24 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; | 26 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; |
| 25 } | 27 } |
| 26 | 28 |
| 27 return g_security_key_ipc_channel_name.Get(); | 29 return g_security_key_ipc_channel_name.Get(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { | 32 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { |
| 31 g_security_key_ipc_channel_name.Get() = channel_name; | 33 g_security_key_ipc_channel_name.Get() = channel_name; |
| 32 } | 34 } |
| 33 | 35 |
| 34 std::string GetChannelNamePathPrefixForTest() { | 36 std::string GetChannelNamePathPrefixForTest() { |
| 35 std::string path_prefix; | 37 std::string base_path; |
| 36 #if defined(OS_LINUX) | 38 #if defined(OS_POSIX) |
| 37 path_prefix = "/dev/socket/"; | 39 base::FilePath base_file_path; |
| 38 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 40 if (!base::GetTempDir(&base_file_path)) { |
| 39 if (env->GetVar(base::env_vars::kHome, &path_prefix)) | 41 LOG(ERROR) << "Failed to retrieve temporary directory."; |
| 40 path_prefix += "/"; | 42 } else { |
| 43 base_path = base_file_path.value() + "/"; | |
| 44 } | |
| 41 #endif | 45 #endif |
| 42 return path_prefix; | 46 return base_path; |
| 43 } | 47 } |
| 44 | 48 |
| 45 } // namespace remoting | 49 } // namespace remoting |
| OLD | NEW |