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 "chromecast/service/cast_service.h"
7 #include "base/logging.h"
8 #include "base/run_loop.h"
9 #include "base/threading/thread_checker.h"
11 namespace chromecast
{
13 CastService::CastService(
14 content::BrowserContext
* browser_context
,
15 PrefService
* pref_service
)
16 : browser_context_(browser_context
),
17 pref_service_(pref_service
),
19 thread_checker_(new base::ThreadChecker()) {
22 CastService::~CastService() {
23 DCHECK(thread_checker_
->CalledOnValidThread());
27 void CastService::Initialize() {
28 DCHECK(thread_checker_
->CalledOnValidThread());
32 void CastService::Finalize() {
33 DCHECK(thread_checker_
->CalledOnValidThread());
37 void CastService::Start() {
38 DCHECK(thread_checker_
->CalledOnValidThread());
43 void CastService::Stop() {
44 DCHECK(thread_checker_
->CalledOnValidThread());
46 // Consume any pending tasks which should be done before destroying in-process
47 // renderer process, for example, destroying web_contents.
48 base::RunLoop().RunUntilIdle();
52 } // namespace chromecast