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/renderer/cast_render_process_observer.h"
7 #include "chromecast/renderer/media/cma_message_filter_proxy.h"
8 #include "content/public/renderer/render_thread.h"
10 namespace chromecast
{
13 CastRenderProcessObserver::CastRenderProcessObserver() {
14 content::RenderThread
* thread
= content::RenderThread::Get();
15 thread
->AddObserver(this);
16 CreateCustomFilters();
19 CastRenderProcessObserver::~CastRenderProcessObserver() {
20 // CastRenderProcessObserver outlives content::RenderThread.
21 // No need to explicitly call RemoveObserver in teardown.
24 void CastRenderProcessObserver::CreateCustomFilters() {
25 #if !defined(OS_ANDROID)
26 content::RenderThread
* thread
= content::RenderThread::Get();
27 cma_message_filter_proxy_
=
28 new media::CmaMessageFilterProxy(thread
->GetIOMessageLoopProxy());
29 thread
->AddFilter(cma_message_filter_proxy_
.get());
30 #endif // !defined(OS_ANDROID)
33 void CastRenderProcessObserver::OnRenderProcessShutdown() {
34 #if !defined(OS_ANDROID)
35 content::RenderThread
* thread
= content::RenderThread::Get();
36 if (cma_message_filter_proxy_
.get()) {
37 thread
->RemoveFilter(cma_message_filter_proxy_
.get());
38 cma_message_filter_proxy_
= NULL
;
40 #endif // !defined(OS_ANDROID)
44 } // namespace chromecast