OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/keyed_service/core/refcounted_keyed_service.h" | 5 #include "components/keyed_service/core/refcounted_keyed_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 namespace impl { | 9 namespace impl { |
10 | 10 |
11 // static | 11 // static |
12 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) { | 12 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) { |
13 if (obj->task_runner_ && !obj->task_runner_->RunsTasksOnCurrentThread()) { | 13 if (obj->task_runner_ && !obj->task_runner_->RunsTasksInCurrentSequence()) { |
14 obj->task_runner_->DeleteSoon(FROM_HERE, obj); | 14 obj->task_runner_->DeleteSoon(FROM_HERE, obj); |
15 } else { | 15 } else { |
16 delete obj; | 16 delete obj; |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 } // namespace impl | 20 } // namespace impl |
21 | 21 |
22 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) { | 22 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) { |
23 } | 23 } |
24 | 24 |
25 RefcountedKeyedService::RefcountedKeyedService( | 25 RefcountedKeyedService::RefcountedKeyedService( |
26 scoped_refptr<base::SequencedTaskRunner> task_runner) | 26 scoped_refptr<base::SequencedTaskRunner> task_runner) |
27 : task_runner_(std::move(task_runner)) {} | 27 : task_runner_(std::move(task_runner)) {} |
28 | 28 |
29 RefcountedKeyedService::~RefcountedKeyedService() = default; | 29 RefcountedKeyedService::~RefcountedKeyedService() = default; |
OLD | NEW |