Commit 58189056 authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

Basic implementation of a sink interface.

Includes IDL changes and setup.

Bug: 1053729
Change-Id: Ia36e527845c17784b761d7ec8bc5b6ee27c99d83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106479Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Auto-Submit: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750867}
parent 038002d6
......@@ -85,7 +85,9 @@ HRESULT UpdaterImpl::Update(const base::char16* app_id) {
}
HRESULT UpdaterImpl::UpdateAll(IUpdaterObserver* observer) {
return E_NOTIMPL;
if (observer)
observer->OnComplete(11);
return S_OK;
}
ComServer::ComServer()
......
......@@ -132,8 +132,9 @@ void AddComInterfacesWorkItems(HKEY root,
return;
}
const base::string16 iid_reg_path = GetComIidRegistryPath();
const base::string16 typelib_reg_path = GetComTypeLibRegistryPath();
for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver)}) {
const base::string16 iid_reg_path = GetComIidRegistryPath(iid);
const base::string16 typelib_reg_path = GetComTypeLibRegistryPath(iid);
// Delete any old registrations first.
for (const auto& reg_path : {iid_reg_path, typelib_reg_path}) {
......@@ -142,18 +143,18 @@ void AddComInterfacesWorkItems(HKEY root,
}
// Registering the Ole Automation marshaler with the CLSID
// {00020424-0000-0000-C000-000000000046} as the proxy/stub for the IUpdater
// interface.
// {00020424-0000-0000-C000-000000000046} as the proxy/stub for the
// interfaces.
list->AddCreateRegKeyWorkItem(root, iid_reg_path + L"\\ProxyStubClsid32",
WorkItem::kWow64Default);
list->AddSetRegValueWorkItem(root, iid_reg_path + L"\\ProxyStubClsid32",
WorkItem::kWow64Default, L"",
L"{00020424-0000-0000-C000-000000000046}", true);
list->AddSetRegValueWorkItem(
root, iid_reg_path + L"\\ProxyStubClsid32", WorkItem::kWow64Default,
L"", L"{00020424-0000-0000-C000-000000000046}", true);
list->AddCreateRegKeyWorkItem(root, iid_reg_path + L"\\TypeLib",
WorkItem::kWow64Default);
list->AddSetRegValueWorkItem(
root, iid_reg_path + L"\\TypeLib", WorkItem::kWow64Default, L"",
base::win::String16FromGUID(__uuidof(IUpdater)), true);
list->AddSetRegValueWorkItem(root, iid_reg_path + L"\\TypeLib",
WorkItem::kWow64Default, L"",
base::win::String16FromGUID(iid), true);
// The TypeLib registration for the Ole Automation marshaler.
list->AddCreateRegKeyWorkItem(root, typelib_reg_path + L"\\1.0\\0\\win32",
......@@ -166,6 +167,7 @@ void AddComInterfacesWorkItems(HKEY root,
list->AddSetRegValueWorkItem(root, typelib_reg_path + L"\\1.0\\0\\win64",
WorkItem::kWow64Default, L"",
typelib_path.value(), true);
}
}
} // namespace
......
......@@ -59,14 +59,14 @@ base::string16 GetComServiceAppidRegistryPath() {
return base::StrCat({L"Software\\Classes\\AppID\\", GetComServiceClsid()});
}
base::string16 GetComIidRegistryPath() {
return base::StrCat({L"Software\\Classes\\Interface\\",
base::win::String16FromGUID(__uuidof(IUpdater))});
base::string16 GetComIidRegistryPath(REFIID iid) {
return base::StrCat(
{L"Software\\Classes\\Interface\\", base::win::String16FromGUID(iid)});
}
base::string16 GetComTypeLibRegistryPath() {
return base::StrCat({L"Software\\Classes\\TypeLib\\",
base::win::String16FromGUID(__uuidof(IUpdater))});
base::string16 GetComTypeLibRegistryPath(REFIID iid) {
return base::StrCat(
{L"Software\\Classes\\TypeLib\\", base::win::String16FromGUID(iid)});
}
} // namespace updater
......@@ -5,6 +5,8 @@
#ifndef CHROME_UPDATER_WIN_SETUP_SETUP_UTIL_H_
#define CHROME_UPDATER_WIN_SETUP_SETUP_UTIL_H_
#include <guiddef.h>
namespace base {
class CommandLine;
} // namespace base
......@@ -22,8 +24,8 @@ base::string16 GetComServerClsidRegistryPath();
base::string16 GetComServiceClsid();
base::string16 GetComServiceClsidRegistryPath();
base::string16 GetComServiceAppidRegistryPath();
base::string16 GetComIidRegistryPath();
base::string16 GetComTypeLibRegistryPath();
base::string16 GetComIidRegistryPath(REFIID iid);
base::string16 GetComTypeLibRegistryPath(REFIID iid);
} // namespace updater
......
......@@ -23,6 +23,7 @@
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/work_item_list.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/server/win/updater_idl.h"
#include "chrome/updater/util.h"
#include "chrome/updater/win/constants.h"
#include "chrome/updater/win/setup/setup_util.h"
......@@ -49,11 +50,12 @@ void DeleteComService() {
}
void DeleteComInterfaces(HKEY root) {
const base::string16 iid_reg_path = GetComIidRegistryPath();
const base::string16 typelib_reg_path = GetComTypeLibRegistryPath();
for (const auto& reg_path : {iid_reg_path, typelib_reg_path}) {
for (const auto iid : {__uuidof(IUpdater), __uuidof(IUpdaterObserver)}) {
for (const auto& reg_path : {GetComIidRegistryPath(iid),
GetComTypeLibRegistryPath(iid)}) {
InstallUtil::DeleteRegistryKey(root, reg_path, WorkItem::kWow64Default);
}
}
}
// Reverses the changes made by setup. This is a best effort uninstall:
......
......@@ -27,6 +27,11 @@ static constexpr base::TaskTraits kComClientTraits = {
namespace updater {
HRESULT UpdaterObserverImpl::OnComplete(int error_code) {
VLOG(2) << "UpdaterObserverImpl::OnComplete(" << error_code << ")";
return S_OK;
}
UpdateServiceOutOfProcess::UpdateServiceOutOfProcess() = default;
UpdateServiceOutOfProcess::~UpdateServiceOutOfProcess() {
......@@ -97,12 +102,17 @@ void UpdateServiceOutOfProcess::UpdateAllOnSTA(
return;
}
hr = updater->UpdateAll(NULL);
::CoAddRefServerProcess();
auto observer = Microsoft::WRL::Make<UpdaterObserverImpl>();
hr = updater->UpdateAll(observer.Get());
if (FAILED(hr)) {
VLOG(2) << "Failed to call IUpdater::UpdateAll" << std::hex << hr;
std::move(callback).Run(static_cast<Result>(hr));
return;
}
observer.Reset();
::CoReleaseServerProcess();
}
} // namespace updater
......@@ -5,12 +5,15 @@
#ifndef CHROME_UPDATER_WIN_UPDATE_SERVICE_OUT_OF_PROCESS_H_
#define CHROME_UPDATER_WIN_UPDATE_SERVICE_OUT_OF_PROCESS_H_
#include <wrl/implements.h>
#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "chrome/updater/server/win/updater_idl.h"
#include "chrome/updater/update_service.h"
namespace base {
......@@ -23,6 +26,23 @@ enum class Error;
namespace updater {
// This class implements the IUpdater interface and exposes it as a COM object.
class UpdaterObserverImpl
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IUpdaterObserver> {
public:
UpdaterObserverImpl() = default;
UpdaterObserverImpl(const UpdaterObserverImpl&) = delete;
UpdaterObserverImpl& operator=(const UpdaterObserverImpl&) = delete;
// Overrides for IUpdaterObserver.
IFACEMETHODIMP OnComplete(int error_code) override;
private:
~UpdaterObserverImpl() override = default;
};
using StateChangeCallback =
base::RepeatingCallback<void(updater::UpdateService::UpdateState)>;
......
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