OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 scoped_ptr<installer::Version> service_version; | 78 scoped_ptr<installer::Version> service_version; |
79 service_version.reset( | 79 service_version.reset( |
80 installer::Version::GetVersionFromString(ASCIIToUTF16(version))); | 80 installer::Version::GetVersionFromString(ASCIIToUTF16(version))); |
81 // If the version string is invalid, treat it like an older version. | 81 // If the version string is invalid, treat it like an older version. |
82 if (!service_version.get()) | 82 if (!service_version.get()) |
83 return SERVICE_OLDER_VERSION_RUNNING; | 83 return SERVICE_OLDER_VERSION_RUNNING; |
84 | 84 |
85 // Get the version of the currently *running* instance of Chrome. | 85 // Get the version of the currently *running* instance of Chrome. |
86 chrome::VersionInfo version_info; | 86 chrome::VersionInfo version_info; |
87 if (!version_info.is_valid()) { | |
88 NOTREACHED() << "Failed to get current file version"; | |
89 // Our own version is invalid. This is an error case. Pretend that we | |
90 // are out of date. | |
91 return SERVICE_NEWER_VERSION_RUNNING; | |
92 } | |
93 scoped_ptr<installer::Version> running_version( | 87 scoped_ptr<installer::Version> running_version( |
94 installer::Version::GetVersionFromString( | 88 installer::Version::GetVersionFromString( |
95 ASCIIToUTF16(version_info.Version()))); | 89 ASCIIToUTF16(version_info.Version()))); |
96 if (!running_version.get()) { | 90 if (!running_version.get()) { |
97 NOTREACHED() << "Failed to parse version info"; | 91 NOTREACHED() << "Failed to parse version info"; |
98 // Our own version is invalid. This is an error case. Pretend that we | 92 // Our own version is invalid. This is an error case. Pretend that we |
99 // are out of date. | 93 // are out of date. |
100 return SERVICE_NEWER_VERSION_RUNNING; | 94 return SERVICE_NEWER_VERSION_RUNNING; |
101 } | 95 } |
102 | 96 |
(...skipping 23 matching lines...) Expand all Loading... |
126 scoped_name.append(append_str); | 120 scoped_name.append(append_str); |
127 return scoped_name; | 121 return scoped_name; |
128 } | 122 } |
129 | 123 |
130 // Return a name that is scoped to this instance of the service process. We | 124 // Return a name that is scoped to this instance of the service process. We |
131 // use the user-data-dir and the version as a scoping prefix. | 125 // use the user-data-dir and the version as a scoping prefix. |
132 std::string GetServiceProcessScopedVersionedName( | 126 std::string GetServiceProcessScopedVersionedName( |
133 const std::string& append_str) { | 127 const std::string& append_str) { |
134 std::string versioned_str; | 128 std::string versioned_str; |
135 chrome::VersionInfo version_info; | 129 chrome::VersionInfo version_info; |
136 DCHECK(version_info.is_valid()); | |
137 versioned_str.append(version_info.Version()); | 130 versioned_str.append(version_info.Version()); |
138 versioned_str.append(append_str); | 131 versioned_str.append(append_str); |
139 return GetServiceProcessScopedName(versioned_str); | 132 return GetServiceProcessScopedName(versioned_str); |
140 } | 133 } |
141 | 134 |
142 // Gets the name of the service process IPC channel. | 135 // Gets the name of the service process IPC channel. |
143 std::string GetServiceProcessChannelName() { | 136 std::string GetServiceProcessChannelName() { |
144 return GetServiceProcessScopedVersionedName("_service_ipc"); | 137 return GetServiceProcessScopedVersionedName("_service_ipc"); |
145 } | 138 } |
146 | 139 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ForceServiceProcessShutdown(running_version); | 187 ForceServiceProcessShutdown(running_version); |
195 break; | 188 break; |
196 case SERVICE_NOT_RUNNING: | 189 case SERVICE_NOT_RUNNING: |
197 break; | 190 break; |
198 } | 191 } |
199 return true; | 192 return true; |
200 } | 193 } |
201 | 194 |
202 bool ServiceProcessState::CreateSharedData() { | 195 bool ServiceProcessState::CreateSharedData() { |
203 chrome::VersionInfo version_info; | 196 chrome::VersionInfo version_info; |
204 if (!version_info.is_valid()) { | |
205 NOTREACHED() << "Failed to get current file version"; | |
206 return false; | |
207 } | |
208 if (version_info.Version().length() >= kMaxVersionStringLength) { | 197 if (version_info.Version().length() >= kMaxVersionStringLength) { |
209 NOTREACHED() << "Version string length is << " << | 198 NOTREACHED() << "Version string length is << " << |
210 version_info.Version().length() << "which is longer than" << | 199 version_info.Version().length() << "which is longer than" << |
211 kMaxVersionStringLength; | 200 kMaxVersionStringLength; |
212 return false; | 201 return false; |
213 } | 202 } |
214 | 203 |
215 scoped_ptr<base::SharedMemory> shared_mem_service_data; | 204 scoped_ptr<base::SharedMemory> shared_mem_service_data; |
216 shared_mem_service_data.reset(new base::SharedMemory()); | 205 shared_mem_service_data.reset(new base::SharedMemory()); |
217 if (!shared_mem_service_data.get()) | 206 if (!shared_mem_service_data.get()) |
(...skipping 16 matching lines...) Expand all Loading... |
234 shared_data->service_process_pid = base::GetCurrentProcId(); | 223 shared_data->service_process_pid = base::GetCurrentProcId(); |
235 shared_mem_service_data_.reset(shared_mem_service_data.release()); | 224 shared_mem_service_data_.reset(shared_mem_service_data.release()); |
236 return true; | 225 return true; |
237 } | 226 } |
238 | 227 |
239 | 228 |
240 std::string ServiceProcessState::GetAutoRunKey() { | 229 std::string ServiceProcessState::GetAutoRunKey() { |
241 return GetServiceProcessScopedName("_service_run"); | 230 return GetServiceProcessScopedName("_service_run"); |
242 } | 231 } |
243 | 232 |
OLD | NEW |