summaryrefslogtreecommitdiffstats
path: root/cloud_print/service/win
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 08:46:46 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-09 08:46:46 +0000
commitd2a662753342934f8e97fde84045aa6e7ff2995b (patch)
tree02edab4c2cbf1753757846efa2206c3212648aac /cloud_print/service/win
parent007b3f812fc9c989fb99d4a668d8bd9c7807ad81 (diff)
downloadchromium_src-d2a662753342934f8e97fde84045aa6e7ff2995b.zip
chromium_src-d2a662753342934f8e97fde84045aa6e7ff2995b.tar.gz
chromium_src-d2a662753342934f8e97fde84045aa6e7ff2995b.tar.bz2
Common code moved to cloud_print/common/
Review URL: https://chromiumcodereview.appspot.com/13770012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cloud_print/service/win')
-rw-r--r--cloud_print/service/win/cloud_print_service.cc4
-rw-r--r--cloud_print/service/win/service_controller.cc17
2 files changed, 9 insertions, 12 deletions
diff --git a/cloud_print/service/win/cloud_print_service.cc b/cloud_print/service/win/cloud_print_service.cc
index 8f387ae..75951b2 100644
--- a/cloud_print/service/win/cloud_print_service.cc
+++ b/cloud_print/service/win/cloud_print_service.cc
@@ -19,6 +19,7 @@
#include "base/win/scoped_handle.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/service/service_state.h"
#include "cloud_print/service/service_switches.h"
#include "cloud_print/service/win/chrome_launcher.h"
@@ -334,8 +335,7 @@ class CloudPrintServiceModule
new_contents.size());
if (written != new_contents.size()) {
LOG(ERROR) << "Failed to write file " << file.value() << ".";
- DWORD last_error = GetLastError();
- return last_error ? HRESULT_FROM_WIN32(last_error) : E_FAIL;
+ return cloud_print::GetLastHResult();
}
}
}
diff --git a/cloud_print/service/win/service_controller.cc b/cloud_print/service/win/service_controller.cc
index 0db0726..c311424 100644
--- a/cloud_print/service/win/service_controller.cc
+++ b/cloud_print/service/win/service_controller.cc
@@ -13,15 +13,12 @@
#include "base/path_service.h"
#include "base/win/scoped_handle.h"
#include "chrome/common/chrome_switches.h"
+#include "cloud_print/common/win/cloud_print_utils.h"
#include "cloud_print/service/win/chrome_launcher.h"
#include "cloud_print/service/win/local_security_policy.h"
namespace {
-HRESULT HResultFromLastError() {
- return GetLastError() ? HRESULT_FROM_WIN32(GetLastError()) : E_FAIL;
-}
-
// The traits class for Windows Service.
class ServiceHandleTraits {
public:
@@ -53,7 +50,7 @@ HRESULT OpenServiceManager(ServiceHandle* service_manager) {
service_manager->Set(::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS));
if (!service_manager->IsValid())
- return HResultFromLastError();
+ return cloud_print::GetLastHResult();
return S_OK;
}
@@ -71,7 +68,7 @@ HRESULT OpenService(const string16& name, DWORD access,
service->Set(::OpenService(scm, name.c_str(), access));
if (!service->IsValid())
- return HResultFromLastError();
+ return cloud_print::GetLastHResult();
return S_OK;
}
@@ -91,7 +88,7 @@ HRESULT ServiceController::StartService() {
if (FAILED(hr))
return hr;
if (!::StartService(service, 0, NULL))
- return HResultFromLastError();
+ return cloud_print::GetLastHResult();
return S_OK;
}
@@ -103,7 +100,7 @@ HRESULT ServiceController::StopService() {
return hr;
SERVICE_STATUS status = {0};
if (!::ControlService(service, SERVICE_CONTROL_STOP, &status))
- return HResultFromLastError();
+ return cloud_print::GetLastHResult();
while (::QueryServiceStatus(service, &status) &&
status.dwCurrentState > SERVICE_STOPPED) {
Sleep(500);
@@ -164,7 +161,7 @@ HRESULT ServiceController::InstallService(const string16& user,
if (!service.IsValid()) {
LOG(ERROR) << "Failed to install service as " << user << ".";
- return HResultFromLastError();
+ return cloud_print::GetLastHResult();
}
return S_OK;
@@ -179,7 +176,7 @@ HRESULT ServiceController::UninstallService() {
if (service) {
if (!::DeleteService(service)) {
LOG(ERROR) << "Failed to uninstall service";
- hr = HResultFromLastError();
+ hr = cloud_print::GetLastHResult();
}
}
UpdateRegistryAppId(false);