Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: components/keyed_service/core/refcounted_keyed_service.cc

Issue 2581213002: Force HostContentSettingsMap to be destroyed on its owning thread. (Closed)
Patch Set: s/STRH comparison/RunsTasksOnCurrentThread/ Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/keyed_service/core/refcounted_keyed_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
9 8
10 namespace impl { 9 namespace impl {
11 10
12 // static 11 // static
13 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) { 12 void RefcountedKeyedServiceTraits::Destruct(const RefcountedKeyedService* obj) {
14 if (obj->task_runner_.get() != nullptr && 13 if (obj->task_runner_ && !obj->task_runner_->RunsTasksOnCurrentThread()) {
15 obj->task_runner_.get() != base::ThreadTaskRunnerHandle::Get()) {
16 obj->task_runner_->DeleteSoon(FROM_HERE, obj); 14 obj->task_runner_->DeleteSoon(FROM_HERE, obj);
17 } else { 15 } else {
18 delete obj; 16 delete obj;
19 } 17 }
20 } 18 }
21 19
22 } // namespace impl 20 } // namespace impl
23 21
24 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) { 22 RefcountedKeyedService::RefcountedKeyedService() : task_runner_(nullptr) {
25 } 23 }
26 24
27 RefcountedKeyedService::RefcountedKeyedService( 25 RefcountedKeyedService::RefcountedKeyedService(
28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) 26 scoped_refptr<base::SequencedTaskRunner> task_runner)
29 : task_runner_(task_runner) { 27 : task_runner_(std::move(task_runner)) {}
30 }
31 28
32 RefcountedKeyedService::~RefcountedKeyedService() { 29 RefcountedKeyedService::~RefcountedKeyedService() = default;
33 }
OLDNEW
« no previous file with comments | « components/keyed_service/core/refcounted_keyed_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698