OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 // Return a name that is scoped to this instance of the service process. We | 101 // Return a name that is scoped to this instance of the service process. We |
102 // use the hash of the user-data-dir as a scoping prefix. We can't use | 102 // use the hash of the user-data-dir as a scoping prefix. We can't use |
103 // the user-data-dir itself as we have limits on the size of the lock names. | 103 // the user-data-dir itself as we have limits on the size of the lock names. |
104 std::string GetServiceProcessScopedName(const std::string& append_str) { | 104 std::string GetServiceProcessScopedName(const std::string& append_str) { |
105 base::FilePath user_data_dir; | 105 base::FilePath user_data_dir; |
106 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 106 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
107 #if defined(OS_WIN) | 107 #if defined(OS_WIN) |
108 std::string user_data_dir_path = WideToUTF8(user_data_dir.value()); | 108 std::string user_data_dir_path = base::WideToUTF8(user_data_dir.value()); |
109 #elif defined(OS_POSIX) | 109 #elif defined(OS_POSIX) |
110 std::string user_data_dir_path = user_data_dir.value(); | 110 std::string user_data_dir_path = user_data_dir.value(); |
111 #endif // defined(OS_WIN) | 111 #endif // defined(OS_WIN) |
112 std::string hash = base::SHA1HashString(user_data_dir_path); | 112 std::string hash = base::SHA1HashString(user_data_dir_path); |
113 std::string hex_hash = base::HexEncode(hash.c_str(), hash.length()); | 113 std::string hex_hash = base::HexEncode(hash.c_str(), hash.length()); |
114 return hex_hash + "." + append_str; | 114 return hex_hash + "." + append_str; |
115 } | 115 } |
116 | 116 |
117 // Return a name that is scoped to this instance of the service process. We | 117 // Return a name that is scoped to this instance of the service process. We |
118 // use the user-data-dir and the version as a scoping prefix. | 118 // use the user-data-dir and the version as a scoping prefix. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 // The user data directory is the only other flag we currently want to | 258 // The user data directory is the only other flag we currently want to |
259 // possibly store. | 259 // possibly store. |
260 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 260 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
261 base::FilePath user_data_dir = | 261 base::FilePath user_data_dir = |
262 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); | 262 browser_command_line.GetSwitchValuePath(switches::kUserDataDir); |
263 if (!user_data_dir.empty()) | 263 if (!user_data_dir.empty()) |
264 autorun_command_line_->AppendSwitchPath(switches::kUserDataDir, | 264 autorun_command_line_->AppendSwitchPath(switches::kUserDataDir, |
265 user_data_dir); | 265 user_data_dir); |
266 } | 266 } |
OLD | NEW |