Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / keyed_service / content / refcounted_browser_context_keyed_service.cc
blob6955846e20b1729ef862cf4fb08af6fc227affc3
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.
5 #include "components/keyed_service/content/refcounted_browser_context_keyed_service.h"
7 namespace impl {
9 // static
10 void RefcountedBrowserContextKeyedServiceTraits::Destruct(
11 const RefcountedBrowserContextKeyedService* obj) {
12 if (obj->requires_destruction_on_thread_ &&
13 !content::BrowserThread::CurrentlyOn(obj->thread_id_)) {
14 content::BrowserThread::DeleteSoon(obj->thread_id_, FROM_HERE, obj);
15 } else {
16 delete obj;
20 } // namespace impl
22 RefcountedBrowserContextKeyedService::RefcountedBrowserContextKeyedService()
23 : requires_destruction_on_thread_(false),
24 thread_id_(content::BrowserThread::UI) {}
26 RefcountedBrowserContextKeyedService::RefcountedBrowserContextKeyedService(
27 const content::BrowserThread::ID thread_id)
28 : requires_destruction_on_thread_(true), thread_id_(thread_id) {}
30 RefcountedBrowserContextKeyedService::~RefcountedBrowserContextKeyedService() {}