summaryrefslogtreecommitdiffstats
path: root/cloud_print
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 15:26:24 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 15:26:24 +0000
commitf6c3493286398773f21a48840ec907d79b258b89 (patch)
tree6debd8577ccde5890253145231c732df95b43449 /cloud_print
parent66f9a0c9759b3aeb2880b0c8e2b77d6501e32679 (diff)
downloadchromium_src-f6c3493286398773f21a48840ec907d79b258b89.zip
chromium_src-f6c3493286398773f21a48840ec907d79b258b89.tar.gz
chromium_src-f6c3493286398773f21a48840ec907d79b258b89.tar.bz2
Fixed failing overinstall.
TBR=gene Review URL: https://chromiumcodereview.appspot.com/12049066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print')
-rw-r--r--cloud_print/virtual_driver/win/install/setup.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc
index 721a940..3bd88e5 100644
--- a/cloud_print/virtual_driver/win/install/setup.cc
+++ b/cloud_print/virtual_driver/win/install/setup.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <iomanip>
#include <windows.h>
-#include <setupapi.h> // Must be included after windows.h
#include <winspool.h>
+#include <setupapi.h> // Must be included after windows.h
#include "base/at_exit.h"
#include "base/command_line.h"
@@ -120,6 +121,7 @@ void SpoolerServiceCommand(const char* command) {
base::LaunchOptions options;
options.wait = true;
options.start_hidden = true;
+ LOG(INFO) << command_line.GetCommandLineString();
base::LaunchProcess(command_line, options, NULL);
}
@@ -160,7 +162,6 @@ HRESULT RegisterPortMonitor(bool install, const FilePath& install_path) {
command_line.AppendArgPath(GetSystemPath(
cloud_print::GetPortMonitorDllName()));
-
base::LaunchOptions options;
options.wait = true;
@@ -318,7 +319,7 @@ HRESULT InstallPpd(const FilePath& install_path) {
}
HRESULT UninstallPpd() {
- int tries = 10;
+ int tries = 3;
string16 driver_name = cloud_print::LoadLocalString(IDS_DRIVER_NAME);
while (!DeletePrinterDriverEx(NULL,
NULL,
@@ -480,21 +481,16 @@ void GetCurrentInstallPath(FilePath* install_path) {
*install_path = FilePath(install_path_value);
}
-HRESULT UnregisterVirtualDriver() {
+HRESULT TryUnregisterVirtualDriver() {
HRESULT result = S_OK;
result = UninstallPrinter();
if (FAILED(result)) {
- LOG(ERROR) << "Unable to uninstall Ppd.";
+ LOG(ERROR) << "Unable to delete printer.";
return result;
}
result = UninstallPpd();
if (FAILED(result)) {
- LOG(ERROR) << "Unable to remove Ppd.";
- // Put the printer back since we're not able to
- // complete the uninstallation.
- // TODO(abodenha@chromium.org) Figure out a better way to recover.
- // See http://code.google.com/p/chromium/issues/detail?id=123039
- InstallPrinter();
+ LOG(ERROR) << "Unable to remove PPD.";
return result;
}
// The second argument is ignored if the first is false.
@@ -506,6 +502,20 @@ HRESULT UnregisterVirtualDriver() {
return S_OK;
}
+HRESULT UnregisterVirtualDriver() {
+ HRESULT hr = S_FALSE;
+ for (int i = 0; i < 2; ++i) {
+ hr = TryUnregisterVirtualDriver();
+ if (SUCCEEDED(hr)) {
+ break;
+ }
+ // Restart spooler and try again.
+ SpoolerServiceCommand("stop");
+ SpoolerServiceCommand("start");
+ }
+ return hr;
+}
+
HRESULT DoLaunchUninstall(const FilePath& installer_source, bool wait) {
FilePath temp_path;
if (file_util::CreateTemporaryFile(&temp_path)) {
@@ -625,6 +635,8 @@ int WINAPI WinMain(__in HINSTANCE hInstance,
CommandLine::Init(0, NULL);
HRESULT retval = ExecuteCommands();
+ LOG(INFO) << "HRESULT=0x" << std::setbase(16) << retval;
+
// Installer is silent by default as required by Google Update.
if (CommandLine::ForCurrentProcess()->HasSwitch("verbose")) {
cloud_print::DisplayWindowsMessage(NULL, retval,