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/browser/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 metrics::CastMetricsServiceClient
* metrics_service_client
)
17 : browser_context_(browser_context
),
18 pref_service_(pref_service
),
19 metrics_service_client_(metrics_service_client
),
21 thread_checker_(new base::ThreadChecker()) {
24 CastService::~CastService() {
25 DCHECK(thread_checker_
->CalledOnValidThread());
29 void CastService::Initialize() {
30 DCHECK(thread_checker_
->CalledOnValidThread());
34 void CastService::Finalize() {
35 DCHECK(thread_checker_
->CalledOnValidThread());
39 void CastService::Start() {
40 DCHECK(thread_checker_
->CalledOnValidThread());
45 void CastService::Stop() {
46 DCHECK(thread_checker_
->CalledOnValidThread());
48 // Consume any pending tasks which should be done before destroying in-process
49 // renderer process, for example, destroying web_contents.
50 base::RunLoop().RunUntilIdle();
54 } // namespace chromecast