We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / chromecast / browser / service / cast_service.cc
blob91fd2e4e9570e177ce28f3fa8d1aa7228fc5f024
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),
20 stopped_(true),
21 thread_checker_(new base::ThreadChecker()) {
24 CastService::~CastService() {
25 DCHECK(thread_checker_->CalledOnValidThread());
26 DCHECK(stopped_);
29 void CastService::Initialize() {
30 DCHECK(thread_checker_->CalledOnValidThread());
31 InitializeInternal();
34 void CastService::Finalize() {
35 DCHECK(thread_checker_->CalledOnValidThread());
36 FinalizeInternal();
37 // Consume any pending tasks which may access components being destroyed soon.
38 base::RunLoop().RunUntilIdle();
41 void CastService::Start() {
42 DCHECK(thread_checker_->CalledOnValidThread());
43 stopped_ = false;
44 StartInternal();
47 void CastService::Stop() {
48 DCHECK(thread_checker_->CalledOnValidThread());
49 StopInternal();
50 // Consume any pending tasks which should be done before destroying in-process
51 // renderer process, for example, destroying web_contents.
52 base::RunLoop().RunUntilIdle();
53 stopped_ = true;
56 } // namespace chromecast