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/environment.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 base::LazyInstance<std::string> g_security_key_ipc_channel_name = | 11 base::LazyInstance<std::string> g_security_key_ipc_channel_name = |
12 LAZY_INSTANCE_INITIALIZER; | 12 LAZY_INSTANCE_INITIALIZER; |
13 | 13 |
14 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; | 14 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; |
15 | 15 |
16 } // namespace | 16 } // namespace |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 extern const char kSecurityKeyConnectionError[] = "ssh_connection_error"; | 20 extern const char kSecurityKeyConnectionError[] = "ssh_connection_error"; |
Lei Zhang
2016/07/19 22:07:30
Drive by: "extern" should not be used in .cc files
joedow
2016/07/19 23:04:12
Done.
| |
21 | 21 |
22 const std::string& GetSecurityKeyIpcChannelName() { | 22 const std::string& GetSecurityKeyIpcChannelName() { |
23 if (g_security_key_ipc_channel_name.Get().empty()) { | 23 if (g_security_key_ipc_channel_name.Get().empty()) { |
24 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; | 24 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; |
25 } | 25 } |
26 | 26 |
27 return g_security_key_ipc_channel_name.Get(); | 27 return g_security_key_ipc_channel_name.Get(); |
28 } | 28 } |
29 | 29 |
30 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { | 30 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { |
31 g_security_key_ipc_channel_name.Get() = channel_name; | 31 g_security_key_ipc_channel_name.Get() = channel_name; |
32 } | 32 } |
33 | 33 |
34 std::string GetChannelNamePathPrefixForTest() { | 34 std::string GetChannelNamePathPrefixForTest() { |
35 std::string path_prefix; | 35 std::string path_prefix; |
36 #if defined(OS_LINUX) | 36 #if defined(OS_POSIX) |
37 path_prefix = "/dev/socket/"; | 37 path_prefix = "/tmp/"; |
38 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 38 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
39 if (env->GetVar(base::env_vars::kHome, &path_prefix)) | 39 if (env->GetVar(base::env_vars::kTempDir, &path_prefix)) |
Lei Zhang
2016/07/19 22:07:30
Can you just call base::GetTempDir() instead?
If
Sergey Ulanov
2016/07/19 22:34:57
Looks like we have base::GetTempDir() in base/file
joedow
2016/07/19 23:04:12
Done.
joedow
2016/07/19 23:04:12
Done.
| |
40 path_prefix += "/"; | 40 path_prefix += "/"; |
41 #endif | 41 #endif |
42 return path_prefix; | 42 return path_prefix; |
43 } | 43 } |
44 | 44 |
45 } // namespace remoting | 45 } // namespace remoting |
OLD | NEW |