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 // AppHostInstaller checks the presence of app_host.exe, and launches | 5 // AppHostInstaller checks the presence of app_host.exe, and launches |
6 // the installer if missing. The check must be performed on the FILE thread. | 6 // the installer if missing. The check must be performed on the FILE thread. |
7 // The installation is also launched on the FILE thread as an asynchronous | 7 // The installation is also launched on the FILE thread as an asynchronous |
8 // process. Once installation completes, QuickEnableWatcher is notified. | 8 // process. Once installation completes, QuickEnableWatcher is notified. |
9 // AppHostInstaller::FinishOnCallerThread() is called in the end, | 9 // AppHostInstaller::FinishOnCallerThread() is called in the end, |
10 // which notifies the caller via a completion callback on the original | 10 // which notifies the caller via a completion callback on the original |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DISALLOW_COPY_AND_ASSIGN(QuickEnableDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(QuickEnableDelegate); |
64 }; | 64 }; |
65 | 65 |
66 QuickEnableDelegate::QuickEnableDelegate( | 66 QuickEnableDelegate::QuickEnableDelegate( |
67 const OnAppHostInstallationCompleteCallback& callback) | 67 const OnAppHostInstallationCompleteCallback& callback) |
68 : callback_(callback) {} | 68 : callback_(callback) {} |
69 | 69 |
70 QuickEnableDelegate::~QuickEnableDelegate() {} | 70 QuickEnableDelegate::~QuickEnableDelegate() {} |
71 | 71 |
72 void QuickEnableDelegate::OnObjectSignaled(HANDLE object) { | 72 void QuickEnableDelegate::OnObjectSignaled(HANDLE object) { |
| 73 // Reset callback_ to free up references. But do it now because it's possible |
| 74 // that callback_.Run() will cause this object to be deleted. |
| 75 OnAppHostInstallationCompleteCallback callback(callback_); |
| 76 callback_.Reset(); |
| 77 |
73 int exit_code = 0; | 78 int exit_code = 0; |
74 base::TerminationStatus status( | 79 base::TerminationStatus status( |
75 base::GetTerminationStatus(object, &exit_code)); | 80 base::GetTerminationStatus(object, &exit_code)); |
76 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION) { | 81 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION) { |
77 callback_.Run(true); | 82 callback.Run(true); |
78 } else { | 83 } else { |
79 LOG(ERROR) << "App Launcher install failed, status = " << status | 84 LOG(ERROR) << "App Launcher install failed, status = " << status |
80 << ", exit code = " << exit_code; | 85 << ", exit code = " << exit_code; |
81 callback_.Run(false); | 86 callback.Run(false); |
82 } | 87 } |
83 callback_.Reset(); | 88 |
| 89 // At this point 'this' may be deleted. Don't do anything else here. |
84 } | 90 } |
85 | 91 |
86 // Reads the path to app_host.exe from the value "UninstallString" within the | 92 // Reads the path to app_host.exe from the value "UninstallString" within the |
87 // App Host's "ClientState" registry key. Returns an empty string if the path | 93 // App Host's "ClientState" registry key. Returns an empty string if the path |
88 // does not exist or cannot be read. | 94 // does not exist or cannot be read. |
89 string16 GetQuickEnableAppHostCommand(bool system_level) { | 95 string16 GetQuickEnableAppHostCommand(bool system_level) { |
90 HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 96 HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
91 string16 subkey(kGoogleRegClientsKey); | 97 string16 subkey(kGoogleRegClientsKey); |
92 subkey.append(1, L'\\').append(kBinariesAppGuid) | 98 subkey.append(1, L'\\').append(kBinariesAppGuid) |
93 .append(1, L'\\').append(kRegCommandsKey) | 99 .append(1, L'\\').append(kRegCommandsKey) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 delete this; | 216 delete this; |
211 } | 217 } |
212 return; | 218 return; |
213 } | 219 } |
214 | 220 |
215 completion_callback_.Run(success); | 221 completion_callback_.Run(success); |
216 delete this; | 222 delete this; |
217 } | 223 } |
218 | 224 |
219 } // namespace extensions | 225 } // namespace extensions |
OLD | NEW |