| 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/installer/util/google_update_util.h" | 5 #include "chrome/installer/util/google_update_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Launches command |cmd_string|, and waits for |timeout| milliseconds before | 88 // Launches command |cmd_string|, and waits for |timeout| milliseconds before |
| 89 // timing out. To wait indefinitely, one can set | 89 // timing out. To wait indefinitely, one can set |
| 90 // |timeout| to be base::TimeDelta::FromMilliseconds(INFINITE). | 90 // |timeout| to be base::TimeDelta::FromMilliseconds(INFINITE). |
| 91 // Returns true if this executes successfully. | 91 // Returns true if this executes successfully. |
| 92 // Returns false if command execution fails to execute, or times out. | 92 // Returns false if command execution fails to execute, or times out. |
| 93 bool LaunchProcessAndWaitWithTimeout(const string16& cmd_string, | 93 bool LaunchProcessAndWaitWithTimeout(const string16& cmd_string, |
| 94 base::TimeDelta timeout) { | 94 base::TimeDelta timeout) { |
| 95 bool success = false; | 95 bool success = false; |
| 96 base::win::ScopedHandle process; | 96 base::win::ScopedHandle process; |
| 97 int exit_code = 0; | 97 int exit_code = 0; |
| 98 VLOG(0) << "Launching: " << cmd_string; | 98 LOG(INFO) << "Launching: " << cmd_string; |
| 99 if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), | 99 if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), |
| 100 &process)) { | 100 process.Receive())) { |
| 101 PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; | 101 PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; |
| 102 } else if (!base::WaitForExitCodeWithTimeout(process, &exit_code, timeout)) { | 102 } else if (!base::WaitForExitCodeWithTimeout(process, &exit_code, timeout)) { |
| 103 // The GetExitCodeProcess failed or timed-out. | 103 // The GetExitCodeProcess failed or timed-out. |
| 104 LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than " | 104 LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than " |
| 105 << timeout.InMilliseconds() << " milliseconds to complete."; | 105 << timeout.InMilliseconds() << " milliseconds to complete."; |
| 106 } else if (exit_code != 0) { | 106 } else if (exit_code != 0) { |
| 107 LOG(ERROR) << "Command (" << cmd_string << ") exited with code " | 107 LOG(ERROR) << "Command (" << cmd_string << ") exited with code " |
| 108 << exit_code; | 108 << exit_code; |
| 109 } else { | 109 } else { |
| 110 success = true; | 110 success = true; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 (*untrusted_data)[key] = value; | 167 (*untrusted_data)[key] = value; |
| 168 else | 168 else |
| 169 LOG(ERROR) << "Illegal character found in untrusted data."; | 169 LOG(ERROR) << "Illegal character found in untrusted data."; |
| 170 } | 170 } |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace | 174 } // namespace |
| 175 | 175 |
| 176 bool EnsureUserLevelGoogleUpdatePresent() { | 176 bool EnsureUserLevelGoogleUpdatePresent() { |
| 177 VLOG(0) << "Ensuring Google Update is present at user-level."; | 177 LOG(INFO) << "Ensuring Google Update is present at user-level."; |
| 178 | 178 |
| 179 bool success = false; | 179 bool success = false; |
| 180 if (IsGoogleUpdatePresent(false)) { | 180 if (IsGoogleUpdatePresent(false)) { |
| 181 success = true; | 181 success = true; |
| 182 } else { | 182 } else { |
| 183 string16 cmd_string; | 183 string16 cmd_string; |
| 184 if (!GetUserLevelGoogleUpdateInstallCommandLine(&cmd_string)) { | 184 if (!GetUserLevelGoogleUpdateInstallCommandLine(&cmd_string)) { |
| 185 LOG(ERROR) << "Cannot find Google Update at system-level."; | 185 LOG(ERROR) << "Cannot find Google Update at system-level."; |
| 186 // Ideally we should return false. However, this case should not be | 186 // Ideally we should return false. However, this case should not be |
| 187 // encountered by regular users, and developers (who often installs | 187 // encountered by regular users, and developers (who often installs |
| (...skipping 27 matching lines...) Expand all Loading... |
| 215 std::map<std::string, std::string>::const_iterator data_it( | 215 std::map<std::string, std::string>::const_iterator data_it( |
| 216 untrusted_data.find(key)); | 216 untrusted_data.find(key)); |
| 217 if (data_it != untrusted_data.end()) | 217 if (data_it != untrusted_data.end()) |
| 218 return data_it->second; | 218 return data_it->second; |
| 219 } | 219 } |
| 220 | 220 |
| 221 return std::string(); | 221 return std::string(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace google_update | 224 } // namespace google_update |
| OLD | NEW |