refcounted_keyed_service.cc 842 B

1234567891011121314151617181920212223242526272829
  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
  3. // found in the LICENSE file.
  4. #include "components/keyed_service/core/refcounted_keyed_service.h"
  5. #include <utility>
  6. namespace impl {
  7. // static
  8. void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) {
  9. if (obj->task_runner_ && !obj->task_runner_->RunsTasksInCurrentSequence()) {
  10. obj->task_runner_->DeleteSoon(FROM_HERE, obj);
  11. } else {
  12. delete obj;
  13. }
  14. }
  15. } // namespace impl
  16. RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) {
  17. }
  18. RefcountedKeyedService::RefcountedKeyedService(
  19. scoped_refptr<base::SequencedTaskRunner> task_runner)
  20. : task_runner_(std::move(task_runner)) {}
  21. RefcountedKeyedService::~RefcountedKeyedService() = default;