Chromium Code Reviews| 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 "base/location.h" | 7 #include <utility> |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 |
| 9 #include "base/threading/sequenced_task_runner_handle.h" | |
| 9 | 10 |
| 10 namespace impl { | 11 namespace impl { |
| 11 | 12 |
| 12 // static | 13 // static |
| 13 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) { | 14 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) { |
| 14 if (obj->task_runner_.get() != nullptr && | 15 if (obj->task_runner_.get() != nullptr && |
| 15 obj->task_runner_.get() != base::ThreadTaskRunnerHandle::Get()) { | 16 base::SequencedTaskRunnerHandle::IsSet() && |
| 17 obj->task_runner_.get() != base::SequencedTaskRunnerHandle::Get()) { | |
|
Bernhard Bauer
2016/12/19 17:07:29
Do we have a guarantee that STRH's can be compared
gab
2016/12/19 18:25:56
No we don't (in practice it's true for MessageLoop
| |
| 16 obj->task_runner_->DeleteSoon(FROM_HERE, obj); | 18 obj->task_runner_->DeleteSoon(FROM_HERE, obj); |
| 17 } else { | 19 } else { |
| 18 delete obj; | 20 delete obj; |
| 19 } | 21 } |
| 20 } | 22 } |
| 21 | 23 |
| 22 } // namespace impl | 24 } // namespace impl |
| 23 | 25 |
| 24 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) { | 26 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) { |
| 25 } | 27 } |
| 26 | 28 |
| 27 RefcountedKeyedService::RefcountedKeyedService( | 29 RefcountedKeyedService::RefcountedKeyedService( |
| 28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | 30 scoped_refptr<base::SequencedTaskRunner> task_runner) |
| 29 : task_runner_(task_runner) { | 31 : task_runner_(std::move(task_runner)) {} |
| 30 } | |
| 31 | 32 |
| 32 RefcountedKeyedService::~RefcountedKeyedService() { | 33 RefcountedKeyedService::~RefcountedKeyedService() = default; |
| 33 } | |
| OLD | NEW |