[go: nahoru, domu]

blob: cd739dc1d7ceba94b5c17cccee228a8e78ca02f1 [file] [log] [blame]
Avi Drissman8ba1bad2022-09-13 19:22:361// Copyright 2014 The Chromium Authors
sdefresne2eb633d2014-10-08 12:31:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/keyed_service/core/refcounted_keyed_service.h"
Sean Mahere672a662023-01-09 21:42:286#include "base/task/sequenced_task_runner.h"
sdefresne2eb633d2014-10-08 12:31:567
gab28fb80be2016-12-19 20:09:288#include <utility>
sdefresne2eb633d2014-10-08 12:31:569
10namespace impl {
11
12// static
13void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) {
peary2ac764482017-06-25 14:39:5314 if (obj->task_runner_ && !obj->task_runner_->RunsTasksInCurrentSequence()) {
sdefresne2eb633d2014-10-08 12:31:5615 obj->task_runner_->DeleteSoon(FROM_HERE, obj);
16 } else {
17 delete obj;
18 }
19}
20
21} // namespace impl
22
23RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) {
24}
25
26RefcountedKeyedService::RefcountedKeyedService(
gab28fb80be2016-12-19 20:09:2827 scoped_refptr<base::SequencedTaskRunner> task_runner)
28 : task_runner_(std::move(task_runner)) {}
sdefresne2eb633d2014-10-08 12:31:5629
gab28fb80be2016-12-19 20:09:2830RefcountedKeyedService::~RefcountedKeyedService() = default;