Commit 569aa719 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Make all update_client ref counted types RefCountedThreadSafe.

Per-project coding style: ref counted types must be thread-safe and
sequence affinity declared with sequence checkers in destructors
if needed.

The motivation for such change is that our types get aggregated in
different ways, and mixing thread-safe and non thread-safe may
result into puzzling asserts in ref-counting code when objects
get shared between sequences.

Bug: 1105922
Change-Id: Ie3b182b31765d0416ae5d6ca108782843b95528e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314677Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791248}
parent c180769f
......@@ -8,7 +8,6 @@
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
namespace update_client {
......@@ -17,9 +16,11 @@ namespace update_client {
// Each invocation of the update client API results in a task being created and
// run. In most cases, a task corresponds to a set of CRXs, which are updated
// together.
class Task : public base::RefCounted<Task> {
class Task : public base::RefCountedThreadSafe<Task> {
public:
Task() = default;
Task(const Task&) = delete;
Task& operator=(const Task&) = delete;
virtual void Run() = 0;
// Does a best effort attempt to make a task release its resources and stop
......@@ -31,11 +32,8 @@ class Task : public base::RefCounted<Task> {
virtual std::vector<std::string> GetIds() const = 0;
protected:
friend class base::RefCounted<Task>;
friend class base::RefCountedThreadSafe<Task>;
virtual ~Task() = default;
private:
DISALLOW_COPY_AND_ASSIGN(Task);
};
} // namespace update_client
......
......@@ -323,7 +323,7 @@ using Callback = base::OnceCallback<void(Error error)>;
// instance of this class is created, the reference to it must be released
// only after the thread pools of the browser process have been destroyed and
// the browser process has gone single-threaded.
class UpdateClient : public base::RefCounted<UpdateClient> {
class UpdateClient : public base::RefCountedThreadSafe<UpdateClient> {
public:
using CrxDataCallback =
base::OnceCallback<std::vector<base::Optional<CrxComponent>>(
......@@ -452,7 +452,7 @@ class UpdateClient : public base::RefCounted<UpdateClient> {
virtual void Stop() = 0;
protected:
friend class base::RefCounted<UpdateClient>;
friend class base::RefCountedThreadSafe<UpdateClient>;
virtual ~UpdateClient() = default;
};
......
......@@ -96,12 +96,12 @@ class MockActionHandler : public ActionHandler {
};
class MockCrxStateChangeReceiver
: public base::RefCounted<MockCrxStateChangeReceiver> {
: public base::RefCountedThreadSafe<MockCrxStateChangeReceiver> {
public:
MOCK_METHOD(void, Receive, (CrxUpdateItem));
private:
friend class base::RefCounted<MockCrxStateChangeReceiver>;
friend class base::RefCountedThreadSafe<MockCrxStateChangeReceiver>;
~MockCrxStateChangeReceiver() = default;
};
......
......@@ -37,7 +37,7 @@ struct UpdateContext;
// Handles updates for a group of components. Updates for different groups
// are run concurrently but within the same group of components, updates are
// applied one at a time.
class UpdateEngine : public base::RefCounted<UpdateEngine> {
class UpdateEngine : public base::RefCountedThreadSafe<UpdateEngine> {
public:
using Callback = base::OnceCallback<void(Error error)>;
using NotifyObserversCallback =
......@@ -70,7 +70,7 @@ class UpdateEngine : public base::RefCounted<UpdateEngine> {
Callback update_callback);
private:
friend class base::RefCounted<UpdateEngine>;
friend class base::RefCountedThreadSafe<UpdateEngine>;
~UpdateEngine();
using UpdateContexts = std::map<std::string, scoped_refptr<UpdateContext>>;
......@@ -120,7 +120,7 @@ class UpdateEngine : public base::RefCounted<UpdateEngine> {
};
// Describes a group of components which are installed or updated together.
struct UpdateContext : public base::RefCounted<UpdateContext> {
struct UpdateContext : public base::RefCountedThreadSafe<UpdateContext> {
UpdateContext(
scoped_refptr<Configurator> config,
bool is_foreground,
......@@ -201,7 +201,7 @@ struct UpdateContext : public base::RefCounted<UpdateContext> {
PersistedData* persisted_data = nullptr;
private:
friend class base::RefCounted<UpdateContext>;
friend class base::RefCountedThreadSafe<UpdateContext>;
~UpdateContext();
};
......
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