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

Side by Side Diff: chrome/common/service_process_util.cc

Issue 982883003: Use fixed socket name instead of SecureSocketWithKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Mar 16 00:37:12 PDT 2015 Created 5 years, 9 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 | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/common/service_process_util.h" 5 #include "chrome/common/service_process_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 if (running_version.CompareTo(service_version) > 0) { 89 if (running_version.CompareTo(service_version) > 0) {
90 return SERVICE_OLDER_VERSION_RUNNING; 90 return SERVICE_OLDER_VERSION_RUNNING;
91 } else if (service_version.CompareTo(running_version) > 0) { 91 } else if (service_version.CompareTo(running_version) > 0) {
92 return SERVICE_NEWER_VERSION_RUNNING; 92 return SERVICE_NEWER_VERSION_RUNNING;
93 } 93 }
94 return SERVICE_SAME_VERSION_RUNNING; 94 return SERVICE_SAME_VERSION_RUNNING;
95 } 95 }
96 96
97 } // namespace 97 } // namespace
98 98
99 // Return a name that is scoped to this instance of the service process. We
100 // use the hash of the user-data-dir as a scoping prefix. We can't use
101 // the user-data-dir itself as we have limits on the size of the lock names.
102 std::string GetServiceProcessScopedName(const std::string& append_str) {
103 base::FilePath user_data_dir;
104 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
105 #if defined(OS_WIN)
106 std::string user_data_dir_path = base::WideToUTF8(user_data_dir.value());
107 #elif defined(OS_POSIX)
108 std::string user_data_dir_path = user_data_dir.value();
109 #endif // defined(OS_WIN)
110 std::string hash = base::SHA1HashString(user_data_dir_path);
111 std::string hex_hash = base::HexEncode(hash.c_str(), hash.length());
112 return hex_hash + "." + append_str;
113 }
114 99
115 // Return a name that is scoped to this instance of the service process. We 100 // Return a name that is scoped to this instance of the service process. We
116 // use the user-data-dir and the version as a scoping prefix. 101 // use the user-data-dir and the version as a scoping prefix.
117 std::string GetServiceProcessScopedVersionedName( 102 std::string GetServiceProcessScopedVersionedName(
118 const std::string& append_str) { 103 const std::string& append_str) {
119 std::string versioned_str; 104 std::string versioned_str;
120 chrome::VersionInfo version_info; 105 chrome::VersionInfo version_info;
121 versioned_str.append(version_info.Version()); 106 versioned_str.append(version_info.Version());
122 versioned_str.append(append_str); 107 versioned_str.append(append_str);
123 return GetServiceProcessScopedName(versioned_str); 108 return GetServiceProcessScopedName(versioned_str);
(...skipping 17 matching lines...) Expand all
141 *version = service_data->service_process_version; 126 *version = service_data->service_process_version;
142 if (pid) 127 if (pid)
143 *pid = service_data->service_process_pid; 128 *pid = service_data->service_process_pid;
144 return true; 129 return true;
145 } 130 }
146 return false; 131 return false;
147 } 132 }
148 133
149 #endif // !OS_MACOSX 134 #endif // !OS_MACOSX
150 135
136 // Return a name that is scoped to this instance of the service process. We
137 // use the hash of the user-data-dir as a scoping prefix. We can't use
138 // the user-data-dir itself as we have limits on the size of the lock names.
139 std::string GetServiceProcessScopedName(const std::string& append_str) {
140 base::FilePath user_data_dir;
141 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
142 #if defined(OS_WIN)
143 std::string user_data_dir_path = base::WideToUTF8(user_data_dir.value());
144 #elif defined(OS_POSIX)
145 std::string user_data_dir_path = user_data_dir.value();
146 #endif // defined(OS_WIN)
147 std::string hash = base::SHA1HashString(user_data_dir_path);
148 std::string hex_hash = base::HexEncode(hash.c_str(), hash.length());
149 return hex_hash + "." + append_str;
150 }
151
151 scoped_ptr<base::CommandLine> CreateServiceProcessCommandLine() { 152 scoped_ptr<base::CommandLine> CreateServiceProcessCommandLine() {
152 base::FilePath exe_path; 153 base::FilePath exe_path;
153 PathService::Get(content::CHILD_PROCESS_EXE, &exe_path); 154 PathService::Get(content::CHILD_PROCESS_EXE, &exe_path);
154 DCHECK(!exe_path.empty()) << "Unable to get service process binary name."; 155 DCHECK(!exe_path.empty()) << "Unable to get service process binary name.";
155 scoped_ptr<base::CommandLine> command_line(new base::CommandLine(exe_path)); 156 scoped_ptr<base::CommandLine> command_line(new base::CommandLine(exe_path));
156 command_line->AppendSwitchASCII(switches::kProcessType, 157 command_line->AppendSwitchASCII(switches::kProcessType,
157 switches::kServiceProcess); 158 switches::kServiceProcess);
158 static const char* const kSwitchesToCopy[] = { 159 static const char* const kSwitchesToCopy[] = {
159 switches::kCloudPrintSetupProxy, 160 switches::kCloudPrintSetupProxy,
160 switches::kCloudPrintURL, 161 switches::kCloudPrintURL,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 shared_data->service_process_pid = base::GetCurrentProcId(); 266 shared_data->service_process_pid = base::GetCurrentProcId();
266 shared_mem_service_data_.reset(shared_mem_service_data.release()); 267 shared_mem_service_data_.reset(shared_mem_service_data.release());
267 return true; 268 return true;
268 } 269 }
269 270
270 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 271 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
271 return ::GetServiceProcessChannel(); 272 return ::GetServiceProcessChannel();
272 } 273 }
273 274
274 #endif // !OS_MACOSX 275 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698