summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles/refcounted_profile_keyed_service.cc
blob: aa8eeae6bab3b2a7b56c9fc0a7e85dabd165ff24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/profiles/refcounted_profile_keyed_service.h"

namespace impl {

// static
void RefcountedProfileKeyedServiceTraits::Destruct(
    const RefcountedProfileKeyedService* obj) {
  if (obj->requires_destruction_on_thread_ &&
      !content::BrowserThread::CurrentlyOn(obj->thread_id_)) {
    content::BrowserThread::DeleteSoon(obj->thread_id_, FROM_HERE, obj);
  } else {
    delete obj;
  }
}

}  // namespace impl

RefcountedProfileKeyedService::RefcountedProfileKeyedService()
    : requires_destruction_on_thread_(false),
      thread_id_(content::BrowserThread::UI) {
}

RefcountedProfileKeyedService::RefcountedProfileKeyedService(
    const content::BrowserThread::ID thread_id)
    : requires_destruction_on_thread_(true),
      thread_id_(thread_id) {
}

RefcountedProfileKeyedService::~RefcountedProfileKeyedService() {}