Commit 9e8ae3e7 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Fix the threading for Windows on-demand server in the updater.

The COM objects participating in the on-demand transactions on the
server side are free threaded. That means that they can be entered
by any COM RPC threads when calls  on their interfaces are made by
the on-demand client on Chrome.

These objects can also be entered by the thread pool threads of
the updater, when callbacks from the update service are posted.

This CL introduces a sequential task runner to `move` the callbacks
which occur in the main sequence onto a new sequence, which can block on
base synchronization primitives. Then, it introduces a lock to
serialize access to the free threaded COM objects.

BUG:1074027

Change-Id: Icc8f579aebf943e5d43965f6f7d2a63e664bf0bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2161347
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Reviewed-by: default avatarS. Ganesh <ganesh@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762461}
parent b2b575fa
This diff is collapsed.
......@@ -8,11 +8,19 @@
#include <wrl/implements.h>
#include <wrl/module.h>
#include <string>
#include "base/memory/scoped_refptr.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "chrome/updater/server/win/updater_idl.h"
#include "chrome/updater/update_service.h"
namespace base {
class SequencedTaskRunner;
} // namespace base
namespace updater {
// TODO(crbug.com/1065712): these Impl classes don't have to be
......@@ -31,7 +39,7 @@ class LegacyOnDemandImpl
ICurrentState,
IDispatch> {
public:
LegacyOnDemandImpl() = default;
LegacyOnDemandImpl();
LegacyOnDemandImpl(const LegacyOnDemandImpl&) = delete;
LegacyOnDemandImpl& operator=(const LegacyOnDemandImpl&) = delete;
......@@ -110,14 +118,34 @@ class LegacyOnDemandImpl
UINT*) override;
private:
~LegacyOnDemandImpl() override;
void UpdateStateCallback(UpdateService::UpdateState state_update);
void UpdateResultCallback(UpdateService::Result result);
// Returns the state of the update and the error code as seen by the
// on-demand client.
CurrentState GetOnDemandCurrentState() const;
HRESULT GetOnDemandError() const;
// Handles the update service callbacks.
scoped_refptr<base::SequencedTaskRunner> task_runner_;
// Synchronized accessors.
std::string app_id() const {
base::AutoLock lock{lock_};
return app_id_;
}
void set_app_id(const std::string& app_id) {
base::AutoLock lock{lock_};
app_id_ = app_id;
}
// Access to these members must be serialized by using the lock.
mutable base::Lock lock_;
std::string app_id_;
int state_value_ = STATE_INIT;
HRESULT error_code_ = S_OK;
~LegacyOnDemandImpl() override = default;
base::Optional<UpdateService::UpdateState> state_update_;
base::Optional<UpdateService::Result> result_;
};
// This class implements the ICompleteStatus interface and exposes it as a COM
......@@ -137,10 +165,10 @@ class CompleteStatusImpl
IFACEMETHODIMP get_statusMessage(BSTR* message) override;
private:
~CompleteStatusImpl() override = default;
const int code_;
const base::string16 message_;
~CompleteStatusImpl() override = default;
};
// This class implements the IUpdater interface and exposes it as a COM object.
......
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