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 "chrome/common/service_process_util_posix.h" | 5 #include "chrome/common/service_process_util_posix.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <launch.h> | 8 #include <launch.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 base::FileDescriptor fd(socket, false); | 198 base::FileDescriptor fd(socket, false); |
199 return IPC::ChannelHandle(std::string(), fd); | 199 return IPC::ChannelHandle(std::string(), fd); |
200 } | 200 } |
201 | 201 |
202 bool CheckServiceProcessReady() { | 202 bool CheckServiceProcessReady() { |
203 std::string version; | 203 std::string version; |
204 pid_t pid; | 204 pid_t pid; |
205 if (!GetServiceProcessData(&version, &pid)) { | 205 if (!GetServiceProcessData(&version, &pid)) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 scoped_ptr<Version> service_version(Version::GetVersionFromString(version)); | 208 Version service_version(version); |
209 bool ready = true; | 209 bool ready = true; |
210 if (!service_version.get()) { | 210 if (!service_version.IsValid()) { |
211 ready = false; | 211 ready = false; |
212 } else { | 212 } else { |
213 chrome::VersionInfo version_info; | 213 chrome::VersionInfo version_info; |
214 if (!version_info.is_valid()) { | 214 if (!version_info.is_valid()) { |
215 // Our own version is invalid. This is an error case. Pretend that we | 215 // Our own version is invalid. This is an error case. Pretend that we |
216 // are out of date. | 216 // are out of date. |
217 NOTREACHED() << "Failed to get current file version"; | 217 NOTREACHED(); |
218 ready = true; | 218 ready = true; |
219 } | 219 } |
220 else { | 220 else { |
221 scoped_ptr<Version> running_version(Version::GetVersionFromString( | 221 Version running_version(version_info.Version()); |
222 version_info.Version())); | 222 if (!running_version.IsValid()) { |
223 if (!running_version.get()) { | |
224 // Our own version is invalid. This is an error case. Pretend that we | 223 // Our own version is invalid. This is an error case. Pretend that we |
225 // are out of date. | 224 // are out of date. |
226 NOTREACHED() << "Failed to parse version info"; | 225 NOTREACHED(); |
227 ready = true; | 226 ready = true; |
228 } else if (running_version->CompareTo(*service_version) > 0) { | 227 } else if (running_version.CompareTo(service_version) > 0) { |
229 ready = false; | 228 ready = false; |
230 } else { | 229 } else { |
231 ready = true; | 230 ready = true; |
232 } | 231 } |
233 } | 232 } |
234 } | 233 } |
235 if (!ready) { | 234 if (!ready) { |
236 ForceServiceProcessShutdown(version, pid); | 235 ForceServiceProcessShutdown(version, pid); |
237 } | 236 } |
238 return ready; | 237 return ready; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 CFErrorRef err = NULL; | 436 CFErrorRef err = NULL; |
438 if (!Launchd::GetInstance()->RemoveJob(label, &err)) { | 437 if (!Launchd::GetInstance()->RemoveJob(label, &err)) { |
439 base::mac::ScopedCFTypeRef<CFErrorRef> scoped_err(err); | 438 base::mac::ScopedCFTypeRef<CFErrorRef> scoped_err(err); |
440 DLOG(ERROR) << "RemoveJob " << err; | 439 DLOG(ERROR) << "RemoveJob " << err; |
441 // Exiting with zero, so launchd doesn't restart the process. | 440 // Exiting with zero, so launchd doesn't restart the process. |
442 exit(0); | 441 exit(0); |
443 } | 442 } |
444 } | 443 } |
445 } | 444 } |
446 } | 445 } |
OLD | NEW |