Commit 178e94c0 authored by Brian Manthos's avatar Brian Manthos Committed by Commit Bot

Remove unused SelfRegWorkItem class

Change-Id: I20f5b9b18345272e435b478f7688a0e0bf10694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210540Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: Brian Manthos <brianman@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#770949}
parent 26efb30f
......@@ -118,9 +118,6 @@ class MockWorkItemList : public WorkItemList {
const std::wstring&,
DWORD,
bool));
MOCK_METHOD3(AddSelfRegWorkItem, WorkItem* (const std::wstring&,
bool,
bool));
};
class MockProductState : public ProductState {
......
......@@ -174,8 +174,6 @@ static_library("with_no_strings") {
"move_tree_work_item.h",
"registry_key_backup.cc",
"registry_key_backup.h",
"self_reg_work_item.cc",
"self_reg_work_item.h",
"set_reg_value_work_item.cc",
"set_reg_value_work_item.h",
"work_item.cc",
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/installer/util/self_reg_work_item.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/installer/util/logging_installer.h"
// Default registration export names.
const char kDefaultRegistrationEntryPoint[] = "DllRegisterServer";
const char kDefaultUnregistrationEntryPoint[] = "DllUnregisterServer";
// User-level registration export names.
const char kUserRegistrationEntryPoint[] = "DllRegisterUserServer";
const char kUserUnregistrationEntryPoint[] = "DllUnregisterUserServer";
SelfRegWorkItem::SelfRegWorkItem(const std::wstring& dll_path,
bool do_register,
bool user_level_registration)
: dll_path_(dll_path),
do_register_(do_register),
user_level_registration_(user_level_registration) {
}
SelfRegWorkItem::~SelfRegWorkItem() {
}
// This is designed to unmux error codes that may be shoe-horned in to HRESULT
// return codes by ORing a number into the top four bits of the facility code
// Any number thus found will be returned in |error_code|. The "cleaned"
// HRESULT is then returned.
//
// This only has an effect if the customer bit is set in the HRESULT, if it is
// not set then *error_code will be unchanged and the original HRESULT is
// returned.
//
// Note that this will do the wrong thing for high-valued facility codes.
HRESULT UnMuxHRESULTErrorCode(HRESULT hr, int* error_code) {
DCHECK(error_code);
if (hr & (1 << 29)) {
*error_code = (hr & 0x07800000) >> 23;
return hr & 0xF87FFFFF;
}
return hr;
}
bool SelfRegWorkItem::RegisterDll(bool do_register) {
VLOG(1) << "COM " << (do_register ? "registration of " : "unregistration of ")
<< dll_path_;
HMODULE dll_module = ::LoadLibraryEx(dll_path_.c_str(), NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
bool success = false;
if (NULL != dll_module) {
typedef HRESULT (WINAPI* RegisterFunc)();
RegisterFunc register_server_func = NULL;
if (do_register) {
register_server_func = reinterpret_cast<RegisterFunc>(
::GetProcAddress(dll_module, user_level_registration_ ?
kUserRegistrationEntryPoint : kDefaultRegistrationEntryPoint));
} else {
register_server_func = reinterpret_cast<RegisterFunc>(
::GetProcAddress(dll_module, user_level_registration_ ?
kUserUnregistrationEntryPoint :
kDefaultUnregistrationEntryPoint));
}
if (NULL != register_server_func) {
HRESULT hr = register_server_func();
success = SUCCEEDED(hr);
if (!success) {
int error_code = 0;
HRESULT unmuxed_hr = UnMuxHRESULTErrorCode(hr, &error_code);
LOG(ERROR) << "Failed to " << (do_register ? "register" : "unregister")
<< " DLL at " << dll_path_.c_str()
<< ", hr=" << base::StringPrintf(" 0x%08lX", unmuxed_hr)
<< ", code=" << error_code;
}
} else {
LOG(ERROR) << "COM registration export function not found";
}
::FreeLibrary(dll_module);
} else {
PLOG(WARNING) << "Failed to load: " << dll_path_;
}
return success;
}
bool SelfRegWorkItem::DoImpl() {
return RegisterDll(do_register_);
}
void SelfRegWorkItem::RollbackImpl() {
RegisterDll(!do_register_);
}
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
#define CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
#include <windows.h>
#include <string>
#include "chrome/installer/util/work_item.h"
// Registers or unregisters the DLL at the given path.
class SelfRegWorkItem : public WorkItem {
public:
~SelfRegWorkItem() override;
private:
friend class WorkItem;
// Constructs a work item that will call upon a self-registering DLL to
// register itself.
// dll_path: The path to the DLL.
// do_register: Whether this action is to register or unregister the DLL.
// user_level_registration: If true, then the exports called
// "DllRegisterUserServer" and "DllUnregisterUserServer" will be called to
// register and unregister the DLL. If false, the default exports named
// "DllRegisterServer" and "DllUnregisterUserServer" will be used.
SelfRegWorkItem(const std::wstring& dll_path, bool do_register,
bool user_level_registration);
// WorkItem:
bool DoImpl() override;
void RollbackImpl() override;
// Examines the DLL at dll_path looking for either DllRegisterServer (if
// do_register is true) or DllUnregisterServer (if do_register is false).
// Returns true if the DLL exports the function and it a call to it
// succeeds, false otherwise.
bool RegisterDll(bool do_register);
// The path to the dll to be registered.
std::wstring dll_path_;
// Whether this work item will register or unregister the dll. The rollback
// action just inverts this parameter.
bool do_register_;
// Whether to use alternate export names on the DLL that will perform
// user level registration.
bool user_level_registration_;
};
#endif // CHROME_INSTALLER_UTIL_SELF_REG_WORK_ITEM_H__
......@@ -16,7 +16,6 @@
#include "chrome/installer/util/delete_reg_value_work_item.h"
#include "chrome/installer/util/delete_tree_work_item.h"
#include "chrome/installer/util/move_tree_work_item.h"
#include "chrome/installer/util/self_reg_work_item.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/work_item_list.h"
......@@ -139,12 +138,6 @@ SetRegValueWorkItem* WorkItem::CreateSetRegValueWorkItem(
value_name, std::move(get_value_callback));
}
SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path,
bool do_register,
bool user_level_registration) {
return new SelfRegWorkItem(dll_path, do_register, user_level_registration);
}
WorkItemList* WorkItem::CreateWorkItemList() {
return new WorkItemList();
}
......
......@@ -25,7 +25,6 @@ class DeleteTreeWorkItem;
class DeleteRegKeyWorkItem;
class DeleteRegValueWorkItem;
class MoveTreeWorkItem;
class SelfRegWorkItem;
class SetRegValueWorkItem;
class WorkItemList;
......@@ -189,12 +188,6 @@ class WorkItem {
const std::wstring& value_name,
GetValueFromExistingCallback get_value_callback);
// Add a SelfRegWorkItem that registers or unregisters a DLL at the
// specified path.
static SelfRegWorkItem* CreateSelfRegWorkItem(const std::wstring& dll_path,
bool do_register,
bool user_level_registration);
// Create an empty WorkItemList. A WorkItemList can recursively contains
// a list of WorkItems.
static WorkItemList* CreateWorkItemList();
......
......@@ -15,7 +15,6 @@
#include "chrome/installer/util/delete_tree_work_item.h"
#include "chrome/installer/util/logging_installer.h"
#include "chrome/installer/util/move_tree_work_item.h"
#include "chrome/installer/util/self_reg_work_item.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
WorkItemList::~WorkItemList() {
......@@ -211,12 +210,3 @@ WorkItem* WorkItemList::AddSetRegValueWorkItem(
AddWorkItem(item);
return item;
}
WorkItem* WorkItemList::AddSelfRegWorkItem(const std::wstring& dll_path,
bool do_register,
bool user_level_registration) {
WorkItem* item = WorkItem::CreateSelfRegWorkItem(dll_path, do_register,
user_level_registration);
AddWorkItem(item);
return item;
}
......@@ -121,13 +121,6 @@ class WorkItemList : public WorkItem {
const std::wstring& value_name,
WorkItem::GetValueFromExistingCallback get_value_callback);
// Add a SelfRegWorkItem that registers or unregisters a DLL at the
// specified path. If user_level_registration is true, then alternate
// registration and unregistration entry point names will be used.
virtual WorkItem* AddSelfRegWorkItem(const std::wstring& dll_path,
bool do_register,
bool user_level_registration);
protected:
friend class WorkItem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment