Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: remoting/host/security_key/security_key_ipc_constants.cc

Issue 2161013003: Changing the default path for RemoteSecurityKeyIpcServer test channels (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename
Patch Set: Fixing a potential problem where the socket name is longer than 104 chars Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/security_key/security_key_ipc_client_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "build/build_config.h"
9
10 #if defined(OS_POSIX)
11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h"
13 #include "base/logging.h"
14 #endif // defined(OS_POSIX)
9 15
10 namespace { 16 namespace {
11 base::LazyInstance<std::string> g_security_key_ipc_channel_name = 17 base::LazyInstance<std::string> g_security_key_ipc_channel_name =
12 LAZY_INSTANCE_INITIALIZER; 18 LAZY_INSTANCE_INITIALIZER;
13 19
14 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel"; 20 const char kSecurityKeyIpcChannelName[] = "security_key_ipc_channel";
15 21
16 } // namespace 22 } // namespace
17 23
18 namespace remoting { 24 namespace remoting {
19 25
20 extern const char kSecurityKeyConnectionError[] = "ssh_connection_error"; 26 const char kSecurityKeyConnectionError[] = "ssh_connection_error";
21 27
22 const std::string& GetSecurityKeyIpcChannelName() { 28 const std::string& GetSecurityKeyIpcChannelName() {
23 if (g_security_key_ipc_channel_name.Get().empty()) { 29 if (g_security_key_ipc_channel_name.Get().empty()) {
24 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName; 30 g_security_key_ipc_channel_name.Get() = kSecurityKeyIpcChannelName;
25 } 31 }
26 32
27 return g_security_key_ipc_channel_name.Get(); 33 return g_security_key_ipc_channel_name.Get();
28 } 34 }
29 35
30 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) { 36 void SetSecurityKeyIpcChannelNameForTest(const std::string& channel_name) {
31 g_security_key_ipc_channel_name.Get() = channel_name; 37 g_security_key_ipc_channel_name.Get() = channel_name;
32 } 38 }
33 39
34 std::string GetChannelNamePathPrefixForTest() { 40 std::string GetChannelNamePathPrefixForTest() {
35 std::string path_prefix; 41 std::string base_path;
36 #if defined(OS_LINUX) 42 #if defined(OS_POSIX)
37 path_prefix = "/dev/socket/"; 43 base::FilePath base_file_path;
38 std::unique_ptr<base::Environment> env(base::Environment::Create()); 44 if (base::GetTempDir(&base_file_path)) {
39 if (env->GetVar(base::env_vars::kHome, &path_prefix)) 45 base_path = base_file_path.AsEndingWithSeparator().value();
40 path_prefix += "/"; 46 } else {
41 #endif 47 LOG(ERROR) << "Failed to retrieve temporary directory.";
42 return path_prefix; 48 }
49 #endif // defined(OS_POSIX)
50 return base_path;
43 } 51 }
44 52
45 } // namespace remoting 53 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/security_key/security_key_ipc_client_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698