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

Hook up Legacy OnDemand with the Update Service.

Omaha 4 now works with the UpdateService to service an on-demand update
request.

Bug: 1067348
Change-Id: Ia85ae0a245664f3c7383addee174b2d6849f4868
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136276Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756504}
parent 8807861e
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#include "chrome/updater/configurator.h" #include "chrome/updater/configurator.h"
#include "chrome/updater/update_service.h" #include "chrome/updater/update_service.h"
#include "chrome/updater/update_service_in_process.h" #include "chrome/updater/update_service_in_process.h"
#include "components/update_client/update_client_errors.h"
namespace updater { namespace updater {
namespace { namespace {
...@@ -230,6 +232,8 @@ STDMETHODIMP LegacyOnDemandImpl::createApp(BSTR app_id, ...@@ -230,6 +232,8 @@ STDMETHODIMP LegacyOnDemandImpl::createApp(BSTR app_id,
return E_NOTIMPL; return E_NOTIMPL;
} }
STDMETHODIMP LegacyOnDemandImpl::createInstalledApp(BSTR app_id) { STDMETHODIMP LegacyOnDemandImpl::createInstalledApp(BSTR app_id) {
app_id_ = base::UTF16ToASCII(app_id);
return S_OK; return S_OK;
} }
STDMETHODIMP LegacyOnDemandImpl::createAllInstalledApps() { STDMETHODIMP LegacyOnDemandImpl::createAllInstalledApps() {
...@@ -258,7 +262,66 @@ STDMETHODIMP LegacyOnDemandImpl::get_appWeb(int index, IDispatch** app_web) { ...@@ -258,7 +262,66 @@ STDMETHODIMP LegacyOnDemandImpl::get_appWeb(int index, IDispatch** app_web) {
STDMETHODIMP LegacyOnDemandImpl::initialize() { STDMETHODIMP LegacyOnDemandImpl::initialize() {
return S_OK; return S_OK;
} }
void LegacyOnDemandImpl::UpdateStateCallback(
UpdateService::UpdateState state_update) {
switch (state_update) {
case UpdateService::UpdateState::kNotStarted:
state_value_ = STATE_INIT;
break;
case UpdateService::UpdateState::kCheckingForUpdates:
state_value_ = STATE_CHECKING_FOR_UPDATE;
break;
case UpdateService::UpdateState::kDownloading:
state_value_ = STATE_DOWNLOADING;
break;
case UpdateService::UpdateState::kInstalling:
state_value_ = STATE_INSTALLING;
break;
case UpdateService::UpdateState::kUpdated:
state_value_ = STATE_INSTALL_COMPLETE;
break;
case UpdateService::UpdateState::kNoUpdate:
state_value_ = STATE_NO_UPDATE;
break;
case UpdateService::UpdateState::kUpdateError:
state_value_ = STATE_ERROR;
break;
default:
break;
}
}
void LegacyOnDemandImpl::UpdateResultCallback(UpdateService::Result result) {
if (result == update_client::Error::NONE) {
state_value_ = STATE_INSTALL_COMPLETE;
error_code_ = S_OK;
} else {
state_value_ = STATE_ERROR;
error_code_ = E_FAIL;
}
}
STDMETHODIMP LegacyOnDemandImpl::checkForUpdate() { STDMETHODIMP LegacyOnDemandImpl::checkForUpdate() {
using LegacyOnDemandImplPtr = Microsoft::WRL::ComPtr<LegacyOnDemandImpl>;
// Invoke the in-process |update_service| on the main sequence.
auto com_server = ComServer::Instance();
com_server->main_task_runner()->PostTask(
FROM_HERE,
base::BindOnce(
[](scoped_refptr<UpdateService> update_service,
LegacyOnDemandImplPtr legacy_on_demand_impl) {
update_service->Update(
legacy_on_demand_impl->app_id_,
UpdateService::Priority::kForeground,
base::BindRepeating(&LegacyOnDemandImpl::UpdateStateCallback,
legacy_on_demand_impl),
base::BindOnce(&LegacyOnDemandImpl::UpdateResultCallback,
legacy_on_demand_impl));
},
com_server->service(), LegacyOnDemandImplPtr(this)));
return S_OK; return S_OK;
} }
STDMETHODIMP LegacyOnDemandImpl::download() { STDMETHODIMP LegacyOnDemandImpl::download() {
...@@ -321,7 +384,7 @@ STDMETHODIMP LegacyOnDemandImpl::put_serverInstallDataIndex(BSTR language) { ...@@ -321,7 +384,7 @@ STDMETHODIMP LegacyOnDemandImpl::put_serverInstallDataIndex(BSTR language) {
STDMETHODIMP LegacyOnDemandImpl::get_stateValue(LONG* state_value) { STDMETHODIMP LegacyOnDemandImpl::get_stateValue(LONG* state_value) {
DCHECK(state_value); DCHECK(state_value);
*state_value = STATE_NO_UPDATE; *state_value = state_value_;
return S_OK; return S_OK;
} }
STDMETHODIMP LegacyOnDemandImpl::get_availableVersion(BSTR* available_version) { STDMETHODIMP LegacyOnDemandImpl::get_availableVersion(BSTR* available_version) {
...@@ -353,7 +416,9 @@ STDMETHODIMP LegacyOnDemandImpl::get_isCanceled(VARIANT_BOOL* is_canceled) { ...@@ -353,7 +416,9 @@ STDMETHODIMP LegacyOnDemandImpl::get_isCanceled(VARIANT_BOOL* is_canceled) {
return E_NOTIMPL; return E_NOTIMPL;
} }
STDMETHODIMP LegacyOnDemandImpl::get_errorCode(LONG* error_code) { STDMETHODIMP LegacyOnDemandImpl::get_errorCode(LONG* error_code) {
return E_NOTIMPL; *error_code = error_code_;
return S_OK;
} }
STDMETHODIMP LegacyOnDemandImpl::get_extraCode1(LONG* extra_code1) { STDMETHODIMP LegacyOnDemandImpl::get_extraCode1(LONG* extra_code1) {
return E_NOTIMPL; return E_NOTIMPL;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "chrome/updater/server/win/updater_idl.h" #include "chrome/updater/server/win/updater_idl.h"
#include "chrome/updater/update_service.h"
namespace updater { namespace updater {
...@@ -109,6 +110,13 @@ class LegacyOnDemandImpl ...@@ -109,6 +110,13 @@ class LegacyOnDemandImpl
UINT*) override; UINT*) override;
private: private:
void UpdateStateCallback(UpdateService::UpdateState state_update);
void UpdateResultCallback(UpdateService::Result result);
std::string app_id_;
int state_value_ = STATE_INIT;
HRESULT error_code_ = S_OK;
~LegacyOnDemandImpl() override = default; ~LegacyOnDemandImpl() override = default;
}; };
......
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